diff options
Diffstat (limited to 'rrdtool-model.lua')
-rw-r--r-- | rrdtool-model.lua | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/rrdtool-model.lua b/rrdtool-model.lua index 2b9344a..2acc464 100644 --- a/rrdtool-model.lua +++ b/rrdtool-model.lua @@ -20,25 +20,6 @@ local path="PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " -- ################################################################################ -- LOCAL FUNCTIONS --- Function to recursively insert all filenames in a dir into an array -local function recursedir(path, filearray) - filearray = filearray or {} - local k,v - for k,v in pairs(posix.dir(path) or {}) do - -- Ignore files that begins with a '.' - if not string.match(v, "^%.") then - local f = path .. "/" .. v - -- If subfolder exists, list files in this subfolder - if (posix.stat(f).type == "directory") then - recursedir(f, filearray) - else - table.insert(filearray, f) - end - end - end - return filearray -end - local function file_info ( path ) local st = fs.stat(path) local size = st.size or "0" @@ -46,15 +27,10 @@ local function file_info ( path ) return lastmod,size end -local function list_files () +local function list_files (path,search) + local files = fs.find_files_as_array(search, path) + local listed_files = {} - local open_files = {} - local files = {} - local k,v - -- Generate a single table with all the files - for k,v in pairs{databases} do - recursedir(v, files) - end -- Loop through each file and present its info for k,v in pairs(files) do @@ -70,9 +46,8 @@ local function list_files () end - local function validfilename(path) - local files = list_files() + local files = list_files(databases) for k,v in pairs(files.value) do if (v["value"]["filename"]["value"] == path) then return true, tostring(v["value"]["filename"]["value"]) @@ -101,7 +76,7 @@ function setconfigfile(filedetails) end function getrrdlist() - return list_files() + return list_files(databases) end function createnewrrd() |