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

  1. /*---------------------------------------------------------------------------
  2.  * filename - getdisk.c
  3.  *
  4.  * function(s)
  5.  *        getdisk - gets current drive
  6.  *        setdisk - sets current drive
  7.  *--------------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <dos.h>
  19.  
  20. /*--------------------------------------------------------------------------*
  21.  
  22. Name            getdisk - gets current drive
  23.  
  24. Usage           int getdisk(void);
  25.  
  26. Prototype in    dir.h
  27.  
  28. Description     gets the current drive.
  29.  
  30. Return value    0 = A:, 1 = B:, 2 = C:; etc.
  31.  
  32. *---------------------------------------------------------------------------*/
  33. int getdisk(void)
  34. {
  35.     unsigned drive;
  36.  
  37.     _dos_getdrive(&drive);
  38.     return ((int)drive - 1);
  39. }
  40.  
  41. /*--------------------------------------------------------------------------*
  42.  
  43. Name            setdisk - sets current drive
  44.  
  45. Usage           int setdisk(int drive);
  46.  
  47. Prototype in    dir.h
  48.  
  49. Description     sets the current drive.
  50.                 0 = A:, 1 = B:, 2 = C:; etc.
  51.  
  52. Return value    the total number of drives available.
  53.  
  54. *---------------------------------------------------------------------------*/
  55. int setdisk(int drive)
  56. {
  57.     unsigned ndrives;
  58.  
  59.     _dos_setdrive(drive+1,&ndrives);
  60.     return ((int)ndrives);
  61. }
  62.