diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-03-06 15:57:09 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-03-06 15:57:09 +0100 |
commit | 4ec0856ccdbd5bf6e110467d4623b52566b0e37d (patch) | |
tree | 8a7a1c9897870ae2cadcb8a1bee9697819222803 /tex/context/base/mkiv/l-file.lua | |
parent | 2d50de713c23ec150dab395dcbce69b854db2d58 (diff) | |
download | context-4ec0856ccdbd5bf6e110467d4623b52566b0e37d.tar.gz |
2018-03-06 15:07:00
Diffstat (limited to 'tex/context/base/mkiv/l-file.lua')
-rw-r--r-- | tex/context/base/mkiv/l-file.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/l-file.lua b/tex/context/base/mkiv/l-file.lua index c04883d8b..5fec0040f 100644 --- a/tex/context/base/mkiv/l-file.lua +++ b/tex/context/base/mkiv/l-file.lua @@ -703,3 +703,25 @@ 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 + |