Changeset 1444 for trunk/dll/filldir.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/filldir.c

    r1440 r1444  
    7575                for tree container
    7676  13 Jul 09 SHL Avoid trap in FillInRecordFromFSA if pszFSType NULL
     77  22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
     78  22 Jul 09 GKY Consolidated driveflag setting code in DriveFlagsOne
     79  22 Jul 09 GKY Streamline scanning code for faster Tree rescans
    7780
    7881***********************************************************************/
     
    132135PCSZ FM3Tools   = "<FM3_Tools>";
    133136PCSZ WPProgram  = "WPProgram";
    134 volatile INT StubbyScanCount;
    135 volatile INT ProcessDirCount;
    136137
    137138typedef struct {
     
    220221      hmq = WinCreateMsgQueue(thab, 0);
    221222      if (hmq) {
    222         StubbyScanCount++;
    223223        IncrThreadUsage();
    224224        priority_normal();
    225225        ret = Stubby(StubbyScan->hwndCnr, StubbyScan->pci);
    226         //DbgMsg(pszSrcFile, __LINE__, "Stubby %i ", ret);
    227226        if (ret == 1) {
    228227          if (WinIsWindow((HAB)0, StubbyScan->hwndCnr)) {
    229             WinSendMsg(StubbyScan->hwndCnr,
    230                        CM_INVALIDATERECORD,
    231                        MPFROMP(&StubbyScan->pci),
    232                        MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
    233             if ((fRScanLocal &&
    234                 (!(driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] &
    235                    ((DRIVE_REMOTE | DRIVE_VIRTUAL)))) ||
    236                  (fRScanRemote &&
    237                   (driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] &
    238                    DRIVE_REMOTE)) ||
    239                  (fRScanVirtual &&
    240                   (driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] &
    241                    DRIVE_VIRTUAL))) && fInitialDriveScan) {
    242               if (!(driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'] &
    243                     ((fRScanNoWrite ? 0 : DRIVE_NOTWRITEABLE) |
    244                      (fRScanSlow ? 0 : DRIVE_SLOW)))) {
    245                 WinSendMsg(StubbyScan->hwndCnr, CM_EXPANDTREE, MPFROMP(StubbyScan->pci), MPVOID);
    246                 //DbgMsg(pszSrcFile, __LINE__, "expanded %x %p", StubbyScan->hwndCnr, StubbyScan->pci);
    247                 WinSendMsg(StubbyScan->hwndCnr, CM_COLLAPSETREE, MPFROMP(StubbyScan->pci), MPVOID);
     228            ULONG flags = driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'];
     229
     230            if (((fRScanLocal && ~flags & DRIVE_REMOTE && ~flags & DRIVE_VIRTUAL) ||
     231                 (fRScanRemote && flags & DRIVE_REMOTE) ||
     232                 (fRScanVirtual && flags & DRIVE_VIRTUAL)) && fInitialDriveScan) {
     233              if (!(flags & ((fRScanNoWrite ? 0 : DRIVE_NOTWRITEABLE) |
     234                             (fRScanSlow ? 0 : DRIVE_SLOW)))) {
     235                UnFlesh(StubbyScan->hwndCnr, StubbyScan->pci);
     236                Flesh(StubbyScan->hwndCnr, StubbyScan->pci);
    248237              }
    249238            }
    250239          }
    251240        }
    252         if (WinIsWindow((HAB)0, StubbyScan->hwndDrivesList)) {
    253           WinSendMsg(StubbyScan->hwndDrivesList,
    254                      LM_INSERTITEM,
    255                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    256                      MPFROMP(StubbyScan->pci->pszFileName));
    257         }
    258         StubbyScanCount--;
    259241        WinDestroyMsgQueue(hmq);
    260242      }
     
    268250#  endif
    269251
    270   // _endthread();                      // 10 Dec 08 SHL
    271252}
    272253
     
    276257  HAB thab;
    277258  HMQ hmq = (HMQ) 0;
    278   //BOOL ret;
    279259
    280260  DosError(FERR_DISABLEHARDERR);
     
    290270      hmq = WinCreateMsgQueue(thab, 0);
    291271      if (hmq) {
    292         ProcessDirCount ++;
    293272        IncrThreadUsage();
    294273        priority_normal();
     
    303282                         ProcessDir->pulTotalFiles,     // Optional
    304283                         ProcessDir->pullTotalBytes);   // Optional
    305         ProcessDirCount --;
    306284        WinDestroyMsgQueue(hmq);
    307285      }
     
    315293#  endif
    316294
    317   // _endthread();                      // 10 Dec 08 SHL
    318295}
    319296
     
    433410  ULONG flags = driveflags[toupper(*pci->pszFileName) - 'A'];
    434411  BOOL fLoadSubjectForDrive = fLoadSubject && ~flags & DRIVE_NOLOADSUBJS;
    435   BOOL fLoadLongNameForDrive = fLoadLongnames &&  ~flags & DRIVE_NOLONGNAMES &&
     412  BOOL fLoadLongNameForDrive = fLoadLongnames &&  //~flags & DRIVE_NOLONGNAMES &&
    436413                               ~flags & DRIVE_NOLOADLONGS;
    437414  if (fLoadSubjectForDrive || fLoadLongNameForDrive) {
     
    580557
    581558  // load Subject and/or Longname EAs, if required and have EAs
    582   if (pffb->cbList > 4L && dcd)
     559  if (pffb->cbList > 4L && dcd &&
     560      !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_NOEASUPPORT))
    583561    FetchCommonEAs(pci);
    584562
     
    741719  // 13 Jul 09 SHL fixme to know if fetch can be bypassed if pszFSType already filled
    742720  // If FSType not supplied, assume don't need EAs either
    743   if (pfsa4->cbList > 4L && dcd && pszFSType)
     721  if (pfsa4->cbList > 4L && dcd &&
     722      !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_NOEASUPPORT))
    744723    FetchCommonEAs(pci);
    745724
     
    827806#   endif
    828807  }
    829   else
     808  else {
    830809    pci->pszFmtFileSize = NullStr;
     810    //DbgMsg(pszSrcFile, __LINE__, "Bypassed Format size %s", pci->pszDisplayName);
     811  }
    831812  pci->date.day = pfsa4->fdateLastWrite.day;
    832813  pci->date.month = pfsa4->fdateLastWrite.month;
     
    11821163    while (pci && (INT)pci != -1) {
    11831164      if ((pci->attrFile & FILE_DIRECTORY))
    1184         if (!fInitialDriveScan)
    1185           Stubby(hwndCnr, pci);
    1186         else {
    1187           while (StubbyScanCount != 0)
    1188             DosSleep(50);
    1189           Stubby(hwndCnr, pci);
    1190         }
     1165        Stubby(hwndCnr, pci);
    11911166      pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
    11921167                       MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     
    12361211  ULONG ulDriveType;
    12371212  PCNRITEM pci, pciFirst = NULL, pciNext, pciParent = NULL;
    1238   INT x, removable;
     1213  INT x;// removable;
    12391214  CHAR suggest[32];
    12401215  CHAR szDrive[] = " :\\";
     
    13031278      ULONG flags = 0;
    13041279      ULONG size = sizeof(ULONG);
    1305       BOOL FSInfo = FALSE;
    13061280      struct {
    13071281              ULONG serial;
     
    13211295        if (!(driveflags[x] & DRIVE_NOPRESCAN)) {
    13221296          *szFSType = 0;
    1323           ulDriveType = 0;
    1324           removable = CheckDrive(*szDrive, szFSType, &ulDriveType);
    1325           driveserial[x] = -1;
    1326           if (removable != -1) {
    1327             DosError(FERR_DISABLEHARDERR);
    1328             if (!DosQueryFSInfo((ULONG) x + 1,
    1329                                 FSIL_VOLSER, &volser, sizeof(volser))) {
    1330               driveserial[x] = volser.serial;
    1331               FSInfo = TRUE;
    1332             }
    1333 
    1334           }
    1335           else
    1336             driveflags[x] |= DRIVE_INVALID;
    1337 
     1297          ulDriveType = 0;
     1298          memset(&volser, 0, sizeof(volser));
     1299          DriveFlagsOne(x, szFSType, &volser);
     1300          driveserial[x] = volser.serial;
    13381301          memset(&fsa4, 0, sizeof(FILESTATUS4L));
    1339           driveflags[x] |= removable == -1 || removable == 1 ? DRIVE_REMOVABLE : 0;
    1340           if (ulDriveType & DRIVE_REMOTE)
    1341             driveflags[x] |= DRIVE_REMOTE;
    1342           if (!stricmp(szFSType,RAMFS)) {
    1343             driveflags[x] |= DRIVE_RAMDISK;
    1344             driveflags[x] &= ~DRIVE_REMOTE;
    1345           }
    1346           if (!stricmp(szFSType,NDFS32)) {
    1347             driveflags[x] |= DRIVE_VIRTUAL;
    1348             driveflags[x] &= ~DRIVE_REMOTE;
    1349           }
    1350           if (!stricmp(szFSType,NTFS))
    1351             driveflags[x] |= DRIVE_NOTWRITEABLE;
    1352           if (strcmp(szFSType, HPFS) &&
    1353               strcmp(szFSType, JFS) &&
    1354               strcmp(szFSType, ISOFS) &&
    1355               strcmp(szFSType, CDFS) &&
    1356               strcmp(szFSType, FAT32) &&
    1357               strcmp(szFSType, NDFS32) &&
    1358               strcmp(szFSType, RAMFS) &&
    1359               strcmp(szFSType, NTFS) &&
    1360               strcmp(szFSType, HPFS386)) {
    1361             driveflags[x] |= DRIVE_NOLONGNAMES;
    1362           }
    1363 
    1364           if (!strcmp(szFSType, CDFS) || !strcmp(szFSType,ISOFS)) {
    1365             removable = 1;
    1366             driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | DRIVE_CDROM;
    1367           }
    1368           if (!stricmp(szFSType, CBSIFS)) {
    1369             driveflags[x] |= DRIVE_ZIPSTREAM;
    1370             driveflags[x] &= ~DRIVE_REMOTE;
    1371             if (ulDriveType & DRIVE_REMOVABLE)
    1372               driveflags[x] |= DRIVE_REMOVABLE;
    1373             if (!(ulDriveType & DRIVE_NOLONGNAMES))
    1374               driveflags[x] &= ~DRIVE_NOLONGNAMES;
    1375           }
    13761302          if (!fVerifyOffChecked[x]) {
    13771303            if (driveflags[x] & DRIVE_REMOVABLE)
     
    13851311            }
    13861312          }
    1387           if (strcmp(volser.volumelabel, NullStr) != 0 && FSInfo && fShowDriveLabelInTree)
     1313          if (stricmp(volser.volumelabel, NullStr) != 0 && fShowDriveLabelInTree)
    13881314            strcpy(szFSType, volser.volumelabel);
    13891315          pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
     
    13911317            pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED);
    13921318
    1393           if (removable == 0) {
     1319          if (!(driveflags[x] & DRIVE_REMOVABLE)) {
    13941320            // Fixed volume
    13951321            pci->attrFile |= FILE_DIRECTORY;
     
    16221548                                MPVOID,
    16231549                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    1624     StubbyScanCount ++;
    16251550    while (pci && (INT)pci != -1) {
    16261551      stubbyScan = xmallocz(sizeof(STUBBYSCAN), pszSrcFile, __LINE__);
     
    16301555      stubbyScan->hwndCnr = hwndCnr;
    16311556      stubbyScan->hwndDrivesList = hwndDrivesList;
    1632       //stubbyScan->RamDrive = FALSE;
    16331557      pciNext = (PCNRITEM) WinSendMsg(hwndCnr,
    16341558                                      CM_QUERYRECORD,
     
    16501574            {
    16511575              xfree(stubbyScan, pszSrcFile, __LINE__);
    1652             }
     1576            }
    16531577          } // if drive for scanning
    16541578          else
     
    16711595      pci = pciNext;
    16721596    } // while
    1673     StubbyScanCount--;
    16741597  }
    16751598  if (hwndParent)
     
    17661689  }
    17671690  didonce = TRUE;
    1768   if (fInitialDriveScan) {
    1769     HWND hwndDrivesList = WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT),
    1770                                           MAIN_DRIVELIST);
    1771     while (StubbyScanCount != 0 || ProcessDirCount != 0)
    1772       DosSleep(50);
    1773     WinShowWindow(hwndCnr, TRUE);
    1774     WinShowWindow(hwndDrivesList, TRUE);
    1775     fInitialDriveScan = FALSE;
    1776   }
    17771691} // FillTreeCnr
    17781692
Note: See TracChangeset for help on using the changeset viewer.