forked from Hyperion/HyperionOS
Hyperion v1.2.0
This commit is contained in:
@@ -1,24 +1,33 @@
|
||||
local args = {...}
|
||||
local name = syscall.getTask(syscall.getpid()).name
|
||||
local fs = require("sys.fs")
|
||||
local filePath = (args[1] or "")
|
||||
if filePath:sub(1, 1) ~= "/" then
|
||||
filePath = syscall.getcwd().."/"..filePath
|
||||
end
|
||||
|
||||
if not fs.exists(filePath) and args[1] then
|
||||
print(name..": Cannot access '"..args[1].."': No such file.")
|
||||
if not args[1] then
|
||||
while true do
|
||||
local content = syscall.read(0, 1024)
|
||||
if not content or content == "" then break end
|
||||
printInline(content)
|
||||
end
|
||||
print("")
|
||||
return
|
||||
end
|
||||
|
||||
local file = 0
|
||||
if args[1] then
|
||||
file = syscall.open(filePath, "r")
|
||||
for _, arg in ipairs(args) do
|
||||
local filePath = arg
|
||||
if filePath:sub(1,1) ~= "/" then
|
||||
filePath = syscall.getcwd().."/"..filePath
|
||||
end
|
||||
|
||||
if not fs.exists(filePath) then
|
||||
print(name..": Cannot access '"..arg.."': No such file.")
|
||||
else
|
||||
local fd = syscall.open(filePath, "r")
|
||||
while true do
|
||||
local content = syscall.read(fd, 1024)
|
||||
if not content or content == "" then break end
|
||||
printInline(content)
|
||||
end
|
||||
syscall.close(fd)
|
||||
end
|
||||
end
|
||||
local content=""
|
||||
while content~=nil or file == 0 do
|
||||
content=syscall.read(file, 1024)
|
||||
printInline(content)
|
||||
end
|
||||
syscall.close(file)
|
||||
print("")
|
||||
print("")
|
||||
|
||||
Reference in New Issue
Block a user