home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / dos / compat / d_getfa.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-24  |  837 b   |  41 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. /*
  3.  * D_GETFA.C.
  4.  *
  5.  * Written by Peter Sulyok 1995 <sulyok@math.klte.hu>.
  6.  *
  7.  * This file is distributed WITHOUT ANY WARRANTY; without even the implied
  8.  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9.  *
  10.  */
  11.  
  12. #include <libc/dosio.h>
  13. #include <go32.h>
  14. #include <dpmi.h>
  15. #include <errno.h>
  16. #include <dos.h>
  17.  
  18. unsigned int _dos_getfileattr(const char *filename, unsigned int *p_attr)
  19. {
  20.   __dpmi_regs r;
  21.  
  22.   if (filename == 0 || p_attr == 0)
  23.   {
  24.     errno = EINVAL;
  25.     return -1;
  26.   }
  27.  
  28.   _put_path(filename);
  29.   r.x.ax = 0x4300;
  30.   r.x.dx = __tb & 15;
  31.   r.x.ds = __tb / 16;
  32.   __dpmi_int(0x21, &r);
  33.   if ( r.x.flags & 1 )
  34.   {
  35.     errno = __doserr_to_errno(r.x.ax);
  36.     return r.x.ax;
  37.   }
  38.   *p_attr = r.x.ax;
  39.   return 0;
  40. }
  41.