mirror of
https://github.com/neovim/neovim.git
synced 2025-11-04 17:54:30 +00:00
test: rmdir(): recursively delete
This commit is contained in:
@@ -345,13 +345,21 @@ local function rmdir(path)
|
|||||||
end
|
end
|
||||||
for file in lfs.dir(path) do
|
for file in lfs.dir(path) do
|
||||||
if file ~= '.' and file ~= '..' then
|
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
|
if not ret then
|
||||||
error('os.remove: '..err)
|
error('os.remove: '..err)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local ret, err = os.remove(path)
|
local ret, err = os.remove(path)
|
||||||
if not ret then
|
if not ret then
|
||||||
error('os.remove: '..err)
|
error('os.remove: '..err)
|
||||||
|
|||||||
Reference in New Issue
Block a user