diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2017-02-04 13:50:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-04 13:50:34 +0100 |
commit | 42f669beab39df38d2f4955b651541272126a04e (patch) | |
tree | f68d918629725f9306698bf0641910d1f714714b /lualibs-dir.lua | |
parent | 144f6d16fd79bd0496b3ae379b69227e0d9bbfa9 (diff) | |
parent | 1b2f8c0355210dbfd34b10ed4ff7f0c90fda062d (diff) | |
download | lualibs-master.tar.gz |
v2.5
Diffstat (limited to 'lualibs-dir.lua')
-rw-r--r-- | lualibs-dir.lua | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lualibs-dir.lua b/lualibs-dir.lua index 81ac65e..bc691d5 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") @@ -557,9 +587,13 @@ file.expandname = dir.expandname -- for convenience local stack = { } function dir.push(newdir) - insert(stack,currentdir()) + local curdir = currentdir() + insert(stack,curdir) if newdir and newdir ~= "" then chdir(newdir) + return newdir + else + return curdir end end |