Sewbacca, on 05 October 2016 - 08:14 PM, said:
if mode:match '^[aw]b?$' then
Smart one, I'll definitely see if it increases performance!
And thanks!
Posted 05 October 2016 - 08:19 PM
Posted 06 October 2016 - 09:48 PM
Posted 07 October 2016 - 04:10 AM
Edited by Creator, 07 October 2016 - 04:11 AM.
Posted 07 October 2016 - 05:59 PM
Posted 07 October 2016 - 10:07 PM
--[[ Shell script: list by Creator for OmniOS ]]-- local path = (...) or getPath() if fs.isDir(path) then for i, v in pairs(fs.list(path)) do if fs.isDir(path.."/"..v) then term.setTextColor(colors.green) print(v) else term.setTextColor(colors.white) print(v) end end else term.setTextColor(colors.red) print("Not a directory.") end term.setTextColor(colors.white)
--[[ Shell script: cat by Creator for OmniOS ]]-- local path = (...) or getPath() if fs.exists(path) and not fs.isDir(path) then local file = fs.open(path,"r") local data = file.readAll() file.close() print(data) elseif fs.isDir(path) then term.setTextColor(colors.red) print("Path is a folder.") else print("File does not exist.") end
Edited by Piorjade, 07 October 2016 - 10:11 PM.
Posted 08 October 2016 - 12:56 PM
Piorjade, on 07 October 2016 - 10:07 PM, said:
--[[ Shell script: list by Creator for OmniOS ]]-- local path = (...) or getPath() if fs.isDir(path) then for i, v in pairs(fs.list(path)) do if fs.isDir(path.."/"..v) then term.setTextColor(colors.green) print(v) else term.setTextColor(colors.white) print(v) end end else term.setTextColor(colors.red) print("Not a directory.") end term.setTextColor(colors.white)
--[[ Shell script: cat by Creator for OmniOS ]]-- local path = (...) or getPath() if fs.exists(path) and not fs.isDir(path) then local file = fs.open(path,"r") local data = file.readAll() file.close() print(data) elseif fs.isDir(path) then term.setTextColor(colors.red) print("Path is a folder.") else print("File does not exist.") end
Posted 08 October 2016 - 06:34 PM
Edited by Piorjade, 08 October 2016 - 08:47 PM.
Posted 10 October 2016 - 08:29 PM
--[[ Zero device ]] local function instance(mode) if mode == "r" then local handle = {} function handle.readLine() return "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" end function handle.readAll() return "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" end function handle.close() handle.readLine = nil handle.readAll = nil handle.close = nil end return handle elseif mode == "rb" then local handle = {} function handle.read() read "\0" end function handle.close() handle.read = nil handle.close = nil end return handle elseif mode == "w" or mode == "a" or mode == "wb" or mode == "ab" then -- try if mode:match '^[aw]b?$' then local handle = {} function handle.write(input) end function handle.writeLine(input) end function handle.flush() end function handle.close() handle.write = nil handle.writeLine = nil handle.flush = nil handle.close = nil end return handle end end return instance
Posted 10 October 2016 - 08:48 PM
Creator, on 10 October 2016 - 08:29 PM, said:
Posted 10 October 2016 - 09:47 PM
Posted 10 October 2016 - 11:30 PM
function handle.read(bytes) local result = "" -- check if bytes is less than 1, if it is a number, etc for i=1,bytes do result = result .. "\0" end return result end
Edited by lkmnds, 10 October 2016 - 11:34 PM.
Posted 11 October 2016 - 04:09 AM
return string.rep("\0", bytes)
Posted 11 October 2016 - 09:02 AM
Lyqyd, on 11 October 2016 - 04:09 AM, said:
return string.rep("\0", bytes)
Edited by Creator, 11 October 2016 - 05:34 PM.
Posted 11 October 2016 - 01:09 PM
Posted 11 October 2016 - 04:48 PM
Creator, on 11 October 2016 - 09:02 AM, said:
Edited by Sewbacca, 16 October 2016 - 04:10 PM.
Posted 11 October 2016 - 05:33 PM
Sewbacca, on 11 October 2016 - 04:48 PM, said:
Creator, on 11 October 2016 - 09:02 AM, said:
Posted 13 October 2016 - 06:29 PM
0 members, 1 guests, 0 anonymous users