|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T o
Length: 838 (0x346) Types: TextFile Names: »opendir.c«
└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89 └─⟦this⟧ »./DVIware/laser-setters/umd-dvi/libcompat/opendir.c«
/* opendir -- C library extension routine last edit: 09-Jul-1983 D A Gwyn */ #include <dir.h> #include <sys/types.h> #include <sys/stat.h> #ifdef BRL #define open _open /* avoid emulation */ #endif extern char *malloc(); extern int open(), close(), fstat(); #define NULL 0 DIR * opendir( filename ) char *filename; /* name of directory */ { register DIR *dirp; /* -> malloc'ed storage */ register int fd; /* file descriptor for read */ struct stat sbuf; /* result of fstat() */ if ( (fd = open( filename, 0 )) < 0 ) return NULL; if ( fstat( fd, &sbuf ) < 0 || (sbuf.st_mode & S_IFMT) != S_IFDIR || (dirp = (DIR *)malloc( sizeof(DIR) )) == NULL ) { (void)close( fd ); return NULL; /* bad luck today */ } dirp->dd_fd = fd; dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ return dirp; }