From 13eb04abbc9d8561e44786ce9b0dd94bc1454e1f Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Fri, 26 Apr 2013 16:07:10 +0300 Subject: substitute lua-posix for lua-filesystem --- acf/persistence/backends/files.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'acf/persistence/backends/files.lua') 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') -- cgit v1.2.3