convert luci.fs users to nixio.fs api
[project/luci.git] / modules / admin-full / luasrc / controller / admin / system.lua
index 1aabe63..c90ecc3 100644 (file)
@@ -27,7 +27,7 @@ function index()
        entry({"admin", "system", "processes"}, form("admin_system/processes"), i18n("process_head"), 45)
        entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50)
 
        entry({"admin", "system", "processes"}, form("admin_system/processes"), i18n("process_head"), 45)
        entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50)
 
-       if luci.fs.isdirectory("/sys/class/leds") then
+       if nixio.fs.access("/sys/class/leds") then
                entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60)
        end
 
                entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60)
        end
 
@@ -124,7 +124,7 @@ function action_packages()
         
        -- Remove index cache
        if changes then
         
        -- Remove index cache
        if changes then
-               luci.fs.unlink("/tmp/luci-indexcache")
+               nixio.fs.unlink("/tmp/luci-indexcache")
        end     
 end
 
        end     
 end
 
@@ -214,7 +214,7 @@ function action_upgrade()
        
        local function storage_size()
                local size = 0
        
        local function storage_size()
                local size = 0
-               if luci.fs.access("/proc/mtd") then
+               if nixio.fs.access("/proc/mtd") then
                        for l in io.lines("/proc/mtd") do
                                local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"')
                                if n == "linux" then
                        for l in io.lines("/proc/mtd") do
                                local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"')
                                if n == "linux" then
@@ -222,7 +222,7 @@ function action_upgrade()
                                        break
                                end
                        end
                                        break
                                end
                        end
-               elseif luci.fs.access("/proc/partitions") then
+               elseif nixio.fs.access("/proc/partitions") then
                        for l in io.lines("/proc/partitions") do
                                local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)')
                                if b and n and not n:match('[0-9]') then
                        for l in io.lines("/proc/partitions") do
                                local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)')
                                if b and n and not n:match('[0-9]') then
@@ -239,7 +239,7 @@ function action_upgrade()
        local file
        luci.http.setfilehandler(
                function(meta, chunk, eof)
        local file
        luci.http.setfilehandler(
                function(meta, chunk, eof)
-                       if not luci.fs.access(tmpfile) and not file and chunk and #chunk > 0 then
+                       if not nixio.fs.access(tmpfile) and not file and chunk and #chunk > 0 then
                                file = io.open(tmpfile, "w")
                        end
                        if file and chunk then
                                file = io.open(tmpfile, "w")
                        end
                        if file and chunk then
@@ -255,9 +255,9 @@ function action_upgrade()
        -- Determine state
        local keep_avail   = true
        local step         = tonumber(luci.http.formvalue("step") or 1)
        -- Determine state
        local keep_avail   = true
        local step         = tonumber(luci.http.formvalue("step") or 1)
-       local has_image    = luci.fs.access(tmpfile)
+       local has_image    = nixio.fs.access(tmpfile)
        local has_support  = image_supported()
        local has_support  = image_supported()
-       local has_platform = luci.fs.access("/lib/upgrade/platform.sh")
+       local has_platform = nixio.fs.access("/lib/upgrade/platform.sh")
        local has_upload   = luci.http.formvalue("image")
        
        -- This does the actual flashing which is invoked inside an iframe
        local has_upload   = luci.http.formvalue("image")
        
        -- This does the actual flashing which is invoked inside an iframe
@@ -298,7 +298,7 @@ function action_upgrade()
                -- If there is an image but user has requested step 1
                -- or type is not supported, then remove it.
                if has_image then
                -- If there is an image but user has requested step 1
                -- or type is not supported, then remove it.
                if has_image then
-                       luci.fs.unlink(tmpfile)
+                       nixio.fs.unlink(tmpfile)
                end
                        
                luci.template.render("admin_system/upgrade", {
                end
                        
                luci.template.render("admin_system/upgrade", {
@@ -313,7 +313,7 @@ function action_upgrade()
                luci.template.render("admin_system/upgrade", {
                        step=2,
                        checksum=image_checksum(),
                luci.template.render("admin_system/upgrade", {
                        step=2,
                        checksum=image_checksum(),
-                       filesize=luci.fs.stat(tmpfile).size,
+                       filesize=nixio.fs.stat(tmpfile).size,
                        flashsize=storage_size(),
                        keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
                } )
                        flashsize=storage_size(),
                        keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
                } )
@@ -333,7 +333,7 @@ function _keep_pattern()
        if files then
                kpattern = ""
                for k, v in pairs(files) do
        if files then
                kpattern = ""
                for k, v in pairs(files) do
-                       if k:sub(1,1) ~= "." and luci.fs.glob(v) then
+                       if k:sub(1,1) ~= "." and nixio.fs.glob(v)() then
                                kpattern = kpattern .. " " ..  v
                        end
                end
                                kpattern = kpattern .. " " ..  v
                        end
                end