#146 OPEN READ returns READY: for a directory under linux


I am running Regina 3.2 under linux.
stream('mydir', 'c', 'open read') returns READY: if
'mydir' is an existing directory, which is not the
desired result. Also, lines('mydir') returns 1.

Here is an example:

/* mydir is an existing directory */
say stream('mydir', 'c', 'open read')
say 'lines:' lines('mydir')

Result under linux:

lines: 1

Result under windows:

lines: 0

I suppose regina should behave in this case as it does
under windows. I also tested Regina 3.3 RC1 under linux
and found the same behaviour.

Thanks for your help!

Steffen Häcker


  • Mark Hessling

    Mark Hessling - 2004-03-14

    Logged In: YES

    An interesting bug report :-) Regina behaves exactly the
    same as Object Rexx under Linux; READY: from 'OPEN READ' and
    1 from LINES(), but I can see your issue in that the normal
    expectation from an 'OPEN READ' would be to read lines from
    the stream, but a directory won't return lines from it
    unless one treated the actual directory entries as lines.
    I'll talk to Florian about this, but my feeling is that the
    Windows behaviour is more intuitive.

  • Mark Hessling

    Mark Hessling - 2004-03-14
    • assigned_to: nobody --> rexx
  • Florian Grosse-Coosmann

    Logged In: YES

    I think an OPEN shall return with success if it
    is possible. The AREXX package or GCI may be
    used to get the file handle for further interesting

    On the other hand, ANSI A.5.8 states
    " A balance has to be made between leaving too much of I/O
    undefined and defining I/O in a way that cannot be
    reasonably implemented on some file systems. This standard
    provides a 'safety valve' for implementation by specifying
    the required behavior of successful operations. An
    implementation that was unable to achieve the required
    behavior could raise an error when the relevant operations
    were attempted. Another 'safety valve' is provided by
    Config_Stream_Command, which allows for implementation
    defined I/O operations."

    I interpret this as a forbid to implement my preferred answer.

    LINES() must return 0 in either case following ANSI.

    Mark, maybe the st_mode field of a stat buffer should be
    examined for a regular file, a pipe or a char device?

    Cheers, Florian


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks