diff options
author | Steven Barth <steven@midlink.org> | 2008-03-29 18:22:21 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-03-29 18:22:21 +0000 |
commit | 1c6c6d62ca665f9d1126b6bad849f7fd584b6a80 (patch) | |
tree | d0f6d975a17d100a52d158a72904d3cbbf964ab4 /src/ffluci/fs.lua | |
parent | cdb0b2f0bfaa0e0bb40b1b90581e1376f55fb0df (diff) |
* Replaced luafilesystem with luaposix library
* Introduced privilege dropping capability
* Automatically drop privileges for "public" to "nobody/nogroup" (as defined in ffluci.uci)
Diffstat (limited to 'src/ffluci/fs.lua')
-rw-r--r-- | src/ffluci/fs.lua | 26 |
1 files changed, 14 insertions, 12 deletions
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 |