*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: directory | Section: 3 | Source: UNIX v10 | File: directory.3
DIRECTORY(3) Library Functions Manual DIRECTORY(3) NAME opendir, readdir, telldir, seekdir, closedir - directory operations SYNOPSIS #include <sys/types.h> #include <ndir.h> DIR *opendir(filename) char *filename; struct direct *readdir(dirp) DIR *dirp; long telldir(dirp) DIR *dirp; seekdir(dirp, loc) DIR *dirp; long loc; closedir(dirp) DIR *dirp; DESCRIPTION Opendir opens the directory named by filename and associates a `direc- tory stream' with it. Opendir returns a pointer to be used to identify the directory stream in subsequent operations. The pointer value 0 is returned if filename cannot be accessed or is not a directory. Readdir returns a pointer to the next directory entry. It returns 0 upon reaching the end of the directory or detecting an invalid seekdir operation. Telldir returns the current location associated with the named direc- tory stream. Seekdir sets the position of the next readdir operation on the direc- tory stream. The new position reverts to the one associated with the directory stream when the telldir operation was performed. Values re- turned by telldir are good only for the lifetime of the DIR pointer from which they are derived. Closedir causes the named directory stream to be closed, and the struc- ture associated with the DIR pointer to be freed. struct direct { u_long d_ino; inode for the entry short d_reclen; don't use short d_namlen; equivalent to strlen(d_name) char d_name[MAXNAMLEN+1]; null-terminated entry name }; The preferred way to search the current directory is: DIR *dirp; dirp = opendir("."); for(dp = readdir(dirp); dp != 0; dp = readdir(dir)) if(strcmp(dp->d_name, name) == 0) break; closedir(dirp); /* found name if dp != 0 */ SEE ALSO dir(5), open(2), dirread(2), read(2), lseek(2), ftw(3) BUGS The return values point to static data whose content is overwritten by each call. DIRECTORY(3)

Navigation Options