/* * Return first char of filesystem type, or 0 if unknown. */ static char getFSType(const char *path) { static char cache[1 + 26]; char drive[3], info[512]; Word unit, infolen; char r; if (isalpha(path[0]) && path[1] == ':') { unit = toupper(path[0]) - '@'; path += 2; } else { ULONG driveMap; #if OS2 >= 2 if (DosQueryCurrentDisk(&unit, &driveMap)) #else if (DosQCurDisk(&unit, &driveMap)) #endif return 0; } if ((path[0] == '\\' || path[0] == '/') && (path[1] == '\\' || path[1] == '/')) return 0; if (cache[unit]) return cache[unit]; drive[0] = '@' + unit; drive[1] = ':'; drive[2] = '\0'; infolen = sizeof info; #if OS2 >= 2 if (DosQueryFSAttach(drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen)) return 0; if (infolen >= sizeof(FSQBUFFER2)) { FSQBUFFER2 *p = (FSQBUFFER2 *)info; r = p->szFSDName[p->cbName]; } else #else if (DosQFSAttach((PSZ)drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen, 0)) return 0; if (infolen >= 9) { char *p = info + sizeof(USHORT); p += sizeof(USHORT) + *(USHORT *)p + 1 + sizeof(USHORT); r = *p; } else #endif r = 0; return cache[unit] = r; }
int IsFileSystemFAT(char *dir) { USHORT nDrive; ULONG lMap; BYTE bData[64], bName[3]; USHORT cbData; static USHORT nLastDrive = -1, nResult; if ( _osmode == DOS_MODE ) return TRUE; else { /* We separate FAT and HPFS+other file systems here. at the moment I consider other systems to be similar to HPFS, i.e. support long file names and beeing case sensitive */ if ( isalpha(dir[0]) && (dir[1] == ':') ) nDrive = toupper(dir[0]) - '@'; else DosQCurDisk(&nDrive, &lMap); if ( nDrive == nLastDrive ) return nResult; bName[0] = (char) (nDrive + '@'); bName[1] = ':'; bName[2] = 0; nLastDrive = nDrive; cbData = sizeof(bData); if ( !DosQFSAttach(bName, 0U, 1U, bData, &cbData, 0L) ) nResult = !strcmp(bData + (*(USHORT *) (bData + 2) + 7), "FAT"); else nResult = FALSE; /* End of this ugly code */ return nResult; } }