diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-26 20:50:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-26 20:50:34 +0000 |
commit | 78334b0d4607b242273f9d0cde94f6a6fba51832 (patch) | |
tree | 5b604ee30bb611eeeae95ed4218b4e7fd6eb00b8 /Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua | |
parent | 3a0140d05a7e481750ec23a30ed5cf3cdef61eb7 (diff) |
luaotfload (26sep18)
git-svn-id: svn://tug.org/texlive/trunk@48771 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua index f2a27ad1832..46b6847d331 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-file.lua @@ -69,31 +69,34 @@ local lpegmatch = lpeg.match local getcurrentdir, attributes = lfs.currentdir, lfs.attributes local checkedsplit = string.checkedsplit --- local patterns = file.patterns or { } --- file.patterns = patterns - local P, R, S, C, Cs, Cp, Cc, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Cp, lpeg.Cc, lpeg.Ct -- better this way: -local tricky = S("/\\") * P(-1) +----- tricky = S("/\\") * P(-1) local attributes = lfs.attributes -if sandbox then - sandbox.redefine(lfs.isfile,"lfs.isfile") - sandbox.redefine(lfs.isdir, "lfs.isdir") -end - function lfs.isdir(name) - if lpegmatch(tricky,name) then - return attributes(name,"mode") == "directory" - else - return attributes(name.."/.","mode") == "directory" - end + -- if not lpegmatch(tricky,name) then + -- name = name .. "/." + -- end + return attributes(name,"mode") == "directory" end function lfs.isfile(name) - return attributes(name,"mode") == "file" + local a = attributes(name,"mode") + return a == "file" or a == "link" or nil +end + +function lfs.isfound(name) + local a = attributes(name,"mode") + return (a == "file" or a == "link") and name or nil +end + +if sandbox then + sandbox.redefine(lfs.isfile,"lfs.isfile") + sandbox.redefine(lfs.isdir, "lfs.isdir") + sandbox.redefine(lfs.isfound, "lfs.isfound") end local colon = P(":") @@ -699,3 +702,32 @@ function lfs.mkdirs(path) lfs.mkdir(full) end end + +-- here is oen i ran into when messign around with xavante code (keppler project) +-- where it's called in_base .. no gain in using lpeg here + +function file.withinbase(path) -- don't go beyond root + local l = 0 + if not find(path,"^/") then + path = "/" .. path + end + for dir in gmatch(path,"/([^/]+)") do + if dir == ".." then + l = l - 1 + elseif dir ~= "." then + l = l + 1 + end + if l < 0 then + return false + end + end + return true +end + +-- not used in context but was in luatex once: + +local symlinkattributes = lfs.symlinkattributes + +function lfs.readlink(name) + return symlinkattributes(name,"target") or nil +end |