HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

readdir

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Reads entries from an open directory stream.

Syntax

   #include <sys/types.h>

   #include <dirent.h>

   struct dirent *readdir (DIR *dirp);

Parameters

dirp

A pointer to an open directory stream obtained from a successful call to opendir().

Return Values

<>NULL

Success.

NULL

End of directory stream was reached, but errno is not modified.

NULL

An error occurred, and errno is set to indicate the error condition.

Description

The readdir() function returns a pointer to a structure of type dirent representing the directory entry at the current position in the directory stream associated with dirp, then positions the directory stream at the next entry. A NULL pointer is returned upon reaching the end of the directory stream.

Upon successful completion, readdir() marks for update the st_atime time field of the directory.

The pointer returned by readdir() points to data that is overwritten by another call to readdir() on the same directory stream.

Implementation Considerations

Refer to the EFAULT and ESYSERR error descriptions below.

Both the dot and dot dot directory entries are returned only for directories that explicitly contain them. The root directory, MPE/iX accounts, and MPE/iX groups do not contain explicit dot and dot dot entries.

If an entry is removed from or added to the directory after the most recent call to opendir() or rewinddir(), subsequent returns from readdir() accurately reflect the current state of the directory.

Errors

If an error occurs, errno is set to one of the following values:

EBADFCAUSEThe dirp parameter does not refer to an open directory stream.
 ACTIONPass an open directory stream pointer returned by the opendir() function.
EFAULTCAUSEThe system detected a NULL or bad address in attempting to use the dirp parameter.
 ACTIONMake sure that the pointer is correctly initialized.
ESYSERRCAUSEAn operating system error has occurred that does not map directly to any of the above errors.
 ACTIONExamine the MPE/iX error stack for the type of system error.

See Also

mkdir(), closedir(), opendir(), rewinddir(), <dirent.h>, POSIX.1 (Section 5.1.2)

Feedback to webmaster