summaryrefslogtreecommitdiff
path: root/lualibs-file.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-07-26 12:46:53 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2014-07-26 12:46:53 +0200
commitf60e809b87c6d9b0ea87ceeb54507d486f2934eb (patch)
tree9fa52ea13b5e05d2c4a8ce8c81ada454bbf7c470 /lualibs-file.lua
parentcdd478fce0ba30e0a2f7af7604b05bb34e392a88 (diff)
downloadlualibs-f60e809b87c6d9b0ea87ceeb54507d486f2934eb.tar.gz
sync with Context as of 2014-07-26
Diffstat (limited to 'lualibs-file.lua')
-rw-r--r--lualibs-file.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lualibs-file.lua b/lualibs-file.lua
index ebb2b39..c05372a 100644
--- a/lualibs-file.lua
+++ b/lualibs-file.lua
@@ -495,6 +495,23 @@ function file.collapsepath(str,anchor) -- anchor: false|nil, true, "."
end
end
+-- better this way:
+
+local tricky = S("/\\") * P(-1)
+local attributes = lfs.attributes
+
+function lfs.isdir(name)
+ if lpegmatch(tricky,name) then
+ return attributes(name,"mode") == "directory"
+ else
+ return attributes(name.."/.","mode") == "directory"
+ end
+end
+
+function lfs.isfile(name)
+ return attributes(name,"mode") == "file"
+end
+
-- local function test(str,...)
-- print(string.format("%-20s %-15s %-30s %-20s",str,file.collapsepath(str),file.collapsepath(str,true),file.collapsepath(str,".")))
-- end