Open a directory for listing its contents.
Syntax
#include <dirent.h>
DIR *opendir (const char *pathname);
Parameters
-
pathname
The path name of the directory to open.
Return Value
The return value is a pointer to a DIR structure if successful. Otherwise, the return value is null and errno is set:
-
ENOMEM
Out of memory.
-
ENOMEM
No free file descriptors.
-
ENOENT
No such file or directory.
Remarks
The returned DIR structure is globally allocated in order to not rely on
malloc
and free
. This implies that the implementation is not thread safe,
and it is not possible to access more than one directory at the same time from
within the same process.