Closes a directory stream.
Syntax |
 |
#include <sys/types.h>
#include <dirent.h>
int closedir (DIR *dirp);
|
Parameters |
 |
- dirp
A pointer to a structure of type DIR representing an open directory stream (returned by a call to opendir()).
Return Values |
 |
- 0
Success. The directory is closed.
- -1
An error occurred. The directory file is not closed, and errno is set to indicate the error condition.
Description |
 |
The closedir() function closes the open directory file pointed to by dirp. The directory stream must be a structure of type DIR (defined in <dirent.h>) returned from a successful call to opendir(), or an error occurs. The file descriptor associated with the DIR structure is also closed.
Implementation Considerations |
 |
Refer to the EFAULT error description below.
The DIR structure is implemented using a file descriptor.
Errors |
 |
If an error occurs, errno is set to one of the following values:
See Also |
 |
opendir(), readdir(), rewinddir(), <dirent.h>, POSIX.1 (Section 5.1.2)