home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / STVI369G.ZIP / ISFAT.C < prev    next >
C/C++ Source or Header  |  1991-10-08  |  1KB  |  67 lines

  1. /* ISFAT.C
  2.  *
  3.  * Autor:    Kai Uwe Rommel
  4.  * Datum:    Sun 28-Oct-1990
  5.  *
  6.  * Compiler: MS C ab 6.00
  7.  * System:   OS/2 ab 1.2
  8.  */
  9.  
  10. #define LABEL    "isfat.c"
  11. #define VERSION  "1.0"
  12.  
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18.  
  19. #define INCL_NOPM
  20. #include <os2.h>
  21.  
  22.  
  23. int IsFileSystemFAT(char *dir)
  24. {
  25.   USHORT nDrive;
  26.   ULONG lMap;
  27.   BYTE bData[64], bName[3];
  28.   USHORT cbData;
  29.   static USHORT nLastDrive = -1, nResult;
  30.  
  31.   if ( _osmode == DOS_MODE )
  32.     return TRUE;
  33.   else
  34.   {
  35.     /* We separate FAT and HPFS+other file systems here.
  36.        At the moment I consider other systems to be similar to HPFS,
  37.        i.e., support long file names and being case sensitive */
  38.  
  39.     if ( isalpha(dir[0]) && (dir[1] == ':') )
  40.       nDrive = toupper(dir[0]) - '@';
  41.     else
  42.       DosQCurDisk(&nDrive, &lMap);
  43.  
  44.     if ( nDrive == nLastDrive )
  45.       return nResult;
  46.  
  47.     bName[0] = (char) (nDrive + '@');
  48.     bName[1] = ':';
  49.     bName[2] = 0;
  50.  
  51.     nLastDrive = nDrive;
  52.     cbData = sizeof(bData);
  53.  
  54.     if ( !DosQFSAttach(bName, 0U, 1U, bData, &cbData, 0L) )
  55.       nResult = !strcmp(bData + (*(USHORT *) (bData + 2) + 7), "FAT");
  56.     else
  57.       nResult = FALSE;
  58.  
  59.     /* End of this ugly code */
  60.     return nResult;
  61.   }
  62. }
  63.  
  64.  
  65.  
  66. /* End of ISFAT.C */
  67.