directory.3c (2010 09)

d
directory(3C) directory(3C)
DIR *dirp;
struct dirent *dp;
dirp = opendir(".");
while ((dp = readdir(dirp)) != NULL) {
if (strcmp(dp->d_name, name) == 0) {
(void) closedir(dirp);
return FOUND;
}
}
(void) closedir(dirp);
return NOT_FOUND;
WARNINGS
readdir() and getdirentries()
(see getdirentries(2)) are the only ways to access remote NFS
directories. Attempting to read a remote directory via NFS by using
read() returns -1 and sets errno
to [EISDIR] (see read (2)).
If a file is removed from or added to the directory after the most recent call to
opendir() or rewind-
dir(), whether a subsequent call to
readdir() or readdir_r() returns an entry for that file is
unspecified.
For 32-bit applications, the d_ino field of the
dirent struct may overflow for filesystems that use 64-bit
values. In this case the most-significant bytes will be truncated without generating an error and d_ino
values may not be unique.
AUTHOR
directory was developed by AT&T, HP, and the University of California, Berkeley.
SEE ALSO
close(2), getdirentries(2), lseek(2), open(2), read(2), dir(4), dirent(5), thread_safety(5).
STANDARDS CONFORMANCE
closedir(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
opendir(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
readdir(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
readdir_r():POSIX.1c
rewinddir(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
seekdir(): AES, SVID3, XPG2, XPG3, XPG4
telldir(): AES, XPG2, XPG3, XPG4
HP-UX 11i Version 3: September 2010 3 Hewlett-Packard Company 3