add standard lua os methods, another fix for vfs links within links, allow write on urlfs mounted files

This commit is contained in:
kepler155c@gmail.com
2020-05-17 19:36:33 -06:00
parent c7c594d6c3
commit a7e3318226
7 changed files with 64 additions and 39 deletions

View File

@@ -1,3 +1,42 @@
local fs = _G.fs
local fs = _G.fs
local os = _G.os
fs.loadTab('sys/etc/fstab')
-- add some Lua compatibility functions
function os.remove(a)
if fs.exists(a) then
local s = pcall(fs.delete, a)
return s and true or nil, a .. ': Unable to remove file'
end
return nil, a .. ': No such file or directory'
end
os.execute = function(cmd)
if not cmd then
return 1
end
local env = _G.getfenv(2)
local s, m = env.shell.run('sys/apps/shell.lua ' .. cmd)
if not s then
return 1, m
end
return 0
end
os.tmpname = function()
local fname
repeat
fname = 'tmp/a' .. math.random(1, 32768)
until not fs.exists(fname)
return fname
end
-- non-standard - will raise error instead
os.exit = function(code)
error('Terminated with ' .. code)
end