1if not modules then modules = { } end modules ['file-ini'] = {
2 version = 1.001,
3 comment = "companion to file-ini.mkvi",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9
13
14
15local implement = interfaces.implement
16local setmacro = interfaces.setmacro
17local setcount = interfaces.setcount
18
19resolvers.jobs = resolvers.jobs or { }
20
21local filenametotable = file.nametotable
22local findtexfile = resolvers.findtexfile
23
24local commands_doifelse = commands.doifelse
25
26local function splitfilename(full)
27 local split = filenametotable(full)
28 local path = split.path
29 setcount("splitoffkind",(path == "" and 0) or (path == '.' and 1) or 2)
30 setmacro("splitofffull",full or "")
31 setmacro("splitoffpath",path or "")
32 setmacro("splitoffname",split.name or "")
33 setmacro("splitoffbase",split.base or "")
34 setmacro("splitofftype",split.suffix or "")
35end
36
37local function isparentfile(name)
38 return
39 name == environment.jobname
40 or name == environment.jobname .. '.tex'
41 or name == environment.outputfilename
42end
43
44local function istexfile(name)
45 local name = name and findtexfile(name)
46 return name ~= "" and name
47end
48
49implement { name = "splitfilename", actions = splitfilename, arguments = "string" }
50implement { name = "doifelseparentfile", actions = { isparentfile, commands_doifelse }, arguments = "string" }
51implement { name = "doifelsepathexist", actions = { lfs.isdir, commands_doifelse }, arguments = "string" }
52implement { name = "doifelsefileexist", actions = { istexfile, commands_doifelse }, arguments = "string" }
53 |