summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/file-ini.lua
diff options
context:
space:
mode:
authorMojca Miklavec <mojca.miklavec@gmail.com>2012-05-14 17:38:55 +0000
committerMojca Miklavec <mojca.miklavec@gmail.com>2012-05-14 17:38:55 +0000
commit15995e10bfc68edf79970c4ea4fbb6678566c46e (patch)
tree2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/file-ini.lua
parentc9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff)
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/file-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/file-ini.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/file-ini.lua b/Master/texmf-dist/tex/context/base/file-ini.lua
new file mode 100644
index 00000000000..4f8b5b6e345
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/file-ini.lua
@@ -0,0 +1,38 @@
+if not modules then modules = { } end modules ['file-ini'] = {
+ version = 1.001,
+ comment = "companion to file-ini.mkvi",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+--[[ldx--
+<p>It's more convenient to manipulate filenames (paths) in
+<l n='lua'/> than in <l n='tex'/>. These methods have counterparts
+at the <l n='tex'/> side.</p>
+--ldx]]--
+
+resolvers.jobs = resolvers.jobs or { }
+
+local texcount = tex.count
+local setvalue = context.setvalue
+
+function commands.splitfilename(fullname)
+ local t = file.nametotable(fullname)
+ local path = t.path
+ texcount.splitoffkind = (path == "" and 0) or (path == '.' and 1) or 2
+ setvalue("splitofffull",fullname)
+ setvalue("splitoffpath",path)
+ setvalue("splitoffname",t.name)
+ setvalue("splitoffbase",t.base)
+ setvalue("splitofftype",t.suffix)
+end
+
+function commands.doifparentfileelse(n)
+ commands.doifelse(n == environment.jobname or n == environment.jobname .. '.tex' or n == environment.outputfilename)
+end
+
+function commands.doiffileexistelse(name)
+ local foundname = resolvers.findtexfile(name)
+ commands.doifelse(foundname and foundname ~= "")
+end