diff options
author | Steven Barth <steven@midlink.org> | 2009-07-24 17:33:32 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-07-24 17:33:32 +0000 |
commit | 2164bdf6518261391097be96b2d873c078977434 (patch) | |
tree | 0b7a8d68e98ff62dc09c6948d67cacaf278eea76 | |
parent | 2655871d397d70eabe10cc45fb822d6e44923499 (diff) |
luci.fs compat
-rw-r--r-- | libs/core/luasrc/fs.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libs/core/luasrc/fs.lua b/libs/core/luasrc/fs.lua index f98f6e605..e2e3abae2 100644 --- a/libs/core/luasrc/fs.lua +++ b/libs/core/luasrc/fs.lua @@ -176,6 +176,15 @@ end -- @return Number containing the os specific errno on error rmdir = fs.rmdir +local stat_tr = { + reg = "regular", + dir = "directory", + lnk = "link", + chr = "character device", + blk = "block device", + fifo = "fifo", + sock = "socket" +} --- Get information about given file or directory. -- @class function -- @name stat @@ -183,7 +192,14 @@ rmdir = fs.rmdir -- @return Table containing file or directory properties or nil on error -- @return String containing the error description on error -- @return Number containing the os specific errno on error -stat = fs.stat +function stat(...) + local data, code, msg = fs.stat(...) + if data then + data.mode = data.modestr + data.type = stat_tr[data.type] or "?" + end + return data, code, msg +end --- Set permissions on given file or directory. -- @class function |