1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-13 11:40:29 +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
local file = nil
local function innerSave()
file = fs.open( _sPath, "w" )
file, fileerr = fs.open( _sPath, "w" )
if file then
for n, sLine in ipairs( tLines ) do
file.write( sLine .. "\n" )
@ -107,7 +107,7 @@ local function save( _sPath )
if file then
file.close()
end
return ok, err
return ok, err, fileerr
end
local tKeywords = {
@ -287,11 +287,15 @@ local tMenuFuncs = {
if bReadOnly then
sStatus = "Access denied"
else
local ok, err = save( sPath )
local ok, err, fileerr = save( sPath )
if ok then
sStatus="Saved to "..sPath
else
sStatus="Error saving to "..sPath
if fileerr then
sStatus="Error saving to "..sPath.." ("..fileerr..")"
else
sStatus="Error saving to "..sPath
end
end
end
redrawMenu()

View File

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