summaryrefslogtreecommitdiff
path: root/tex/context/base/l-file.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2014-07-25 12:57:00 +0200
committerHans Hagen <pragma@wxs.nl>2014-07-25 12:57:00 +0200
commit552aceb88e5e5e77a9263144180139a6ac95646c (patch)
tree33053ce46dd12e14505d457f42f29486f16890eb /tex/context/base/l-file.lua
parente80c75029084c0e8a80286f78150b5a2e320e63c (diff)
downloadcontext-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.lua17
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