diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2014-07-26 12:58:22 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2014-07-26 12:58:22 +0200 |
commit | 8f36023f13e4c443ca697a491d1919a6c11a3ead (patch) | |
tree | c19a1fef71d8265f41ee73b0ebe551dadbe645d1 /lualibs-file.lua | |
parent | cc7cbd37b22131aa81a58be88da43ad15ea18436 (diff) | |
parent | 48944f8f4c0ca1f3f7d59ce911a689a7777197ee (diff) | |
download | lualibs-8f36023f13e4c443ca697a491d1919a6c11a3ead.tar.gz |
Merge pull request #25 from phi-gamma/master
prepare release
Diffstat (limited to 'lualibs-file.lua')
-rw-r--r-- | lualibs-file.lua | 17 |
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 |