remove preferred apps/alternates - same can be accomplished using aliases
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
local Array = require('opus.array')
|
||||
local Config = require('opus.config')
|
||||
local Util = require('opus.util')
|
||||
|
||||
local function getConfig()
|
||||
return Config.load('alternate', {
|
||||
shell = {
|
||||
'sys/apps/shell.lua',
|
||||
'rom/programs/shell.lua',
|
||||
},
|
||||
lua = {
|
||||
'sys/apps/Lua.lua',
|
||||
'rom/programs/lua.lua',
|
||||
},
|
||||
files = {
|
||||
'sys/apps/Files.lua',
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
local Alt = { }
|
||||
|
||||
function Alt.get(key)
|
||||
return getConfig()[key][1]
|
||||
end
|
||||
|
||||
function Alt.set(key, value)
|
||||
local config = getConfig()
|
||||
Array.removeByValue(config[key], value)
|
||||
table.insert(config[key], 1, value)
|
||||
Config.update('alternate', config)
|
||||
end
|
||||
|
||||
function Alt.remove(key, value)
|
||||
local config = getConfig()
|
||||
Array.removeByValue(config[key], value)
|
||||
Config.update('alternate', config)
|
||||
end
|
||||
|
||||
function Alt.add(key, value)
|
||||
local config = getConfig()
|
||||
if not Util.contains(config[key], value) then
|
||||
table.insert(config[key], value)
|
||||
Config.update('alternate', config)
|
||||
end
|
||||
end
|
||||
|
||||
return Alt
|
||||
@@ -79,10 +79,40 @@ function ramfs.list(node, dir)
|
||||
end
|
||||
|
||||
function ramfs.open(node, fn, fl)
|
||||
if fl ~= 'r' and fl ~= 'w' and fl ~= 'rb' and fl ~= 'wb' then
|
||||
local modes = Util.transpose { 'r', 'w', 'rb', 'wb', 'a' }
|
||||
if not modes[fl] then
|
||||
error('Unsupported mode')
|
||||
end
|
||||
|
||||
if fl == 'a' then
|
||||
if node.mountPoint ~= fn then
|
||||
fl = 'w'
|
||||
else
|
||||
local c = type(node.contents) == 'table'
|
||||
and string.char(table.unpack(node.contents))
|
||||
or node.contents
|
||||
or ''
|
||||
|
||||
return {
|
||||
write = function(str)
|
||||
c = c .. str
|
||||
end,
|
||||
writeLine = function(str)
|
||||
c = c .. str .. '\n'
|
||||
end,
|
||||
flush = function()
|
||||
node.contents = c
|
||||
node.size = #c
|
||||
end,
|
||||
close = function()
|
||||
node.contents = c
|
||||
node.size = #c
|
||||
c = nil
|
||||
end,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
if fl == 'r' then
|
||||
if node.mountPoint ~= fn then
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user