better fuzzy matching + vfs type flag in Files

This commit is contained in:
kepler155c@gmail.com
2020-05-19 17:09:10 -06:00
parent b93d69c261
commit 985830fcfd
8 changed files with 115 additions and 66 deletions

View File

@@ -6,37 +6,41 @@ 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'
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)
if not cmd then
return env.shell and 1 or 0
end
local env = _G.getfenv(2)
local s, m = env.shell.run('sys/apps/shell.lua ' .. cmd)
if not env.shell then
return 0
end
if not s then
return 1, m
end
local s, m = env.shell.run('sys/apps/shell.lua ' .. cmd)
return 0
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)
local fname
repeat
fname = 'tmp/a' .. math.random(1, 32768)
until not fs.exists(fname)
return fname
return fname
end
-- non-standard - will raise error instead
os.exit = function(code)
error('Terminated with ' .. code)
error('Terminated with ' .. code)
end