forked from izaya/OC-PsychOS2
40 lines
635 B
Lua
40 lines
635 B
Lua
io = {}
|
|
|
|
function io.open(path,mode)
|
|
local f,e = fs.open(path, mode)
|
|
if not f then return false, e end
|
|
return buffer.new(mode,f)
|
|
end
|
|
|
|
function io.input(fd)
|
|
if type(fd) == "string" then
|
|
fd=io.open(fd,"rb")
|
|
end
|
|
if fd then
|
|
os.setenv("STDIN",fd)
|
|
end
|
|
return os.getenv("STDIN")
|
|
end
|
|
function io.output(fd)
|
|
if type(fd) == "string" then
|
|
fd=io.open(fd,"wb")
|
|
end
|
|
if fd then
|
|
os.setenv("STDOUT",fd)
|
|
end
|
|
return os.getenv("STDOUT")
|
|
end
|
|
|
|
function io.read(...)
|
|
return io.input():read()
|
|
end
|
|
function io.write(...)
|
|
io.output():write(...)
|
|
end
|
|
|
|
function print(...)
|
|
for k,v in ipairs({...}) do
|
|
io.write(tostring(v).."\n")
|
|
end
|
|
end
|