made io buffers actually write, hopefully.
This commit is contained in:
parent
45d0b85887
commit
ee7da224f1
@ -4,20 +4,11 @@ io.write = write
|
|||||||
function io.open(n,m)
|
function io.open(n,m)
|
||||||
m=m or "rb"
|
m=m or "rb"
|
||||||
local h=fs.open(n,m)
|
local h=fs.open(n,m)
|
||||||
if h then
|
|
||||||
if h and m:sub(1,1) == "w" then
|
if h and m:sub(1,1) == "w" then
|
||||||
bt=buffer.ucreate()
|
bt=buffer.ucreate()
|
||||||
spawn("io worker: "..n,function()
|
function bt.write(d)
|
||||||
while true do
|
return fs.write(h,d)
|
||||||
if bt.s ~= "open" and bt.b == "" then fclose(h) break end
|
|
||||||
nd = bt.b
|
|
||||||
if nd ~= nil and nd ~= "" then
|
|
||||||
fs.write(h,nd)
|
|
||||||
end
|
end
|
||||||
bt.b = ""
|
|
||||||
coroutine.yield()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
return bt
|
return bt
|
||||||
elseif h and m:sub(1,1) == "r" then
|
elseif h and m:sub(1,1) == "r" then
|
||||||
bt = buffer.ucreate()
|
bt = buffer.ucreate()
|
||||||
@ -29,7 +20,6 @@ function io.open(n,m)
|
|||||||
fs.close(h)
|
fs.close(h)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
return bt
|
return bt
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user