summaryrefslogtreecommitdiff
path: root/tex/context/base/l-dir.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-04-19 17:40:26 +0300
committerMarius <mariausol@gmail.com>2013-04-19 17:40:26 +0300
commitb7e0ad6611d168a628cd644b4c6c7a83788e483a (patch)
tree72c8e0d8fa4899ce271636bfa6da99a3bcf058fa /tex/context/base/l-dir.lua
parent4586560fc032bd763deee980ed5238511be88ba9 (diff)
downloadcontext-b7e0ad6611d168a628cd644b4c6c7a83788e483a.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.lua23
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