Chapter Contents

Previous

Next
readdir

readdir



Read Directory Entry

Portability: POSIX.1 conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <sys/types.h>
#include <dirent.h>

struct dirent *readdir(DIR *dir);


DESCRIPTION

readdir returns information about the next directory entry from an HFS directory opened by opendir . The dir function is the value returned by opendir when the directory was opened. readdir uses a single area for return information for each directory. This means that each call to readdir overlays the return information from the previous call for the same directory. Whether or not information is returned for the "." and ".." directory entries is not defined by the POSIX.1 standard. Under USS, these entries are returned.

The dirent structure contains the following:
char *d_name points to a string that names a file in the directory. The string terminates with a null. It has a maximum of NAME_MAX characters.


RETURN VALUE

readdir returns the pointer to a dirent structure that describes the next directory entry. readdir returns a NULL pointer when it reaches the end of the stream. readdir returns a NULL pointer and sets errno if it is not successful.


EXAMPLE

The example for rewinddir illustrates the use of the readdir function.


RELATED FUNCTIONS

opendir


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.