在lua中递归删除一个文件夹中ios热更新删除zip遇到的问题

Cocos2d: rmdir: /Users/xxx/Library/Developer/CoreSimulator/Devices/54DFBA71-9973-49CC-BD4A-A33E5D32901E/data/Containers/Data/Application/9440671C-FBAD-4DE2-A763-0D4CDA8CB2BA/Documents/update.zip
Cocos2d: ----------------------------------------
Cocos2d: LUA ERROR: :179: cannot open /Users/Rickee/Library/Developer/CoreSimulator/Devices/54DFBA71-9973-49CC-BD4A-A33E5D32901E/data/Containers/Data/Application/9440671C-FBAD-4DE2-A763-0D4CDA8CB2BA/Documents/update.zip: Not a directory

调用语句:
if exists(path) then
local function _rmdir(path)
local iter, dir_obj = lfs.dir(path)
while true do
local dir = iter(dir_obj)
print(“dir=”, dir)
if dir == nil then break end
if dir ~= “.” and dir ~= “…” then
local curDir = path…dir
local mode = lfs.attributes(curDir, “mode”)
if mode == “directory” then
_rmdir(curDir…"/")
elseif mode == “file” then
os.remove(curDir)
end
end
end
local succ, des = os.remove(path)
if des then print(des) end
return succ
end
_rmdir(path)
end

更新完删除zip在红色的那句报了这些错误,是不是我调用的有错误,麻烦大神教下把

:13:是不是这个只能删除文件夹和包含的文件啊

:10:Not a directory

lfs.dir()是取一个目录下的所有文件,参数只允许是目录名,不能是文件名