FAT | RFS | XFS | ZFS
readdir_fopen()
PROTOTYPE
#include <posix.h>
struct dirent *readdir_fopen(DIR *dirp, const char *mode, void **fcbp);
DESCRIPTION
readdir_fopen() is a non-standard routine that combines the behavior of readdir() and fopen(). It is an optimization since the name lookup otherwise required by fopen() on the dirent structure’s d_name entry is omitted.
The readdir_fopen() dirp parameter and return value are the same as for readdir(). The mode parameter is the same as for fopen() and the *fcbp output is the same as fopen()’s return value. See the readdir() and fopen() pages for information on those.
EXAMPLE
/*-------------------------------------------------------------------*/
/* Read all of every file in the current directory. */
/*-------------------------------------------------------------------*/
dir = opendir(".");
if (dir == NULL)
error("opendir() failed");
while (readdir_fopen(dir, "r", &file))
{
do
rc = fread(Buf, 1, BUF_SIZE, file);
while (rc == BUF_SIZE);
if (fclose(file))
error("fclose() error");
}
closedir(dir);