home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CLIBSRC2.ZIP / DOSFATTR.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.7 KB  |  99 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - dosfattr.cas
  3.  *
  4.  * function(s)
  5.  *      _dos_getfileattr - get file attributes (MSC compatible)
  6.  *      _dos_setfileattr - change file attributes (MSC compatible)
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1991, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <_io.h>
  21.  
  22. /*--------------------------------------------------------------------------*
  23.  
  24. Name            _dos_getfileattr - get current attributes of file
  25.  
  26. Usage           unsigned _dos_getfileattr(const char *filename,
  27.                          unsigned *attrib);
  28.  
  29. Prototype in    dos.h
  30.  
  31. Description     Fetch the MS-DOS file attributes for filename,
  32.                 store them in low byte of *attrib.
  33.  
  34. Return value    success : 0
  35.                 failure : DOS error code, and errno is set to
  36.  
  37.                         ENOENT  Path or file name not found
  38.  
  39. Note            Compatible with Microsoft C.
  40.  
  41. *---------------------------------------------------------------------------*/
  42.  
  43. unsigned _dos_getfileattr(const char *filename, unsigned *attrib)
  44. {
  45.         pushDS_
  46. asm     mov     ah,43h
  47. asm     xor     al,al
  48. asm     LDS_    dx, filename
  49. asm     int     21h
  50.         popDS_
  51. asm     jc      _getFailed
  52. asm     LES_    bx,attrib
  53. asm     mov     ES_ [bx],cx
  54.         return (0);
  55.  
  56. _getFailed:
  57.         return (__DOSerror(_AX));               /* set errno */
  58. }
  59.  
  60.  
  61. /*--------------------------------------------------------------------------*
  62.  
  63. Name            _dos_setfileattr - set current attributes of file
  64.  
  65. Usage           unsigned _dos_setfileattr(const char *filename,
  66.                          unsigned attrib);
  67.  
  68. Prototype in    dos.h
  69.  
  70. Description     Set the MS-DOS file attributes for filename to
  71.                 the value in the low byte of attrib.
  72.  
  73. Return value    success : 0
  74.                 failure : DOS error code, and errno is set to either
  75.  
  76.                         ENOENT  Path or file name not found
  77.                         EACCESS Permission denied
  78.  
  79. Note            Compatible with Microsoft C.
  80.  
  81. *---------------------------------------------------------------------------*/
  82.  
  83.  
  84. unsigned _dos_setfileattr(const char *filename, unsigned attrib)
  85. {
  86.         pushDS_
  87. asm     mov     ah,43h
  88. asm     mov     al,1
  89. asm     LDS_    dx, filename
  90. asm     mov     cx, attrib
  91. asm     int     21h
  92.         popDS_
  93. asm     jc      _setFailed
  94.         return (0);
  95.  
  96. _setFailed:
  97.         return (__DOSerror(_AX));               /* set errno */
  98. }
  99.