--- Calls the index function of all available controllers
-function createindex_plain(path, suffix)
- local cache = nil
-
- local controllers = luci.util.combine(
- luci.fs.glob(path .. "*" .. suffix) or {},
- luci.fs.glob(path .. "*/*" .. suffix) or {}
- )
-
- if indexcache then
- cache = luci.fs.mtime(indexcache)
-
- if not cache then
- luci.fs.mkdir(indexcache)
- luci.fs.chmod(indexcache, "a=,u=rwx")
- cache = luci.fs.mtime(indexcache)
- end
- end
-
- for i,c in ipairs(controllers) do
- local module = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".")
- local cachefile = indexcache .. "/" .. module
- local stime
- local ctime
-
- if cache then
- stime = luci.fs.mtime(c) or 0
- ctime = luci.fs.mtime(cachefile) or 0
- end
-
- if not cache or stime > ctime then
- stat, mod = pcall(require, module)
-
- if stat and mod and type(mod.index) == "function" then
- index[module] = mod.index
-
- if cache then
- luci.fs.writefile(cachefile, luci.util.dump(mod.index))
- end
- end
- else
- index[module] = loadfile(cachefile)
- end
- end