Changeset 1444 for trunk/dll/valid.c


Ignore:
Timestamp:
Jul 23, 2009, 1:24:23 AM (16 years ago)
Author:
Gregg Young
Message:

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/valid.c

    r1439 r1444  
    3636  08 Mar 09 GKY Additional strings move to PCSZs
    3737  12 Jul 09 GKY Add xDosQueryAppType and xDoxAlloc... to allow FM/2 to load in high memory
     38  22 Jul 09 GKY Consolidated driveflag setting code in DriveFlagsOne
     39  22 Jul 09 GKY Check if drives support EAs add driveflag for this
     40  22 Jul 09 GKY Add LocalHD driveflag
     41  22 Jul 09 GKY Streamline scanning code for faster Tree rescans
    3842
    3943***********************************************************************/
     
    7983PCSZ RAMFS = "RAMFS";
    8084PCSZ NTFS = "NTFS";
     85PCSZ LAN = "LAN";
    8186BOOL fVerifyOffChecked[26];
    8287
     
    256261INT CheckDrive(CHAR chDrive, CHAR * pszFileSystem, ULONG * pulType)
    257262{
    258   CHAR szPath[3];
     263  CHAR szPath[4];
    259264  VOID *pvBuffer = NULL;
    260265  CHAR *pfsn;
     
    266271  ULONG clDataBytes;
    267272  HFILE hDev;
     273  EASIZEBUF easize = {0};
     274  ULONG   ulDataLen        = sizeof(EASIZEBUF); 
     275  ULONG   ulParmLen        = 0;
    268276
    269277# pragma pack(1)
     
    322330  pfsn = (PCHAR)(pfsq->szName) + pfsq->cbName + 1;
    323331  pfsd = pfsn + pfsq->cbFSDName + 1;
     332  strupr(pfsn);
    324333
    325334  if (pszFileSystem) {
     
    327336    pszFileSystem[CCHMAXPATH - 1] = 0;
    328337  }
    329 
     338  szPath[2] = '\\';
     339  szPath[3] = 0;
     340  DosFSCtl(&easize, sizeof(EASIZEBUF), &ulDataLen, NULL, ulParmLen,
     341           &ulParmLen, FSCTL_MAX_EASIZE, szPath, -1, FSCTL_PATHNAME);
     342  //DbgMsg(pszSrcFile, __LINE__, "%i %i %s %s", easize.cbMaxEASize, easize.cbMaxEAListSize, szPath, pfsn);
     343  szPath[2] = 0;
     344  if (pulType && easize.cbMaxEASize == 0)
     345    *pulType |= DRIVE_NOEASUPPORT;
    330346  if (pulType && (!strcmp(pfsn, CDFS) || !strcmp(pfsn, ISOFS)))
    331       *pulType |= DRIVE_NOTWRITEABLE | DRIVE_CDROM | DRIVE_REMOVABLE;
     347    *pulType |= DRIVE_NOTWRITEABLE | DRIVE_CDROM | DRIVE_REMOVABLE;
    332348  if (pulType && !strcmp(pfsn, NTFS))
    333349    *pulType |= DRIVE_NOTWRITEABLE;
     
    338354        *pulType |= DRIVE_RAMDISK;
    339355    }
    340   if (((PFSQBUFFER2) pvBuffer)->iType == FSAT_REMOTEDRV &&
    341       (strcmp(pfsn, CDFS) || strcmp(pfsn, ISOFS))) {
     356  if (((PFSQBUFFER2) pvBuffer)->iType == FSAT_REMOTEDRV) {
    342357    if (pulType)
    343358      *pulType |= DRIVE_REMOTE;
     
    360375    }
    361376    if (pulType &&
    362         (!strcmp(pfsn, HPFS) ||
    363          !strcmp(pfsn, JFS) ||
    364          !strcmp(pfsn, FAT32) ||
     377        (!strcmp(pfsn, LAN) ||
    365378         !strcmp(pfsn, RAMFS) ||
    366          !strcmp(pfsn, NDFS32) ||
    367          !strcmp(pfsn, NTFS) ||
    368          !strcmp(pfsn, HPFS386))) {
     379         !strcmp(pfsn, NDFS32))) {
    369380      *pulType &= ~DRIVE_NOLONGNAMES;
    370381    }
     
    376387  // Local drive
    377388  if (strcmp(pfsn, HPFS) &&
    378       strcmp(pfsn, JFS) &&
    379389      strcmp(pfsn, CDFS) &&
    380390      strcmp(pfsn, ISOFS) &&
    381       strcmp(pfsn, RAMFS) &&
     391      strcmp(pfsn, JFS) &&
    382392      strcmp(pfsn, FAT32) &&
    383       strcmp(pfsn, NDFS32) &&
    384393      strcmp(pfsn, NTFS) &&
    385394      strcmp(pfsn, HPFS386)) {
     
    387396      (*pulType) |= DRIVE_NOLONGNAMES;  // Others can not have long names
    388397  }
    389 
    390398
    391399  DosError(FERR_DISABLEHARDERR);
     
    725733}
    726734
    727 VOID DriveFlagsOne(INT x)
     735VOID DriveFlagsOne(INT x, CHAR *FileSystem, VOID *volser)
    728736{
    729737  INT removable;
    730   CHAR szDrive[] = " :\\", FileSystem[CCHMAXPATH];
     738  CHAR szDrive[] = " :\\";
    731739  ULONG drvtype;
    732740
     
    735743  drvtype = 0;
    736744  removable = CheckDrive(*szDrive, FileSystem, &drvtype);
     745  strupr(FileSystem);
    737746  driveserial[x] = -1;
    738747  driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
     
    741750                    DRIVE_WRITEVERIFYOFF);
    742751  if (removable != -1) {
    743     struct
    744     {
    745       ULONG serial;
    746       CHAR volumelength;
    747       CHAR volumelabel[CCHMAXPATH];
    748     }
    749     volser;
    750 
    751     DosError(FERR_DISABLEHARDERR);
    752     if (!DosQueryFSInfo((ULONG) x + 1, FSIL_VOLSER, &volser, sizeof(volser)))
    753       driveserial[x] = volser.serial;
    754     else
     752    if (!volser) {
     753      struct
     754      {
     755        ULONG serial;
     756        CHAR volumelength;
     757        CHAR volumelabel[CCHMAXPATH];
     758      }
     759      volserl;
     760 
    755761      DosError(FERR_DISABLEHARDERR);
     762      if (!DosQueryFSInfo((ULONG) x + 1, FSIL_VOLSER, &volserl, sizeof(volserl)))
     763        driveserial[x] = volserl.serial;
     764      else
     765        DosError(FERR_DISABLEHARDERR);
     766    }
     767    else {
     768      DosError(FERR_DISABLEHARDERR);
     769      if (DosQueryFSInfo((ULONG) x + 1, FSIL_VOLSER, volser,
     770                         sizeof(ULONG) + sizeof(CHAR) + CCHMAXPATH))
     771        DosError(FERR_DISABLEHARDERR);
     772    }
    756773  }
    757774  else
    758775    driveflags[x] |= DRIVE_INVALID;
    759   driveflags[x] |= ((removable == -1 || removable == 1) ?
    760                     DRIVE_REMOVABLE : 0);
     776  driveflags[x] |= ((removable == -1 || removable == 1) ? DRIVE_REMOVABLE : 0);
    761777  if (drvtype & DRIVE_REMOTE)
    762778    driveflags[x] |= DRIVE_REMOTE;
    763   if(!stricmp(FileSystem,NDFS32)){
     779  if (drvtype & DRIVE_NOEASUPPORT)
     780    driveflags[x] |= DRIVE_NOEASUPPORT;
     781  if(!strcmp(FileSystem,NDFS32)){
    764782    driveflags[x] |= DRIVE_VIRTUAL;
    765783    driveflags[x] &= (~DRIVE_REMOTE);
    766784  }
    767   if(!stricmp(FileSystem,RAMFS)){
     785  if(!strcmp(FileSystem,RAMFS)){
    768786    driveflags[x] |= DRIVE_RAMDISK;
    769787    driveflags[x] &= (~DRIVE_REMOTE);
    770788  }
    771   if(!stricmp(FileSystem,NTFS))
     789  if(!strcmp(FileSystem,NTFS))
    772790    driveflags[x] |= DRIVE_NOTWRITEABLE;
    773791  if (strcmp(FileSystem, HPFS) &&
    774       strcmp(FileSystem, JFS) &&
    775792      strcmp(FileSystem, CDFS) &&
    776793      strcmp(FileSystem, ISOFS) &&
     794      strcmp(FileSystem, JFS) &&
     795      strcmp(FileSystem, LAN) &&
    777796      strcmp(FileSystem, RAMFS) &&
    778797      strcmp(FileSystem, FAT32) &&
     
    782801    driveflags[x] |= DRIVE_NOLONGNAMES;
    783802  }
    784 
     803  if ((!strcmp(FileSystem, HPFS) ||
     804       !strcmp(FileSystem, JFS) ||
     805       !strcmp(FileSystem, FAT32) ||
     806       !strcmp(FileSystem, NTFS) ||
     807       !strcmp(FileSystem, HPFS386)) && ~driveflags[x] & DRIVE_REMOVABLE) {
     808    driveflags[x] |= DRIVE_LOCALHD;
     809  }
    785810  if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS)) {
    786     removable = 1;
    787811    driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | DRIVE_CDROM);
    788812  }
    789   if (!stricmp(FileSystem, CBSIFS)) {
     813  if (!strcmp(FileSystem, CBSIFS)) {
    790814    driveflags[x] |= DRIVE_ZIPSTREAM;
    791815    driveflags[x] &= (~DRIVE_REMOTE);
     
    823847
    824848      if (x > 1) {
    825         if (!(driveflags[x] & DRIVE_NOPRESCAN))
    826           DriveFlagsOne(x);
     849        if (!(driveflags[x] & DRIVE_NOPRESCAN)) {
     850          CHAR FileSystem[CCHMAXPATH];
     851          DriveFlagsOne(x, FileSystem, NULL);
     852        }
    827853        else
    828854          driveserial[x] = -1;
Note: See TracChangeset for help on using the changeset viewer.