From 8fcd841aa9af96c8a4a4d3c1a555d2d1ed42332c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 19 Jul 2009 00:24:58 +0000 Subject: convert luci.fs users to nixio.fs api --- libs/cbi/luasrc/cbi.lua | 17 +++++++++-------- libs/cbi/luasrc/view/cbi/filebrowser.htm | 13 +++++++------ libs/cbi/luasrc/view/cbi/upload.htm | 3 ++- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'libs/cbi/luasrc') diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index e513053bab..f3c481cf84 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -30,9 +30,10 @@ require("luci.template") local util = require("luci.util") require("luci.http") require("luci.uvl") -require("luci.fs") + --local event = require "luci.sys.event" +local fs = require("nixio.fs") local uci = require("luci.model.uci") local class = util.class local instanceof = util.instanceof @@ -52,7 +53,7 @@ REMOVE_PREFIX = "cbi.rts." -- Loads a CBI map from given file, creating an environment and returns it function load(cbimap, ...) - require("luci.fs") + local fs = require "nixio.fs" local i18n = require "luci.i18n" require("luci.config") require("luci.util") @@ -60,9 +61,9 @@ function load(cbimap, ...) local upldir = "/lib/uci/upload/" local cbidir = luci.util.libpath() .. "/model/cbi/" - assert(luci.fs.stat(cbimap) or - luci.fs.stat(cbidir..cbimap..".lua") or - luci.fs.stat(cbidir..cbimap..".lua.gz"), + assert(fs.stat(cbimap) or + fs.stat(cbidir..cbimap..".lua") or + fs.stat(cbidir..cbimap..".lua.gz"), "Model not found!") local func, err = loadfile(cbimap) @@ -1703,7 +1704,7 @@ end function FileUpload.cfgvalue(self, section) local val = AbstractValue.cfgvalue(self, section) - if val and luci.fs.access(val) then + if val and fs.access(val) then return val end return nil @@ -1717,7 +1718,7 @@ function FileUpload.formvalue(self, section) then return val end - luci.fs.unlink(val) + fs.unlink(val) self.value = nil end return nil @@ -1725,7 +1726,7 @@ end function FileUpload.remove(self, section) local val = AbstractValue.formvalue(self, section) - if val and luci.fs.access(val) then luci.fs.unlink(val) end + if val and fs.access(val) then fs.unlink(val) end return AbstractValue.remove(self, section) end diff --git a/libs/cbi/luasrc/view/cbi/filebrowser.htm b/libs/cbi/luasrc/view/cbi/filebrowser.htm index 5eda993b67..f82957221c 100644 --- a/libs/cbi/luasrc/view/cbi/filebrowser.htm +++ b/libs/cbi/luasrc/view/cbi/filebrowser.htm @@ -48,7 +48,8 @@ $Id$ <% - require("luci.fs") + require("nixio.fs") + require("nixio.util") require("luci.http") require("luci.dispatcher") @@ -63,7 +64,7 @@ $Id$ end local filepath = table.concat( path, '/' ) - local filestat = luci.fs.stat( filepath ) + local filestat = nixio.fs.stat( filepath ) local baseurl = luci.dispatcher.build_url('admin', 'filebrowser') if filestat and filestat.type == "reg" then @@ -76,7 +77,7 @@ $Id$ filepath = filepath .. '/' end - local entries = luci.fs.dir(filepath) + local entries = nixio.util.consume((nixio.fs.dir(filepath))) -%>
Location: @@ -98,8 +99,8 @@ $Id$
    <% for _, e in luci.util.vspairs(entries) do - local stat = luci.fs.stat(filepath..e) - if e ~= '.' and e ~= '..' and stat and stat.type == 'dir' then + local stat = nixio.fs.stat(filepath..e) + if stat and stat.type == 'dir' then -%>
  • Directory @@ -108,7 +109,7 @@ $Id$ <% end end -%> <% for _, e in luci.util.vspairs(entries) do - local stat = luci.fs.stat(filepath..e) + local stat = nixio.fs.stat(filepath..e) if stat and stat.type ~= 'dir' then -%>
  • diff --git a/libs/cbi/luasrc/view/cbi/upload.htm b/libs/cbi/luasrc/view/cbi/upload.htm index a4ab0c958d..7bde74b482 100644 --- a/libs/cbi/luasrc/view/cbi/upload.htm +++ b/libs/cbi/luasrc/view/cbi/upload.htm @@ -16,10 +16,11 @@ $Id$ <% local t = require("luci.tools.webadmin") local v = self:cfgvalue(section) + v = v and nixio.fs.stat(v) -%> <%+cbi/valueheader%> <% if v then %> - <%:cbi_upload Uploaded File%> (<%=t.byte_format(luci.fs.stat(v, "size") or 0)%>) + <%:cbi_upload Uploaded File%> (<%=t.byte_format(v.size)%>) /> " alt="<%:cbi_replace%>" title="<%:cbi_replace%>" src="<%=resource%>/cbi/reload.gif" /> <% else %> -- cgit v1.2.3