文件模块新增两个删除文件的方法
This commit is contained in:
@@ -57,4 +57,32 @@ function FILE.save(data,name,mode)
|
|||||||
LOG.print(debug.traceback(),'error')
|
LOG.print(debug.traceback(),'error')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function FILE.clear(path)
|
||||||
|
if fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory'then return end
|
||||||
|
for _,name in next,fs.getDirectoryItems(path)do
|
||||||
|
name=path.."/"..name
|
||||||
|
if fs.getRealDirectory(name)==SAVEDIR then
|
||||||
|
local t=fs.getInfo(name).type
|
||||||
|
if t=='file'then
|
||||||
|
fs.remove(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function FILE.clear_s(path)
|
||||||
|
if path~=""and(fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory')then return end
|
||||||
|
for _,name in next,fs.getDirectoryItems(path)do
|
||||||
|
name=path.."/"..name
|
||||||
|
if fs.getRealDirectory(name)==SAVEDIR then
|
||||||
|
local t=fs.getInfo(name).type
|
||||||
|
if t=='file'then
|
||||||
|
fs.remove(name)
|
||||||
|
elseif t=='directory'then
|
||||||
|
FILE.clear_s(name)
|
||||||
|
fs.remove(name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
fs.remove(path)
|
||||||
|
end
|
||||||
return FILE
|
return FILE
|
||||||
Reference in New Issue
Block a user