diff options
author | Hans Hagen <pragma@wxs.nl> | 2013-04-19 16:29:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2013-04-19 16:29:00 +0200 |
commit | 7b107268d43038815d72037d28dbb3a3e4331d64 (patch) | |
tree | ab683af201b7baeeaf557f3bd829792a9c4e019a /tex/context/base/l-dir.lua | |
parent | b5f4e5df1fd7d3a868e190fc1df83b82a140e8d9 (diff) | |
download | context-7b107268d43038815d72037d28dbb3a3e4331d64.tar.gz |
beta 2013.04.19 16:29
Diffstat (limited to 'tex/context/base/l-dir.lua')
-rw-r--r-- | tex/context/base/l-dir.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua index 00cda3899..3d0576eeb 100644 --- a/tex/context/base/l-dir.lua +++ b/tex/context/base/l-dir.lua @@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['l-dir'] = { local type, select = type, select local find, gmatch, match, gsub = string.find, string.gmatch, string.match, string.gsub -local concat, insert, remove = table.concat, table.insert, table.remove +local concat, insert, remove, unpack = table.concat, table.insert, table.remove, table.unpack local lpegmatch = lpeg.match local P, S, R, C, Cc, Cs, Ct, Cv, V = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cv, lpeg.V @@ -447,3 +447,24 @@ function dir.pop() end return d end + +local function found(...) -- can have nil entries + for i=1,select("#",...) do + local path = select(i,...) + local kind = type(path) + if kind == "string" then + if isdir(path) then + return path + end + elseif kind == "table" then + -- here we asume no holes, i.e. an indexed table + local path = found(unpack(path)) + if path then + return path + end + end + end + -- return nil -- if we want print("crappath") to show something +end + +dir.found = found |