# HG changeset patch # User Tuomo Valkonen # Date 1737721665 -3600 # Node ID 5700ebe9277b8170b5292fbb3f2d4e363c8950de # Parent 20606bf1a6a03196746458dda38f131a39c5cd08 Fix directory creation, as lfs doesn't do all leaves like the old approach. diff -r 20606bf1a6a0 -r 5700ebe9277b luaext.lua --- a/luaext.lua Sun Aug 06 21:12:43 2023 +0300 +++ b/luaext.lua Fri Jan 24 13:27:45 2025 +0100 @@ -89,13 +89,18 @@ end end +function ensure_dir_of(name) + local dn = path.dirname(name) + if dn ~= "" and not lfs.attributes(dn) then + ensure_dir_of(dn) + print("Creating directory", dn) + lfs.mkdir(dn) + end +end + 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 + ensure_dir_of(file) end local f, err = io.open(file, mode) if not f then