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

  1. /*---------------------------------------------------------------------------
  2.  * filename - chdir.cas
  3.  *
  4.  * function(s)
  5.  *        chdir   - changes working directory
  6.  *        getdisk - gets current drive
  7.  *        setdisk - sets current drive
  8.  *--------------------------------------------------------------------------*/
  9.  
  10. /*[]------------------------------------------------------------[]*/
  11. /*|                                                              |*/
  12. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  13. /*|                                                              |*/
  14. /*|                                                              |*/
  15. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  16. /*|     All Rights Reserved.                                     |*/
  17. /*|                                                              |*/
  18. /*[]------------------------------------------------------------[]*/
  19.  
  20. #pragma inline
  21. #include <asmrules.h>
  22. #include <dir.h>
  23. #include <_io.h>
  24.  
  25. /*--------------------------------------------------------------------------*
  26.  
  27. Name        chdir - changes working directory
  28.  
  29. Usage        int chdir(const char *path);
  30.  
  31. Prototype in    dir.h
  32.  
  33. Description    causes the directory specified by path to become the
  34.         current working directory.
  35.  
  36. Return value    success : 0
  37.                 failure : -1 and errno is set to ENOENT (Path or file
  38.                 name not found)
  39.  
  40. *---------------------------------------------------------------------------*/
  41. int chdir(const char *pathP)
  42. {
  43.     pushDS_
  44. asm    mov    ah, 03Bh
  45. asm    LDS_    dx, pathP
  46. asm    int    021H
  47.     popDS_
  48. asm    jc    chdirFailed
  49.  
  50.     return(0);
  51.  
  52. chdirFailed:
  53.     return __IOerror(_AX);
  54. }
  55.  
  56. /*--------------------------------------------------------------------------*
  57.  
  58. Name        getdisk - gets current drive
  59.  
  60. Usage        int getdisk(void);
  61.  
  62. Prototype in    dir.h
  63.  
  64. Description    gets the current drive.
  65.  
  66. Return value    0 = A:, 1 = B:, 2 = C:; etc.
  67.  
  68. *---------------------------------------------------------------------------*/
  69. int getdisk(void)
  70. {
  71. asm    mov    ah, 019h
  72. asm    int    021h
  73. asm     cbw
  74.  
  75.     return _AX;
  76. }
  77.  
  78. /*--------------------------------------------------------------------------*
  79.  
  80. Name        setdisk - sets current drive
  81.  
  82. Usage        int setdisk(int drive);
  83.  
  84. Prototype in    dir.h
  85.  
  86. Description    sets the current drive.
  87.         0 = A:, 1 = B:, 2 = C:; etc.
  88.  
  89. Return value    the total number of drives available.
  90.  
  91. *---------------------------------------------------------------------------*/
  92. int setdisk(int drive)
  93. {
  94. asm    mov    ah, 00Eh
  95. asm    mov    dl, drive
  96. asm    int    021h
  97. asm     cbw
  98.  
  99.     return _AX;
  100. }
  101.