From 1c6c6d62ca665f9d1126b6bad849f7fd584b6a80 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sat, 29 Mar 2008 18:22:21 +0000 Subject: * Replaced luafilesystem with luaposix library * Introduced privilege dropping capability * Automatically drop privileges for "public" to "nobody/nogroup" (as defined in ffluci.uci) --- src/ffluci/fs.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/ffluci/fs.lua') diff --git a/src/ffluci/fs.lua b/src/ffluci/fs.lua index fdea1b51ec..1896122798 100644 --- a/src/ffluci/fs.lua +++ b/src/ffluci/fs.lua @@ -26,7 +26,7 @@ limitations under the License. module("ffluci.fs", package.seeall) -require("lfs") +require("posix") -- Checks whether a file exists function isfile(filename) @@ -80,26 +80,28 @@ end -- Returns the file modification date/time of "path" function mtime(path) - return lfs.attributes(path, "modification") + return posix.stat(path, "mtime") end --- Simplified dirname function -function dirname(file) - return string.gsub(file, "[^/]+$", "") +-- basename wrapper +function basename(path) + return posix.basename(path) +end + +-- dirname wrapper +function dirname(path) + return posix.dirname(path) end -- Diriterator - alias for lfs.dir - filter . and .. function dir(path) - local e = {} - for entry in lfs.dir(path) do - if not(entry == "." or entry == "..") then - table.insert(e, entry) - end - end + local e = posix.dir(path) + table.remove(e, 1) + table.remove(e, 1) return e end -- Alias for lfs.mkdir function mkdir(...) - return lfs.mkdir(...) + return posix.mkdir(...) end \ No newline at end of file -- cgit v1.2.3