diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-04-26 16:07:10 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-04-26 16:07:10 +0300 |
commit | 13eb04abbc9d8561e44786ce9b0dd94bc1454e1f (patch) | |
tree | de9e355d35daaad565803c76f107c9617c79ed7b /acf/persistence | |
parent | aa778f7cbe0285056516b15044037309f9ec95e7 (diff) | |
download | aconf-13eb04abbc9d8561e44786ce9b0dd94bc1454e1f.tar.bz2 aconf-13eb04abbc9d8561e44786ce9b0dd94bc1454e1f.tar.xz |
substitute lua-posix for lua-filesystem
Diffstat (limited to 'acf/persistence')
-rw-r--r-- | acf/persistence/backends/files.lua | 14 | ||||
-rw-r--r-- | acf/persistence/backends/json.lua | 8 |
2 files changed, 11 insertions, 11 deletions
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 |