question on opendir, readdir, etc.
Tom Reingold
tr at samadams.princeton.edu
Fri Nov 30 09:01:35 AEST 1990
In article <14611 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn)
writes:
$ In article <4767 at rossignol.Princeton.EDU> tr at samadams.princeton.edu
$ (Tom Reingold) writes:
$ >To use opendir, readdir, etc. on BSD, you include <sys/dir.h>. This
$ >lets you use a struct defined as direct. The member d_name is a
$ >character array of size MAXNAMLEN+1 (256).
$
$ That is obsolete.
Which is obsolete? <sys/ndir.h>?
$ >To use these functions on System V, you include <dirent.h>. This lets
$ >you use a struct defined as dirent. Confusingly close. The member
$ >d_name is a character array of size 1! Is this for real? I have a
$ >sample program which works, but I think I'm lucky that trashing the
$ >area after my structure doesn't kill anything vital.
$
$ UNIX System (as of release 3.0) included IEEE Std 1003.1 (POSIX)-
$ compatible directory access functions and the corresponding header.
$ The code actually originated with my independent implementation;
$ Kirk McKusick of UCB had earlier provided an implementation of the
$ BSD "struct direct" flavor of these functions, which inspired the
$ POSIX specification. There were good reasons for the slight changes
$ made by IEEE P1003, which I won't go into here.
$
$ >Am I not supposed to use these functions in System V? If I am, do they
$ >normally work?
$
$ Yes, they had BETTER work. The [1] kludge is deliberate, and from
$ time to time argument rages about whether the C standard requires that
$ an implementation make it work or whether it could ever fail. I have
$ yet to hear of any commercial UNIX implementation where it doesn't
$ work.
How can it work? And why was this kludge put there?
$ You can also obtain my current implementation simply by requesting it
$ in an e-mail message to me <Gwyn at BRL.MIL>.
I have it already, thank you. Now I know I should use it.
Is this POSIX standard found in System V Release 4?
--
Tom Reingold
tr at samadams.princeton.edu OR ...!princeton!samadams!tr
"Warning: Do not drive with Auto-Shade in place. Remove
from windshield before starting ignition."
More information about the Comp.lang.c
mailing list