Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (n - r) readdir_r(3)
NAME
readdir_r - Reads a directory stream (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
32-bit H-series and J-series OSS processes that do not use Standard POSIX Threads: |
/G/system/zdllnnn/zossfdll
64-bit H-series and J-series OSS processes that do not use Standard POSIX Threads: |
/G/system/zdllnnn/yossfdll
H-series and J-series OSS processes that use the Standard POSIX Threads Library:
/G/system/zdllnnn/zsptdll
(See NOTES)
SYNOPSIS
[#include <sys/types.h>]
#include <dirent.h>
[#include <spthread.h>] /* Required if using Standard POSIX Threads Library */
int readdir_r(
DIR *dirp,
struct dirent *ret,
struct dirent **result);
PARAMETERS
dirp Points to the dirent structure of an open directory.
ret Points to the directory entry at the current position in the directory stream.
result Points to the struct dirent structure where the returned directory entry is stored.
DESCRIPTION
The readdir_r( ) function is the reentrant version of the readdir( ) function.
The type DIR, which is defined in the dirent.h header file, represents a directory stream. A
directory stream is an ordered sequence of all the directory entries in a particular directory.
(Directory streams are not implemented through file descriptors.) The structure pointed to by the
dirp parameter is established by a prior call to the opendir( ) function.
The readdir_r( ) function initializes the dirent structure referenced by the ret parameter to
represent the directory entry at the current position in the directory stream referred to by the dirp
parameter, stores a pointer to this structure at the location referenced by the result parameter, and
positions the directory stream at the next entry.
The storage pointed to by ret is large enough for a dirent with an array of char d_name
member containing at least NAME_MAX plus one element.
Upon successful return, the pointer returned at *result has the same value as the value passed by
ret. Upon reaching the end of the directory stream, this pointer has the value NULL.
The readdir_r( ) function does not return directory entries containing empty names. It is
unspecified whether entries are returned for the . (dot) or .. (dot-dot) directories.
If a file is removed from or added to the directory after the most recent call to the opendir( ) or
rewinddir( ) function, it is unspecified whether a subsequent call to readdir_r( ) returns an entry
for that file.
The readdir_r( ) function might buffer several directory entries per actual read operation; the
readdir_r( ) function marks for update the st_atime field of the directory each time the directory
is actually read. Applications that need to check for error situations should set errno to 0 (zero)
before calling readdir( ).Iferrno is set to a nonzero value on return, an error occurs.
527187-017 Hewlett-Packard Company 5147