![]() |
![]() |
![]() |
Get information about the next matching filename
#include <sys/types.h> #include <dirent.h> int readdir_r( DIR * dirp, struct dirent * entry, struct direct ** result );
libc
If _POSIX_THREAD_SAFE_FUNCTIONS is defined, readdir_r() initializes the dirent structure referenced by entry with the directory entry at the current position in the directory stream referred to by dirp, and stores a pointer to this structure in result.
The storage pointed by entry must be large enough for a dirent structure with the s_name member an array of char containing at least NAME_MAX plus one element.
![]() |
The struct dirent structure doesn't include space for the pathname.
You must provide it:
struct dirent *entry; entry = malloc( sizeof(*entry) + NAME_MAX + 1 ); |
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
closedir(), errno, opendir(), readdir(), rewinddir()
![]() |
![]() |
![]() |