From 349d46eb1e7f1d13f5d823e818216b5ef1cee566 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 15 Sep 2016 08:07:32 +0200 Subject: sync with Context as of 2016-09-15 --- lualibs-dir.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lualibs-dir.lua') 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") -- cgit v1.2.3 From 12d27922f7bb7f466b5d476fa2c1ddc08a300513 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 20 Oct 2016 07:28:32 +0200 Subject: sync with Context as of 2016-10-20 Signed-off-by: Philipp Gesang --- lualibs-dir.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lualibs-dir.lua') diff --git a/lualibs-dir.lua b/lualibs-dir.lua index db4125c..bc691d5 100644 --- a/lualibs-dir.lua +++ b/lualibs-dir.lua @@ -587,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 -- cgit v1.2.3