summaryrefslogtreecommitdiff
path: root/tex/context/base/l-dir.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-02-09 18:00:12 +0200
committerMarius <mariausol@gmail.com>2011-02-09 18:00:12 +0200
commit9273ab2ccc41973a34fbde3c7667beec8021f2eb (patch)
tree1885d69505b9f40d9a3f7e54c8445a44977cec4c /tex/context/base/l-dir.lua
parented637df24cc8435fc78d30bc08c89f7db60b39c9 (diff)
downloadcontext-9273ab2ccc41973a34fbde3c7667beec8021f2eb.tar.gz
beta 2011.02.09 16:42
Diffstat (limited to 'tex/context/base/l-dir.lua')
-rw-r--r--tex/context/base/l-dir.lua27
1 files changed, 19 insertions, 8 deletions
diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua
index 2c4ff999b..40b94782b 100644
--- a/tex/context/base/l-dir.lua
+++ b/tex/context/base/l-dir.lua
@@ -58,21 +58,32 @@ end
--~ end
--~ end
+local lfsisdir = isdir
+
+local function isdir(path)
+ path = gsub(path,"[/\\]+$","")
+ return lfsisdir(path)
+end
+
+lfs.isdir = isdir
+
local function globpattern(path,patt,recurse,action)
if path == "/" then
path = path .. "."
elseif not find(path,"/$") then
path = path .. '/'
end
- for name in walkdir(path) do
- local full = path .. name
- local mode = attributes(full,'mode')
- if mode == 'file' then
- if find(full,patt) then
- action(full)
+ if isdir(path) then -- lfs.isdir does not like trailing /
+ for name in walkdir(path) do -- lfs.dir accepts trailing /
+ local full = path .. name
+ local mode = attributes(full,'mode')
+ if mode == 'file' then
+ if find(full,patt) then
+ action(full)
+ end
+ elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
+ globpattern(full,patt,recurse,action)
end
- elseif recurse and (mode == "directory") and (name ~= '.') and (name ~= "..") then
- globpattern(full,patt,recurse,action)
end
end
end