diff options
author | Hans Hagen <pragma@wxs.nl> | 2014-07-25 12:57:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2014-07-25 12:57:00 +0200 |
commit | 552aceb88e5e5e77a9263144180139a6ac95646c (patch) | |
tree | 33053ce46dd12e14505d457f42f29486f16890eb /tex/context/base/l-file.lua | |
parent | e80c75029084c0e8a80286f78150b5a2e320e63c (diff) | |
download | context-552aceb88e5e5e77a9263144180139a6ac95646c.tar.gz |
beta 2014.07.25 12:57
Diffstat (limited to 'tex/context/base/l-file.lua')
-rw-r--r-- | tex/context/base/l-file.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua index ebb2b39f4..c05372a05 100644 --- a/tex/context/base/l-file.lua +++ b/tex/context/base/l-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 |