home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / CHDRIVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.0 KB  |  71 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - _chdrive.cas
  3.  *
  4.  * function(s)
  5.  *        _chdrive   - change the current working drive
  6.  *        _getrive   - get the current working drive
  7.  *--------------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1990, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <dos.h>
  19.  
  20. /*--------------------------------------------------------------------------*
  21.  
  22. Name            _chdrive - sets current drive
  23.  
  24. Usage           int _chdrive(int drive);
  25.  
  26. Prototype in    dir.h
  27.  
  28. Description     sets the current drive.
  29.                 1 = A:, 2 = B:, 3 = C:; etc.
  30.  
  31. Return value    0 if drive changed successfully, -1 if error.
  32.  
  33. Note            Compatible with MSC. Not the same as setdisk().
  34. *---------------------------------------------------------------------------*/
  35.  
  36. int _chdrive(int drive)
  37. {
  38.     int newdrive;
  39.  
  40.     _dos_setdrive((unsigned)drive,(unsigned *)&newdrive); /* set the drive */
  41.     _dos_getdrive((unsigned *)&newdrive);       /* get current drive */
  42.     if (newdrive == drive)                      /* success? */
  43.         return 0;
  44.     else
  45.         return -1;              /* error, disk didn't change for some reason */
  46. }
  47.  
  48. /*--------------------------------------------------------------------------*
  49.  
  50. Name            _getdrive - sets current drive
  51.  
  52. Usage           int _getdrive(int drive);
  53.  
  54. Prototype in    dir.h
  55.  
  56. Description     sets the current drive.
  57.                 1 = A:, 2 = B:, 3 = C:; etc.
  58.  
  59. Return value    0 if drive changed successfully, -1 if error.
  60.  
  61. Note            Compatible with MSC. Not the same as setdisk().
  62. *---------------------------------------------------------------------------*/
  63.  
  64. int _getdrive()
  65. {
  66.     int newdrive;
  67.  
  68.     _dos_getdrive((unsigned *)&newdrive);       /* get current drive */
  69.     return (newdrive);
  70. }
  71.