在lua中递归删除一个文件夹
发布时间:2020-12-14 22:08:28 所属栏目:大数据 来源:网络整理
导读:require ( "lfs" ) ? function os.exists(path) ???? return CCFileUtils:sharedFileUtils():isFileExist(path) end ? os.mkdir(path) if not os.exists(path) then ???????? lfs.mkdir(path) end return true end ? os.rmdir(path) ???? print "os.rmdir:"
require
(
"lfs"
)
?
function
os.exists(path)
????
return
CCFileUtils:sharedFileUtils():isFileExist(path)
end
?
os.mkdir(path)
if
not
os.exists(path)
then
????????
lfs.mkdir(path)
end
return
true
end
?
os.rmdir(path)
????
print
"os.rmdir:"
,path)
if
then
local
function
_rmdir(path)
????????????
local
iter,dir_obj = lfs.dir(path)
while
true
do
????????????????
dir = iter(dir_obj)
dir ==
nil
then
break
end
dir ~=
"."
and
".."
then
????????????????????
curDir = path..dir
mode = lfs.attributes(curDir,
"mode"
)
mode ==
"directory"
then
????????????????????????
_rmdir(curDir..
"/"
)
elseif
"file"
then
????????????????????????
os.remove
(curDir)
end
end
end
succ,des =
(path)
des
then
print
(des)
end
succ
end
????????
_rmdir(path)
end
true
end
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |