Next: Scanning Directory Content, Previous: Simple Directory Lister, Up: Accessing Directories
This section describes how to reread parts of a directory that you have already read from an open directory stream. All the symbols are declared in the header file dirent.h.
The
rewinddirfunction is used to reinitialize the directory stream dirstream, so that if you callreaddirit returns information about the first entry in the directory again. This function also notices if files have been added or removed to the directory since it was opened withopendir. (Entries for these files might or might not be returned byreaddirif they were added or removed since you last calledopendirorrewinddir.)
The
telldirfunction returns the file position of the directory stream dirstream. You can use this value withseekdirto restore the directory stream to that position.
The
seekdirfunction sets the file position of the directory stream dirstream to pos. The value pos must be the result of a previous call totelldiron this particular stream; closing and reopening the directory can invalidate values returned bytelldir.