2 telldir -- report directory stream position
4 last edit: 25-Apr-1987 D A Gwyn
6 NOTE: 4.nBSD directory compaction makes seekdir() & telldir()
7 practically impossible to do right. Avoid using them!
11 #include <sys/errno.h>
12 #include <sys/types.h>
15 extern off_t _lseek(int d, int offset, int whence);
22 telldir(register DIR *dirp) /* return offset of next entry */
24 if ( dirp == NULL || dirp->dd_buf == NULL )
27 return -1; /* invalid pointer */
30 if ( dirp->dd_loc < dirp->dd_size ) /* valid index */
31 return ((struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off;
32 else /* beginning of next directory block */
33 return _lseek( dirp->dd_fd, (off_t)0, SEEK_CUR );