Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component_invoke = component.invoke
- function boot_invoke(address, method, ...)
- local result = table.pack(pcall(component_invoke, address, method, ...))
- if not result[1] then
- return nil, result[2]
- else
- return table.unpack(result, 2, result.n)
- end
- end
- function stream(fd,file,mode)
- checkArg(1,fd,'number')
- assert(fd>=0,'fd must be >= 0. 0 is input, 1 is stdout, 2 is stderr')
- if file then
- if type(file) == "string" then
- local result, reason = io.open(file, mode)
- if not result then
- error(reason, 2)
- end
- file = result
- elseif not io.type(file) then
- error("bad argument #1 (string or file expected, got " .. type(file) .. ")", 2)
- end
- require("process").info().data.io[fd] = file
- end
- return require("process").info().data.io[fd]
- end
- function input(file)
- return stream(0, file, 'r')
- end
- function write(...)
- return output():write(...)
- end
- -- backwards compatibility, may remove later
- local eeprom = component.list("eeprom")()
- computer.getBootAddress = function()
- return boot_invoke(eeprom, "getData")
- end
- computer.setBootAddress = function(address)
- return boot_invoke(eeprom, "setData", address)
- end
- local screen = component.list("screen")()
- local gpu = component.list("gpu")()
- if gpu and screen then
- boot_invoke(gpu, "bind", screen)
- end
- fs = component.list("filesystem")
- for k, v in pairs(fs) do
- write(k)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement