This section describes how to open a directory stream. All the symbols are declared in the header file `dirent.h'.
DIR data type represents a directory stream.
You shouldn't ever allocate objects of the struct dirent or
DIR data types, since the directory access functions do that for
you. Instead, you refer to these objects using the pointers returned by
the following functions.
opendir function opens and returns a directory stream for
reading the directory whose file name is dirname. The stream has
type DIR *.
If unsuccessful, opendir returns a null pointer. In addition to
the usual file name errors (see section File Name Errors), the
following errno error conditions are defined for this function:
EACCES
dirname.
EMFILE
ENFILE
The DIR type is typically implemented using a file descriptor,
and the opendir function in terms of the open function.
See section Low-Level Input/Output. Directory streams and the underlying
file descriptors are closed on exec (see section Executing a File).
Go to the first, previous, next, last section, table of contents.