#include <sys/types.h> #include <dirent.h> void rewinddir(DIR *dirp);Service Program Name: QP0LLIB1
The rewinddir() function "rewinds" the position of an open directory stream to the beginning. dirp points to a DIR associated with an open directory stream.
The next call to readdir() reads the first entry in the directory. If the contents of the directory have changed since the directory was opened and rewinddir() is called, subsequent calls to readdir() read the changed contents.
No authorization is required. Authorization is verified during opendir().
None.
None.
The following messages may be sent from this function:
Message ID | Error Message Text |
---|---|
CPE3418 E | Possible APAR condition or hardware failure. |
CPF1F05 E | Directory handle not valid. |
CPF3CF2 E | Error(s) occurred during running of &1 API. |
See Code disclaimer information for information pertaining to code examples.
The following example produces the contents of a directory by opening it, rewinding it, and closing it:
#include <sys/types.h> #include <dirent.h> #include <errno.h> #include <stdio.h> main() { DIR *dir; struct dirent *entry; if ((dir = opendir("/")) == NULL) perror("opendir() error"); else { puts("contents of root:"); while ((entry = readdir(dir)) != NULL) printf("%s ", entry->d_name); rewinddir(dir); puts(""); while ((entry = readdir(dir)) != NULL) printf("%s ", entry->d_name); closedir(dir); puts(""); } }
Output:
contents of root: . .. QSYS.LIB QDLS QOpenSys QOPT home . .. QSYS.LIB QDLS QOpenSys QOPT home newdir
Top | UNIX-Type APIs | APIs by category |