From b76b82d6ee0f3ebf5775640c395a7dc18dcca880 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 19 Dec 2020 15:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96=E6=9B=B4?= =?UTF-8?q?=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/file.lua | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Zframework/file.lua b/Zframework/file.lua index 8418e8ff..9c34c852 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -1,28 +1,25 @@ local fs=love.filesystem local FILE={} function FILE.load(name) - local F=fs.newFile(name) - if F:open("r")then - local s=F:read() - F:close() - if s:sub(1,6)=="return"then - s=loadstring(s) - if s then - setfenv(s,{}) - return s() + if fs.getInfo(name)then + local F=fs.newFile(name) + if F:open("r")then + local s=F:read() + F:close() + if s:sub(1,6)=="return"then + s=loadstring(s) + if s then + setfenv(s,{}) + return s() + end else - LOG.print(name.." "..text.loadError,COLOR.red) - return - end - else - local res=json.decode(s) - if res then - return res - else - LOG.print(name.." "..text.loadError,COLOR.red) - return + local res=json.decode(s) + if res then + return res + end end end + LOG.print(name.." "..text.loadError,COLOR.red) end end function FILE.save(data,name,mode)