test: rmdir(): recursively delete

This commit is contained in:
Justin M. Keyes
2016-06-05 02:51:50 -04:00
parent af161dcfb8
commit 5f5f2d8945

View File

@@ -345,13 +345,21 @@ local function rmdir(path)
end
for file in lfs.dir(path) do
if file ~= '.' and file ~= '..' then
local ret, err = os.remove(path..'/'..file)
local abspath = path..'/'..file
if lfs.attributes(abspath, 'mode') == 'directory' then
local ret = rmdir(abspath) -- recurse
if not ret then
return nil
end
else
local ret, err = os.remove(abspath)
if not ret then
error('os.remove: '..err)
return nil
end
end
end
end
local ret, err = os.remove(path)
if not ret then
error('os.remove: '..err)