diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/file-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/file-ini.lua | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/context/base/file-ini.lua b/Master/texmf-dist/tex/context/base/file-ini.lua index 3314bb33dfb..2a0271a9d80 100644 --- a/Master/texmf-dist/tex/context/base/file-ini.lua +++ b/Master/texmf-dist/tex/context/base/file-ini.lua @@ -11,29 +11,42 @@ if not modules then modules = { } end modules ['file-ini'] = { <l n='tex'/>. These methods have counterparts at the <l n='tex'/> end.</p> --ldx]]-- + +local implement = interfaces.implement +local setmacro = interfaces.setmacro +local setcount = interfaces.setcount + resolvers.jobs = resolvers.jobs or { } -local texsetcount = tex.setcount +local filenametotable = file.nametotable +local findtexfile = resolvers.findtexfile -local context_setvalue = context.setvalue local commands_doifelse = commands.doifelse -function commands.splitfilename(fullname) - local t = file.nametotable(fullname) - local path = t.path - texsetcount("splitoffkind",(path == "" and 0) or (path == '.' and 1) or 2) - context_setvalue("splitofffull",fullname) - context_setvalue("splitoffpath",path) - context_setvalue("splitoffname",t.name) - context_setvalue("splitoffbase",t.base) - context_setvalue("splitofftype",t.suffix) +local function splitfilename(full) + local split = filenametotable(full) + local path = split.path + setcount("splitoffkind",(path == "" and 0) or (path == '.' and 1) or 2) + setmacro("splitofffull",full or "") + setmacro("splitoffpath",path or "") + setmacro("splitoffname",split.name or "") + setmacro("splitoffbase",split.base or "") + setmacro("splitofftype",split.suffix or "") end -function commands.doifparentfileelse(n) - commands_doifelse(n == environment.jobname or n == environment.jobname .. '.tex' or n == environment.outputfilename) +local function isparentfile(name) + return + name == environment.jobname + or name == environment.jobname .. '.tex' + or name == environment.outputfilename end -function commands.doiffileexistelse(name) - local foundname = resolvers.findtexfile(name) - commands_doifelse(foundname and foundname ~= "") +local function istexfile(name) + local name = name and findtexfile(name) + return name ~= "" and name end + +implement { name = "splitfilename", actions = splitfilename, arguments = "string" } +implement { name = "doifelseparentfile", actions = { isparentfile, commands_doifelse }, arguments = "string" } +implement { name = "doifelsepathexist", actions = { lfs.isdir, commands_doifelse }, arguments = "string" } +implement { name = "doifelsefileexist", actions = { istexfile, commands_doifelse }, arguments = "string" } |