|
|
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 ] | |
|
| |