File system
File system readdir_r
// INCLUDE
#include <dirent.h>
// PROTOTYPE
int readdir_r(DIR* pdir, struct dirent* dentry, struct dirent** out_dirent)
Reads the next entry from a directory. Used to find the names of all of the files and directories within a directory. See also readdir
.
dirp
: TheDIR*
returned byopendir
.dentry
: Pass in a pointer to astruct dirent
to be filled in with the current directory entry.out_dirent
: If notNULL
, filled in withdentry
if a directory entry was retrieved, orNULL
if at the end of the directory.
Not all fields of dentry
are filled in. You should only rely on:
d_type
: Type of entry:DT_REG
: FileDT_DIR
: Directory
d_name
: Name of the file or directory. Just the name, not the whole path.
Returns 0 on success. On error, returns -1 and sets errno
.