I am deleting a folder in which I have other files, however, when deleting, the files are simply deleted, not the folder itself. That is, files are deleted, but the folder itself and folders remain in it. Here is my code. Help please.
local function deleteFolder(path)
if not folderExists(path) then
print("Папка не существует: "..path)
return false
end
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..'/'..file
local attr = lfs.attributes(f)
if attr.mode == "directory" then
deleteFolder(f)
else
os.remove(f)
end
end
end
local success = lfs.rmdir(path)
if success then
print("Папка успешно удалена: "..path)
return true
else
print("Ошибка при удалении папки: "..path)
return false
end
end