Path: utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: question on opendir, readdir, etc. Message-ID: <14611@smoke.brl.mil> Date: 29 Nov 90 20:38:43 GMT References: <4767@rossignol.Princeton.EDU> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 32 In article <4767@rossignol.Princeton.EDU> tr@samadams.princeton.edu (Tom Reingold) writes: >To use opendir, readdir, etc. on BSD, you include . 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. >To use these functions on System V, you include . 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. You can also obtain my current implementation simply by requesting it in an e-mail message to me .