2017-07-31 12:10:24 +10:00
|
|
|
-- not gonna lie, this was just ported from MultICE. Code is terrible and I should rewrite it.
|
|
|
|
_G.io = {}
|
|
|
|
io.write = write
|
|
|
|
function io.open(n,m)
|
|
|
|
m=m or "rb"
|
|
|
|
local h=fs.open(n,m)
|
|
|
|
if h and m:sub(1,1) == "w" then
|
2017-08-03 17:54:38 +10:00
|
|
|
bt=buffer.ucreate()
|
2017-08-27 04:22:11 +10:00
|
|
|
function bt.write(_,d)
|
2017-08-20 16:01:25 +10:00
|
|
|
return fs.write(h,d)
|
2017-08-03 17:54:38 +10:00
|
|
|
end
|
2017-08-27 04:22:11 +10:00
|
|
|
function bt.close()
|
|
|
|
return fs.close(h)
|
|
|
|
end
|
2017-08-03 17:54:38 +10:00
|
|
|
return bt
|
|
|
|
elseif h and m:sub(1,1) == "r" then
|
|
|
|
bt = buffer.ucreate()
|
|
|
|
local sb = ""
|
|
|
|
repeat
|
|
|
|
bt.b=bt.b..sb
|
|
|
|
sb=fs.read(h,2048)
|
|
|
|
until sb == "" or sb == nil
|
|
|
|
fs.close(h)
|
|
|
|
coroutine.yield()
|
|
|
|
return bt
|
2017-07-31 12:10:24 +10:00
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|