On 6/15/2021 2:38 PM, Hans van der Meer wrote:
This I cannot explain. Opening a file directly from its full name in a
string succeeds. But doing the same from a parameter transferred from
ConteXt to Lua succeeds if the file is in one directory deeper but fails
if the file is two directories deeper.
I suspect there is something not ok in LuaTeX.
The lines with and directly come from print statements
inserted in the Lua code.
dr. Hans van der Meer
Open file in directory 1 and 2 levels deep - direct call succeeds
..io.open("events/hga-0372-345-62.xml","r")=>file (0x7fff97415f88)
..io.open("events/transcripten/hga-0372-345-62.xml","r")=>file
(0x7fff97416020)
Idem but now from parameter filename transferred from ConTeXt into Lua:
Open file one level deeper succeeds (printed filename comes from the call):
>>io.open(filename,"r")
filename=events/hga-0372-1764-63.xml=>file (0x7fff974160b8)
Open file two levels deeper fails:
>>io.open(filename,"r")
filename=events/transcripten/hga-0372-1764-63.xml=>nil
Caller:
\def\FileExist#1{\cldcontext{hvdm.existfile([===[#1]===])}}
Lua code:
hvdm.existfile = function (filename)
-- The test code was inserted here --
local file = io.open(filename, "r")
if file then
file:close()
end
return file ~= nil and "true" or "false"
end
does lfs.isfile(name) work?
-
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___