1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-26 08:56:54 +00:00

Merge pull request #429 from Wilma456/iofix

Fix io API
This commit is contained in:
Daniel Ratcliffe 2017-09-09 23:59:57 +01:00 committed by GitHub
commit 707f0899da

View File

@ -49,13 +49,13 @@ function input( _arg )
elseif _G.type( _arg ) == "nil" then elseif _G.type( _arg ) == "nil" then
return g_currentInput return g_currentInput
else else
error( "bad argument #1 (expected string/table/nil, got " .. type( _arg ) .. ")", 2 ) error( "bad argument #1 (expected string/table/nil, got " .. _G.type( _arg ) .. ")", 2 )
end end
end end
function lines( _sFileName ) function lines( _sFileName )
if type( _sFileNamel ) ~= "string" then if _G.type( _sFileNamel ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sFileName ) .. ")", 2 ) error( "bad argument #1 (expected string, got " .. _G.type( _sFileName ) .. ")", 2 )
end end
if _sFileName then if _sFileName then
return open( _sFileName, "r" ):lines() return open( _sFileName, "r" ):lines()
@ -65,11 +65,11 @@ function lines( _sFileName )
end end
function open( _sPath, _sMode ) function open( _sPath, _sMode )
if type( _sPath ) ~= "string" then if _G.type( _sPath ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 ) error( "bad argument #1 (expected string, got " .. _G.type( _sPath ) .. ")", 2 )
end end
if type( _sMode ) ~= "string" then if _sMode ~= nil and _G.type( _sMode ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( _sMode ) .. ")", 2 ) error( "bad argument #2 (expected string, got " .. _G.type( _sMode ) .. ")", 2 )
end end
local sMode = _sMode or "r" local sMode = _sMode or "r"
local file, err = fs.open( _sPath, sMode ) local file, err = fs.open( _sPath, sMode )
@ -167,7 +167,7 @@ function output( _arg )
elseif _G.type( _arg ) == "nil" then elseif _G.type( _arg ) == "nil" then
return g_currentOutput return g_currentOutput
else else
error( "bad argument #1 (expected string/table/nil, got " .. type( _arg ) .. ")", 2 ) error( "bad argument #1 (expected string/table/nil, got " .. _G.type( _arg ) .. ")", 2 )
end end
end end