Sun, 06 Sep 2020 22:12:52 +0300
Don't auto-create directories that will be empty
2 | 1 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
2 | --@module handlers.copy |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
3 | |
26
77cd7b8fb6a6
Rename path.lua mypath.lua not conflict with other lua path modules.
Tuomo Valkonen <tuomov@iki.fi>
parents:
7
diff
changeset
|
4 | local path=require("mypath") |
35
2f927eae429b
Don't auto-create directories that will be empty
Tuomo Valkonen <tuomov@iki.fi>
parents:
26
diff
changeset
|
5 | local lfs=require("lfs") |
2 | 6 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
7 | local handlers_copy={} |
3 | 8 | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
9 | local dependency=require("dependency") |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
10 | local log=require("log") |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
11 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
12 | function handlers_copy.phase1(file, env) |
2 | 13 | end |
14 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
15 | function handlers_copy.phase2(file, env) |
3 | 16 | local src=path.join(env.paths.src, file) |
17 | local dst=path.join(env.paths.dst, file) | |
18 | if dependency.simple_update_check(dst, {src}) then | |
19 | log.log("Copy "..file.."\n") | |
20 | local f = io.openX(src, 'r') | |
21 | local dstf = io.openX(dst, 'w') | |
22 | while true do | |
23 | local data=f:read(1024*1024) | |
24 | if not data then | |
25 | break | |
26 | end | |
27 | dstf:write(data) | |
28 | end | |
29 | end | |
2 | 30 | end |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
31 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
3
diff
changeset
|
32 | return handlers_copy |