summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/l-dir.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-09-06 01:12:18 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-09-06 01:12:18 +0200
commit9db0d829e3ee2c3ab607c3c624adf189b2da15f4 (patch)
tree0d65a3fea48b3ded2a98fb637cd70b0a4b488a28 /tex/context/base/mkiv/l-dir.lua
parent3f59c56887a9a6c4bda68ab8d99e67d2afc902f9 (diff)
downloadcontext-9db0d829e3ee2c3ab607c3c624adf189b2da15f4.tar.gz
2016-09-06 00:33:00
Diffstat (limited to 'tex/context/base/mkiv/l-dir.lua')
-rw-r--r--tex/context/base/mkiv/l-dir.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/l-dir.lua b/tex/context/base/mkiv/l-dir.lua
index 81ac65e50..db4125cd2 100644
--- a/tex/context/base/mkiv/l-dir.lua
+++ b/tex/context/base/mkiv/l-dir.lua
@@ -335,6 +335,36 @@ end
dir.globfiles = globfiles
+local function globdirs(path,recurse,func,files) -- func == pattern or function
+ if type(func) == "string" then
+ local s = func
+ func = function(name) return find(name,s) end
+ end
+ files = files or { }
+ local noffiles = #files
+ for name in walkdir(path) do
+ if find(name,"^%.") then
+ --- skip
+ else
+ local mode = attributes(name,'mode')
+ if mode == "directory" then
+ if not func or func(name) then
+ noffiles = noffiles + 1
+ files[noffiles] = path .. "/" .. name
+ if recurse then
+ globdirs(path .. "/" .. name,recurse,func,files)
+ end
+ end
+ end
+ end
+ end
+ return files
+end
+
+dir.globdirs = globdirs
+
+-- inspect(globdirs("e:/tmp"))
+
-- t = dir.glob("c:/data/develop/context/sources/**/????-*.tex")
-- t = dir.glob("c:/data/develop/tex/texmf/**/*.tex")
-- t = dir.glob("c:/data/develop/context/texmf/**/*.tex")