1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-13 19:50:31 +00:00

Show fs error in paint and edit

This commit is contained in:
Wilma456 2017-07-28 15:36:33 +02:00
parent 579f7443a8
commit c9e7b45509
2 changed files with 16 additions and 8 deletions

View File

@ -93,7 +93,7 @@ local function save( _sPath )
-- Save -- Save
local file = nil local file = nil
local function innerSave() local function innerSave()
file = fs.open( _sPath, "w" ) file, fileerr = fs.open( _sPath, "w" )
if file then if file then
for n, sLine in ipairs( tLines ) do for n, sLine in ipairs( tLines ) do
file.write( sLine .. "\n" ) file.write( sLine .. "\n" )
@ -107,7 +107,7 @@ local function save( _sPath )
if file then if file then
file.close() file.close()
end end
return ok, err return ok, err, fileerr
end end
local tKeywords = { local tKeywords = {
@ -287,11 +287,15 @@ local tMenuFuncs = {
if bReadOnly then if bReadOnly then
sStatus = "Access denied" sStatus = "Access denied"
else else
local ok, err = save( sPath ) local ok, err, fileerr = save( sPath )
if ok then if ok then
sStatus="Saved to "..sPath sStatus="Saved to "..sPath
else else
sStatus="Error saving to "..sPath if fileerr then
sStatus="Error saving to "..sPath.." ("..fileerr..")"
else
sStatus="Error saving to "..sPath
end
end end
end end
redrawMenu() redrawMenu()

View File

@ -128,9 +128,9 @@ local function save(path)
fs.makeDir(sDir) fs.makeDir(sDir)
end end
local file = fs.open( path, "w" ) local file, err = fs.open( path, "w" )
if not file then if not file then
return false return false, err
end end
-- Encode (and trim) -- Encode (and trim)
@ -313,11 +313,15 @@ local function accessMenu()
fMessage = "Access denied" fMessage = "Access denied"
return false return false
end end
local success = save(sPath) local success, err = save(sPath)
if success then if success then
fMessage = "Saved to "..sPath fMessage = "Saved to "..sPath
else else
fMessage = "Error saving to "..sPath if err then
fMessage = "Error saving to "..sPath.." ("..err..")"
else
fMessage = "Error saving to "..sPath
end
end end
return false return false
elseif mChoices[selection]=="Exit" then elseif mChoices[selection]=="Exit" then