diff --git a/Zframework/file.lua b/Zframework/file.lua index b756701f..e64b6cbb 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -57,4 +57,32 @@ function FILE.save(data,name,mode) LOG.print(debug.traceback(),'error') 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 \ No newline at end of file