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 direntto be filled in with the current directory entry.out_dirent: If notNULL, filled in withdentryif a directory entry was retrieved, orNULLif 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.