1: /*
   2:  * static char sccsid[] = "@(#)opendir.c 4.3 8/4/82";
   3:  */
   4: 
   5: #include <sys/types.h>
   6: #include <sys/stat.h>
   7: #include <ndir.h>
   8: 
   9: /*
  10:  * open a directory.
  11:  */
  12: DIR *
  13: opendir(name)
  14:     char *name;
  15: {
  16:     register DIR *dirp;
  17:     register int fd;
  18:     struct stat sbuf;
  19: 
  20:     if ((fd = open(name, 0)) == -1)
  21:         return NULL;
  22:     fstat(fd, &sbuf);
  23:     if (((sbuf.st_mode & S_IFDIR) == 0) ||
  24:         ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL)) {
  25:         close (fd);
  26:         return NULL;
  27:     }
  28:     dirp->dd_fd = fd;
  29:     dirp->dd_loc = 0;
  30:     return dirp;
  31: }

Defined functions

opendir defined in line 12; used 1 times
Last modified: 1983-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 681
Valid CSS Valid XHTML 1.0 Strict