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