# HG changeset patch # User Tuomo Valkonen # Date 1599419572 -10800 # Node ID 2f927eae429b54c348eb526918e14caf4591248d # Parent 4c7122a505d4f0205bd622259cf30f31c04d52bd Don't auto-create directories that will be empty diff -r 4c7122a505d4 -r 2f927eae429b handlers/copy.lua --- a/handlers/copy.lua Sun Sep 06 21:24:39 2020 +0300 +++ b/handlers/copy.lua Sun Sep 06 22:12:52 2020 +0300 @@ -2,6 +2,7 @@ --@module handlers.copy local path=require("mypath") +local lfs=require("lfs") local handlers_copy={} diff -r 4c7122a505d4 -r 2f927eae429b lgen.lua --- a/lgen.lua Sun Sep 06 21:24:39 2020 +0300 +++ b/lgen.lua Sun Sep 06 22:12:52 2020 +0300 @@ -56,7 +56,7 @@ scan.map(hierarchy, function(f) handlers.phase2(f, env) end, function(d) --log.log("Make path "..path.join(dst, d).."\n") - lfs.mkdir(path.join(dst, d)) + --lfs.mkdir(path.join(dst, d)) end) --print('Phase 3...') --scan.map(hierarchy, function(f) handlers.phase3(f, env) end) diff -r 4c7122a505d4 -r 2f927eae429b luaext.lua --- a/luaext.lua Sun Sep 06 21:24:39 2020 +0300 +++ b/luaext.lua Sun Sep 06 22:12:52 2020 +0300 @@ -6,6 +6,8 @@ -- See the included file LICENSE for details. -- +local lfs=require("lfs") +local path=require("mypath") --DOC -- Make \var{str} shell-safe. @@ -87,8 +89,15 @@ end end -function io.openX(file, ...) - local f, err = io.open(file, ...) +function io.openX(file, mode) + if mode=='w' then + local dn = path.dirname(file) + if not lfs.attributes(dn) then + print("Ensure directory", dn) + lfs.mkdir(dn) + end + end + local f, err = io.open(file, mode) if not f then error(file..": "..err) end diff -r 4c7122a505d4 -r 2f927eae429b mypath.lua --- a/mypath.lua Sun Sep 06 21:24:39 2020 +0300 +++ b/mypath.lua Sun Sep 06 22:12:52 2020 +0300 @@ -28,7 +28,7 @@ end function path.dirname(p) - return tuple.fst(dirbasename(p)) + return tuple.fst(path.dirbasename(p)) end function path.dirname_slash(p) diff -r 4c7122a505d4 -r 2f927eae429b tuple.lua --- a/tuple.lua Sun Sep 06 21:24:39 2020 +0300 +++ b/tuple.lua Sun Sep 06 22:12:52 2020 +0300 @@ -2,7 +2,7 @@ --@module tuple local tuple={} -function tuplefst(a, b) +function tuple.fst(a, b) return a end