handlers/copy.lua

changeset 3
b2df1b3f2c83
parent 2
3975fa5ed630
child 7
038275cd92ed
--- a/handlers/copy.lua	Sat Sep 12 21:27:57 2009 +0300
+++ b/handlers/copy.lua	Sun Sep 13 22:22:47 2009 +0300
@@ -1,9 +1,25 @@
 
 module("handlers.copy", package.seeall)
 
-function phase1(f, env)
+require("dependency")
+require("log")
+
+function phase1(file, env)
 end
     
-function phase2(f, env)
-    -- copy here!
+function phase2(file, env)
+    local src=path.join(env.paths.src, file)
+    local dst=path.join(env.paths.dst, file)
+    if dependency.simple_update_check(dst, {src}) then
+        log.log("Copy "..file.."\n")
+        local f = io.openX(src, 'r')
+        local dstf = io.openX(dst, 'w')
+        while true do
+            local data=f:read(1024*1024)
+            if not data then
+                break
+            end
+            dstf:write(data)
+        end
+    end
 end

mercurial