From c25f2f7cb6272baca8ba3fb704c97e19ab5d5c5a Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 28 May 2021 01:23:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=A8=A1=E5=9D=97=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=B8=A4=E4=B8=AA=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/file.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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