ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Hans van der Meer <havdmeer@ziggo.nl>
Subject: Re: Bug in Luatex file handling?
Date: Tue, 15 Jun 2021 15:37:41 +0200	[thread overview]
Message-ID: <949d9b9c-9390-7d29-279f-6e36b62217e3@xs4all.nl> (raw)
In-Reply-To: <9F0DB6E4-5588-4829-8642-931F14EF472B@ziggo.nl>

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
___________________________________________________________________________________

      reply	other threads:[~2021-06-15 13:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 12:38 Hans van der Meer
2021-06-15 13:37 ` Hans Hagen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=949d9b9c-9390-7d29-279f-6e36b62217e3@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=havdmeer@ziggo.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).