COHERENT manpages
This page displays the COHERENT manpage for readdir() [Read a directory stream].
List of available manpages
Index
readdir() -- General Function (libc) Read a directory stream #include <sys/types.h> #include <dirent.h> struct dirent *readdir(dirp) DIR *dirp; The COHERENT function readdir() is one of a set of COHERENT routines that manipulate directories in a device-independent manner. It reads the directory stream pointed to by dirp and returns information about the next active entry within the stream. It does not report on inactive entries. readdir() returns a pointer to a structure of type dirent, which contains information about the next active entry within the stream. The internal structure may be overwritten by another operation on the same directory stream. The amount of memory needed to hold a copy of the internal structure is given by the value of a macro, DIRENTSIZ(strlen(direntp- >d_name)), not by sizeof(struct dirent) as one might expect. readdir() returns NULL if it has reached the end of the directory, has detected an invalid location within the directory, or if an error occurs while it is reading the directory. If an error occurs, readdir() exits and sets errno to an appropriate value. Example For an example of this function, see the Lexicon entry for opendir(). See Also closedir(), dirent.h, getdents(), libc, opendir(), rewinddir(), seekdir(), telldir() POSIX Standard, §5.1.2 Notes The dirent routines buffer directories; and because directory entries can appear and disappear as other users manipulate the directory, your application should continually rescan a directory to keep an accurate picture of its active entries. The COHERENT implementation of the dirent routines was written by D. Gwynn.