diff options
Diffstat (limited to 'acf')
-rw-r--r-- | acf/loader.lua | 4 | ||||
-rw-r--r-- | acf/model/aaa.lua | 2 | ||||
-rw-r--r-- | acf/modules/awall.lua | 2 | ||||
-rw-r--r-- | acf/persistence/backends/files.lua | 14 | ||||
-rw-r--r-- | acf/persistence/backends/json.lua | 8 |
5 files changed, 15 insertions, 15 deletions
diff --git a/acf/loader.lua b/acf/loader.lua index d66403a..ba28245 100644 --- a/acf/loader.lua +++ b/acf/loader.lua @@ -6,13 +6,13 @@ See LICENSE file for license details module(..., package.seeall) local pth = require('acf.path') -require 'lfs' +require 'posix' require 'stringy' function loadmods(subdir) local comps = pth.split('acf/'..subdir) local res = {} - for modfile in lfs.dir(pth.mjoin(unpack(comps))) do + for _, modfile in ipairs(posix.dir(pth.mjoin(unpack(comps)))) do if stringy.endswith(modfile, '.lua') then local name = string.sub(modfile, 1, -5) res[name] = require(table.concat(comps, '.')..'.'..name) diff --git a/acf/model/aaa.lua b/acf/model/aaa.lua index 93f07dc..f503ea8 100644 --- a/acf/model/aaa.lua +++ b/acf/model/aaa.lua @@ -46,7 +46,7 @@ Authentication.permissions = M.Set{ M.register( 'auth', - '/json'..require('lfs').currentdir()..'/config/aaa.json', + '/json'..require('posix').getcwd()..'/config/aaa.json', Authentication ) diff --git a/acf/modules/awall.lua b/acf/modules/awall.lua index fa120c6..2fb912f 100644 --- a/acf/modules/awall.lua +++ b/acf/modules/awall.lua @@ -123,7 +123,7 @@ AWall['no-track'] = M.Collection{type=Rule} AWall.ipset = M.Collection{type=IPSet} M.register('awall', - '/json'..require('lfs').currentdir()..'/config/awall.json', + '/json'..require('posix').getcwd()..'/config/awall.json', AWall) M.permission.defaults('/awall') diff --git a/acf/persistence/backends/files.lua b/acf/persistence/backends/files.lua index bc9c111..31058a7 100644 --- a/acf/persistence/backends/files.lua +++ b/acf/persistence/backends/files.lua @@ -8,7 +8,7 @@ module(..., package.seeall) local pth = require('acf.path') local util = require('acf.persistence.util') -require 'lfs' +require 'posix' backend = require('acf.object').class() @@ -20,15 +20,15 @@ function backend:get(path) local name = pth.mjoin('/', unpack(path)) if not self.cache[name] then - local attrs = lfs.attributes(name) - if not attrs then return end + local t = posix.stat(name, 'type') + if not t then return end - if attrs.mode == 'file' then + if t == 'regular' then self.cache[name] = util.read_file(name) - elseif attrs.mode == 'directory' then + elseif t == 'directory' then local res = {} - for fname in lfs.dir(name) do + for _, fname in ipairs(posix.dir(name)) do if not ({['.']=true, ['..']=true})[fname] then table.insert(res, fname) end @@ -55,7 +55,7 @@ function backend:set(mods) print('DEL', name) elseif t == 'table' then - lfs.mkdir(name) + assert(posix.mkdir(name)) else local file = util.open_file(name, 'w') diff --git a/acf/persistence/backends/json.lua b/acf/persistence/backends/json.lua index 299cf72..1ac977e 100644 --- a/acf/persistence/backends/json.lua +++ b/acf/persistence/backends/json.lua @@ -11,7 +11,7 @@ local util = require('acf.persistence.util') local copy = require('acf.util').copy require 'json' -require 'lfs' +require 'posix' backend = require('acf.object').class() @@ -40,12 +40,12 @@ function backend:split_path(path) fpath = pth.mjoin(fpath, jpath[1]) table.remove(jpath, 1) - local attrs = lfs.attributes(fpath) - if not attrs or not ({directory=true, file=true})[attrs.mode] then + local t = posix.stat(fpath, 'type') + if not t or not ({directory=true, regular=true})[t] then error('File or directory does not exist: '..fpath) end - if attrs.mode == 'file' then return fpath, jpath end + if t == 'regular' then return fpath, jpath end assert(#jpath > 0) end |