summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-12-19 12:08:51 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-12-19 12:08:51 +0000
commit0c3f77a3971699382d86fd1016aae7dcd0205f91 (patch)
tree40e5df0ea839bc8ccbfe012d9e4b2d322cb61810
parent4ab5b4165a00cfd26366cf85c6d040bbae23311a (diff)
libs/core: implement fs.isdirectory()
-rw-r--r--libs/core/luasrc/fs.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/libs/core/luasrc/fs.lua b/libs/core/luasrc/fs.lua
index abea5b5e8..830536cbe 100644
--- a/libs/core/luasrc/fs.lua
+++ b/libs/core/luasrc/fs.lua
@@ -54,12 +54,19 @@ access = posix.access
glob = posix.glob
--- Checks wheather the given path exists and points to a regular file.
--- @param filename String containing the path of the file to read
+-- @param filename String containing the path of the file to test
-- @return Boolean indicating wheather given path points to regular file
function isfile(filename)
return posix.stat(filename, "type") == "regular"
end
+--- Checks wheather the given path exists and points to a directory.
+-- @param dirname String containing the path of the directory to test
+-- @return Boolean indicating wheather given path points to directory
+function isdirectory(dirname)
+ return posix.stat(dirname, "type") == "directory"
+end
+
--- Read the whole content of the given file into memory.
-- @param filename String containing the path of the file to read
-- @return String containing the file contents or nil on error