seekdir() — Set position of directory stream

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _XOPEN_SOURCE
#include <dirent.h>

void seekdir(DIR *dirp, long int loc);

General description

The seekdir() function sets the position of the next readdir() operation on the directory stream specified by dirp to the position specified by loc. The value of loc should have been returned from an earlier call to telldir(). The new position reverts to the one associated with the directory stream when telldir() was performed. If the value of loc was not obtained from an earlier call to telldir() or if a call to rewinddir() occurred between the call to telldir() and the call to seekdir(), the result of subsequent calls to readdir() are unspecified.

Note: If files were added or removed from the directory after telldir() was called and before seekdir() is done, the results are also unspecified.

Returned value

seekdir() returns no values.

If the loc argument is negative, the directory stream is unchanged.

Related information