home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ISRAMDSK.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  57 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  isRamDsk() - Determine if a drive is a RAM disk
  5. **
  6. **  Call with drive letter ('a' - 'z', 'A' - 'Z')
  7. **
  8. **  Returns True_, False_, or Error_
  9. **
  10. **  Uses ABSDISKC.C, ABSDISK.ASM, and DOS5BOOT.H from SNIPPETS
  11. **  (Note: The relevant parts of the structure in DOS5BOOT.H are
  12. **   also applicable to lower version numbers of DOS)
  13. **
  14. **  Public domain by Bob Stout
  15. */
  16.  
  17. #include <stdlib.h>
  18. #include <ctype.h>
  19. #include <dos.h>
  20. #include "dos5boot.h"
  21. #include "dosfiles.h"
  22. #include "snpdskio.h"
  23.  
  24. Boolean_T isRamDsk(unsigned char drive)
  25. {
  26.       union REGS regs;
  27.       B_REC buffer;
  28.  
  29.       regs.x.ax = 0x4408;           /* Not if removable     */
  30.       regs.h.bl = (unsigned)toupper(drive) - (unsigned char)'@';
  31.       intdos(®s, ®s);
  32.       if (0 == regs.x.ax)
  33.             return False_;
  34.       if (AbsDiskRead(toupper(drive) - 'A', 1, 0, &buffer))
  35.             return Error_;
  36.       return (1 == buffer.bsFATs);
  37.  
  38. #ifdef TEST
  39.  
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42.  
  43. int main(int argc, char *argv[])
  44. {
  45.       if (2 > argc)
  46.       {
  47.             puts("Syntax: ISRAMDSK drive_letter");
  48.             return EXIT_FAILURE;
  49.       }
  50.       printf("Drive %c: is%s a RAM drive\n", toupper(*argv[1]),
  51.             isRamDsk(*argv[1]) ? "" : " not");
  52.       return EXIT_SUCCESS;
  53. }
  54.  
  55. #endif /* TEST */
  56.