readdir_r(), readdir64_r()

read directory (reentrant) 

Function


SYNOPSIS

#include <sys/types.h>

#include <dirent.h>

int readdir_r(DIR* dirp, struct dirent *entry, struct dirent **result);

int readdir64_r(DIR* dirp, struct dirent *entry, struct dirent64 **result);


DESCRIPTION

The readdir_r() function sets the dirent structure pointed to by entry to the directory entry of the current position in the directory stream referred to by dirp. It stores a pointer to this structure at the location referenced by result, and positions the directory stream at the next entry. On successful return, the pointer returned at *result has the same value as the argument entry. Upon reaching the end of the directory stream, this pointer has the value NULL.

The readdir64_r() function is similar to the readdir_r() function, and is a part of the large file extensions.

An entry for dot (.) and dot-dot (..) is returned.

If a file is removed from the directory after the most recent call to opendir() or rewinddir(), a subsequent call to readdir_r() returns an entry for that file. If a file is added to the directory after the most recent call to opendir() or rewinddir(), a subsequent call to readdir_r() does not return an entry for the added file.

readdir_r() fills all the members of the dirent structure except d_ino which is always set to 0.

entry points to a struct dirent that includes the member d_name. The size of the d_name array is not specified; however, the number of bytes preceding the terminating null character cannot exceed NAME_MAX.

After a call to fork(), both parent and child can independently continue processing the directory stream using readdir_r() or rewinddir() or both. Directory streams are closed after a successful call to exec() and hence execed image cannot use the directory streams opened in the execing process.


PARAMETERS

dirp 

Points to the directory stream to be read.

entry 

Points to the directory entry to be filled.

result 

Points to the directory entry pointer which was returned in entry.


RETURN VALUES

If successful, readdir_r() and readdir64_r() return zero. When the operation encounters the end of a directory, readdir_r() and readdir64_r() return zero and set the result parameter to NULL. If dirp does not refer to an open directory stream, readdir_r() and readdir64_r() return EBADF.

If one of the values in the structure to be returned cannot be represented correctly, readdir_r() and readdir64_r() return EOVERFLOW.


CONFORMANCE

POSIX.1 (1996).

readdir64_r(): Large File Specification, revision 1.5.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
closedir(), opendir(), readdir(), rewinddir(), scandir(), seekdir(), telldir()

Miscellaneous:
lf64


PTC MKS Toolkit 10.5 Documentation Build 40.