* Added support for first-level controllers
* Added several posix functions to ffluci.fs * Added ffluci.util.combine
This commit is contained in:
parent
f920f79b64
commit
427dd0bd1d
3 changed files with 33 additions and 3 deletions
|
@ -126,8 +126,14 @@ end
|
||||||
function createindex()
|
function createindex()
|
||||||
local root = ffluci.sys.libpath() .. "/controller/"
|
local root = ffluci.sys.libpath() .. "/controller/"
|
||||||
local suff = ".lua"
|
local suff = ".lua"
|
||||||
for i,c in ipairs(ffluci.fs.glob(root .. "*/*" .. suff)) do
|
|
||||||
c = "ffluci.controller." .. c:sub(#root+1, #c-#suff):gsub("/", ".", 1)
|
local controllers = ffluci.util.combine(
|
||||||
|
ffluci.fs.glob(root .. "*" .. suff),
|
||||||
|
ffluci.fs.glob(root .. "*/*" .. suff)
|
||||||
|
)
|
||||||
|
|
||||||
|
for i,c in ipairs(controllers) do
|
||||||
|
c = "ffluci.controller." .. c:sub(#root+1, #c-#suff):gsub("/", ".")
|
||||||
stat, mod = pcall(require, c)
|
stat, mod = pcall(require, c)
|
||||||
|
|
||||||
if stat and mod and type(mod.index) == "function" then
|
if stat and mod and type(mod.index) == "function" then
|
||||||
|
|
|
@ -83,4 +83,16 @@ dir = posix.dir
|
||||||
mkdir = posix.mkdir
|
mkdir = posix.mkdir
|
||||||
|
|
||||||
-- Alias for posix.rmdir
|
-- Alias for posix.rmdir
|
||||||
rmdir = posix.rmdir
|
rmdir = posix.rmdir
|
||||||
|
|
||||||
|
-- Alias for posix.stat
|
||||||
|
stat = posix.stat
|
||||||
|
|
||||||
|
-- Alias for posix.chmod
|
||||||
|
chmod = posix.chmod
|
||||||
|
|
||||||
|
-- Alias for posix.link
|
||||||
|
link = posix.link
|
||||||
|
|
||||||
|
-- Alias for posix.unlink
|
||||||
|
unlink = posix.unlink
|
|
@ -73,6 +73,18 @@ function clone(object, deep)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Combines two or more numerically indexed tables into one
|
||||||
|
function combine(...)
|
||||||
|
local result = {}
|
||||||
|
for i, a in ipairs(arg) do
|
||||||
|
for j, v in ipairs(a) do
|
||||||
|
table.insert(result, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Checks whether a table has an object "value" in it
|
-- Checks whether a table has an object "value" in it
|
||||||
function contains(table, value)
|
function contains(table, value)
|
||||||
for k,v in pairs(table) do
|
for k,v in pairs(table) do
|
||||||
|
|
Loading…
Reference in a new issue