|
|
1.1 ! root 1: /* ! 2: telldir -- report directory stream position ! 3: ! 4: last edit: 25-Apr-1987 D A Gwyn ! 5: ! 6: NOTE: 4.nBSD directory compaction makes seekdir() & telldir() ! 7: practically impossible to do right. Avoid using them! ! 8: */ ! 9: ! 10: #include <sys/errno.h> ! 11: #include <sys/types.h> ! 12: #include "usr.dirent.h" ! 13: ! 14: #ifndef GETDENTS ! 15: extern off_t lseek(); ! 16: ! 17: extern int errno; ! 18: ! 19: #ifndef SEEK_CUR ! 20: #define SEEK_CUR 1 ! 21: #endif ! 22: ! 23: off_t ! 24: telldir( dirp ) /* return offset of next entry */ ! 25: DIR *dirp; /* stream from opendir() */ ! 26: { ! 27: if ( dirp == NULL || dirp->dd_buf == NULL ) ! 28: { ! 29: errno = EFAULT; ! 30: return -1; /* invalid pointer */ ! 31: } ! 32: ! 33: if ( dirp->dd_loc < dirp->dd_size ) /* valid index */ ! 34: return ((struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off; ! 35: else /* beginning of next directory block */ ! 36: return lseek( dirp->dd_fd, (off_t)0, SEEK_CUR ); ! 37: } ! 38: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.