整理代码习惯,常量字符串改用单引号,可能有遗漏
This commit is contained in:
@@ -3,7 +3,7 @@ local FILE={}
|
||||
function FILE.load(name)
|
||||
if fs.getInfo(name)then
|
||||
local F=fs.newFile(name)
|
||||
if F:open("r")then
|
||||
if F:open'r'then
|
||||
local s=F:read()
|
||||
F:close()
|
||||
if s:sub(1,6)=="return"then
|
||||
@@ -26,17 +26,17 @@ function FILE.load(name)
|
||||
end
|
||||
function FILE.save(data,name,mode)
|
||||
if not mode then mode=""end
|
||||
if type(data)=="table"then
|
||||
if mode:find("l")then
|
||||
if type(data)=='table'then
|
||||
if mode:find'l'then
|
||||
data=TABLE.dump(data)
|
||||
if not data then
|
||||
LOG.print(name.." "..text.saveError.."dump error","error")
|
||||
LOG.print(name.." "..text.saveError.."dump error",'error')
|
||||
return
|
||||
end
|
||||
else
|
||||
data=JSON.encode(data)
|
||||
if not data then
|
||||
LOG.print(name.." "..text.saveError.."json error","error")
|
||||
LOG.print(name.." "..text.saveError.."json error",'error')
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -45,16 +45,16 @@ function FILE.save(data,name,mode)
|
||||
end
|
||||
|
||||
local F=fs.newFile(name)
|
||||
F:open("w")
|
||||
F:open'w'
|
||||
local success,mes=F:write(data)
|
||||
F:flush()F:close()
|
||||
if success then
|
||||
if not mode:find("q")then
|
||||
if not mode:find'q'then
|
||||
LOG.print(text.saveDone,COLOR.G)
|
||||
end
|
||||
else
|
||||
LOG.print(text.saveError..(mes or"unknown error"),"error")
|
||||
LOG.print(debug.traceback(),"error")
|
||||
LOG.print(text.saveError..(mes or"unknown error"),'error')
|
||||
LOG.print(debug.traceback(),'error')
|
||||
end
|
||||
end
|
||||
return FILE
|
||||
Reference in New Issue
Block a user