you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
$Id$
local util = require("luci.util")
local sys = require("luci.sys")
-local fs = require("luci.fs")
-local uci = require("luci.model.uci").Session()
-local sections = uci:sections( "luci_statistics" )
+local fs = require("nixio.fs")
+local uci = require("luci.model.uci").cursor()
+local sections = uci:get_all("luci_statistics")
Instance = util.class()
return dir
end
+function Instance._ls( self, ... )
+ local ditr = fs.dir(self:_mkpath(...))
+ if ditr then
+ local dirs = { }
+ while true do
+ local d = ditr()
+ if not d then break end
+ dirs[#dirs+1] = d
+ end
+ return dirs
+ end
+end
+
function Instance._notzero( self, table )
for k in pairs(table) do
return true
end
function Instance._scan( self )
- local dir = fs.dir( self._libdir )
- if not dir then
+ local dirs = self:_ls()
+ if not dirs then
return
end
- for i, plugin in ipairs( dir ) do
- if plugin:match("%w+.so") then
- self._plugins[ plugin:gsub(".so", "") ] = { }
+
+-- for i, plugin in ipairs( dirs ) do
+-- if plugin:match("%w+.so") then
+-- self._plugins[ plugin:gsub("%.so$", "") ] = { }
+-- end
+-- end
+
+ for _, dir in ipairs(dirs) do
+ if dir ~= "." and dir ~= ".." and
+ fs.stat(self:_mkpath(dir)).type == "dir"
+ then
+ local plugin = dir:gsub("%-.+$", "")
+ if not self._plugins[plugin] then
+ self._plugins[plugin] = { }
+ end
end
end
for plugin, instances in pairs( self._plugins ) do
- local dirs = fs.dir( self:_mkpath() )
+ local dirs = self:_ls()
if type(dirs) == "table" then
for i, dir in ipairs(dirs) do
for instance, data_instances in pairs( instances ) do
- dirs = fs.dir( self:_mkpath( plugin, instance ) )
+ dirs = self:_ls(plugin, instance)
if type(dirs) == "table" then
for i, file in ipairs(dirs) do