home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / sys / stat / mkdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-31  |  972 b   |  47 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <libc/stubs.h>
  3. #include <errno.h>
  4. #include <sys/stat.h>
  5. #include <go32.h>
  6. #include <dpmi.h>
  7. #include <unistd.h>
  8. #include <fcntl.h>
  9. #include <libc/dosio.h>
  10.  
  11. int
  12. mkdir(const char *dirname, mode_t mode)
  13. {
  14.   __dpmi_regs r;
  15.   int use_lfn = _USE_LFN;
  16.  
  17.   _put_path(dirname);
  18.  
  19.   if(use_lfn)
  20.     r.x.ax = 0x7139;
  21.   else
  22.     r.h.ah = 0x39;
  23.   r.x.ds = __tb_segment;
  24.   r.x.dx = __tb_offset;
  25.   __dpmi_int(0x21, &r);
  26.  
  27.   if (r.x.flags & 1)
  28.   {
  29.     errno = __doserr_to_errno(r.x.ax);
  30.     if (errno == EACCES)
  31.     {
  32.       /* see if the directory existed, in which case
  33.      we should return EEXIST - DJ */
  34.       if (access(dirname, D_OK) == 0)
  35.     errno = EEXIST;
  36.     }
  37.     return -1;
  38.   }
  39.  
  40.   /* DOS ignores directory permissions, and mkdir is stub'd,
  41.      so rather than stub chmod also, just skip it.   DJ */
  42. /*  if (chmod(dirname, mode))
  43.     return -1; */
  44.   return 0;
  45. }
  46.  
  47.