summaryrefslogtreecommitdiff
path: root/lualibs-dir.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-09-15 08:07:32 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-09-15 08:07:32 +0200
commit349d46eb1e7f1d13f5d823e818216b5ef1cee566 (patch)
tree6c721f136781389e80392c4e5d3c714bb089afb8 /lualibs-dir.lua
parent8ee68eedb5cbdf06585f6f37bdc361b69437a25d (diff)
downloadlualibs-349d46eb1e7f1d13f5d823e818216b5ef1cee566.tar.gz
sync with Context as of 2016-09-15
Diffstat (limited to 'lualibs-dir.lua')
-rw-r--r--lualibs-dir.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/lualibs-dir.lua b/lualibs-dir.lua
index 81ac65e..db4125c 100644
--- a/lualibs-dir.lua
+++ b/lualibs-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")