HP 3000 Manuals

readdir [ MPE/iX Developer's Kit Reference Manual Volume I ] MPE/iX 5.0 Documentation


MPE/iX Developer's Kit Reference Manual Volume I

readdir 

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:

EBADF             CAUSE           The dirp parameter does not refer to an open
                                  directory stream.
                  ACTION          Pass an open directory stream pointer returned by the
                                  opendir() function.

EFAULT            CAUSE           The system detected a NULL or bad address in
                                  attempting to use the dirp parameter.
                  ACTION          Make sure that the pointer is correctly initialized.

ESYSERR           CAUSE           An operating system error has occurred that does not
                                  map directly to any of the above errors.
                  ACTION          Examine 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)



MPE/iX 5.0 Documentation