FLTK logo

Re: [fltk/fltk] scandir_posix.c readentry should check for ENOENT (#238)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] scandir_posix.c readentry should check for ENOENT (#238) Albrecht Schlosser Jun 16, 2021  
 

Looking at the GNU implementation of readdir, it seems evident that ENOENT
should be checked for correctness as an EOF condition.

No, Mark, that's not true. Please do not take the ENOENT error condition literally. In the example code you posted (a link to) this is the error code returned by the system (kernel) function getdents() which in this case is turned into an EOF (end of directory) condition for whatever reason (doesn't matter). This is a special case on "some systems" (citation) and has absolutely nothing to do with our case here on DOS.

We do not know why the DOS function readdir() returns ENOENT at the end of the directory. Maybe this is ancient history and has never been changed for backwards compatibility. You can't conclude from the (likely Linux kernel) implementation of getdents() on the result of the DOS function readdir(). The ENOENT errno value of POSIX readdir() is definitely an error condition and not just "end of directory".

The question we need to answer is how we deal with this condition. An easy (pseudo code) solution would be, partly as Greg suggested, using #ifdef MSDOS for the decision:

#ifdef MSDOS /* MSDOS readdir() returns ENOENT on end of directory */
    if ((!errno) || (ENOENT == errno))
#else /* POSIX compliant readdir()
    if (!errno)
#endif

... or something like this ...


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.