home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / CHMODA.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.7 KB  |  69 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - chmoda.cas
  3.  *
  4.  * function(s)
  5.  *        _chmod - changes access mode of file
  6.  *--------------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <asmrules.h>
  19.  
  20. #define  __IN_CHMOD
  21.  
  22. #include <io.h>
  23. #include <_io.h>
  24. #include <stdarg.h>
  25.  
  26.  
  27. /*--------------------------------------------------------------------------*
  28.  
  29. Name            _chmod - changes access mode of file
  30.  
  31. Usage           int _chmod(const char *filename, int func [,int attrib]);
  32.  
  33. Prototype in    io.h
  34.  
  35. Description     may either fetch or set the MS-DOS file attributes.
  36.                 If func is 0, the function returns the current MS-
  37.                 DOS attributes for the file.  If func is 1, the
  38.                 attribute is set to attrib.
  39.  
  40. Return value    success : returns the file attribute word
  41.                 failure : -1 and errno is set to either
  42.  
  43.                         ENOENT  Path or file name not found
  44.                         EACCESS Permission denied
  45.  
  46. *---------------------------------------------------------------------------*/
  47. int _FARFUNC _chmod( pathname, func, attrib )
  48. const char *pathname;
  49. int func, attrib;
  50. {
  51.         pushDS_
  52. asm     mov     cx,attrib
  53. asm     mov     ah,43h
  54. asm     mov     al,func
  55. asm     LDS_    dx, pathname
  56. asm     int     21h
  57.         popDS_
  58. asm     jc      _chmodFailed
  59. asm     xchg    ax,cx
  60.         return(_AX);
  61.  
  62. /*
  63.         error detected call __IOerror
  64. */
  65.  
  66. _chmodFailed:
  67.         return __IOerror (_AX);
  68. }
  69.