home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / CHMODA.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.2 KB  |  70 lines

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