Saving Position Within a Directory

It is possible to use the function telldir(3) to save a position within a directory. The function synopsis is as follows:

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

long telldir(const DIR *dirp);

Given the input pointer dirp, which points to an open DIR structure returned by opendir(3), this function returns an offset into the directory for later use by seekdir(3). The offset returned is greater than or equal to zero if it is successful. A -1L value is returned if it fails, and the error code is found in errno.

Note

Some UNIX platforms may have a slightly different type definition for telldir(3). For example, SGI's IRIX 6.5 defines its telldir(3) as follows:

off_t telldir (DIR *dirp);

Note that the returned offset is type off_t, and that the input argument lacks the keyword const.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.82.23