Changeset 1250 for trunk/dll


Ignore:
Timestamp:
Oct 19, 2008, 1:02:39 AM (17 years ago)
Author:
Gregg Young
Message:

Scan drives in 4 passes to speed up tree scans (Ticket 25)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/filldir.c

    r1223 r1250  
    5050  05 Sep 08 SHL Correct FreeCnrItemData pszDisplayName pointer overlap check
    5151  08 Sep 08 SHL Remove extra pszLongName logic in FreeCnrItemData
     52  18 Oct 08 GKY Scan drives in 4 passes (local, virtual, remote, flagged slow) to speed tree scans
    5253
    5354***********************************************************************/
     
    11341135  BOOL drivesbuilt = FALSE;
    11351136  ULONG startdrive = 3;
     1137  LONG TestFlags[3];
    11361138
    11371139  static BOOL didonce = FALSE;
     
    13131315            pci->pszDispAttr = FileAttrToString(pci->attrFile);
    13141316          }
    1315           SelectDriveIcon(pci);
     1317          SelectDriveIcon(pci);
     1318#         ifdef FORTIFY
     1319          // Will be freed by TreeCnrWndProc WM_DESTROY
     1320          Fortify_SetScope(pci->pszFileName, 2);
     1321#         endif
    13161322        }
    1317         else {
     1323        else {
    13181324          pci->rc.hptrIcon = hptrDunno;
    13191325          pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
     
    14741480    }
    14751481  } // if show env
    1476 
     1482  TestFlags[0] = DRIVE_SLOW | DRIVE_VIRTUAL | DRIVE_REMOTE;
     1483  TestFlags[1] = DRIVE_VIRTUAL;
     1484  TestFlags[2] = DRIVE_REMOTE;
     1485  TestFlags[3] = DRIVE_SLOW;
    14771486  x = 0;
    1478   pci = (PCNRITEM) WinSendMsg(hwndCnr,
    1479                               CM_QUERYRECORD,
    1480                               MPVOID,
    1481                               MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    1482   while (pci && (INT)pci != -1) {
    1483     pciNext = (PCNRITEM) WinSendMsg(hwndCnr,
    1484                                     CM_QUERYRECORD,
    1485                                     MPFROMP(pci),
    1486                                     MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    1487     if (!(pci->flags & RECFLAGS_ENV)) {
    1488       if ((ULONG) (toupper(*pci->pszFileName) - '@') == ulCurDriveNum ||
    1489           toupper(*pci->pszFileName) > 'B')
    1490       {
    1491         if (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_INVALID) &&
    1492             !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_NOPRESCAN) &&
    1493             (!fNoRemovableScan ||
    1494              !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE)))
    1495         {
    1496           if (!Stubby(hwndCnr, pci) && !DRIVE_RAMDISK) {
    1497             WinSendMsg(hwndCnr,
    1498                        CM_INVALIDATERECORD,
    1499                        MPFROMP(&pci),
    1500                        MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
    1501             goto SkipBadRec;
    1502           }
    1503         }
    1504       }
    1505       else {
    1506         WinSendMsg(hwndCnr,
    1507                    CM_INVALIDATERECORD,
    1508                    MPFROMP(&pci),
    1509                    MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
    1510       }
    1511 
    1512       WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT),
    1513                                  MAIN_DRIVELIST),
    1514                  LM_INSERTITEM,
    1515                  MPFROM2SHORT(LIT_SORTASCENDING, 0),
    1516                  MPFROMP(pci->pszFileName));
    1517     }
    1518   SkipBadRec:
    1519     x++;
    1520     pci = pciNext;
    1521   } // while
     1487  // Scan drives in 4 passes based on TestFlags
     1488  for (x = 0; x < 4; x++) {
     1489    pci = (PCNRITEM) WinSendMsg(hwndCnr,
     1490                                CM_QUERYRECORD,
     1491                                MPVOID,
     1492                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     1493    while (pci && (INT)pci != -1) {
     1494      pciNext = (PCNRITEM) WinSendMsg(hwndCnr,
     1495                                      CM_QUERYRECORD,
     1496                                      MPFROMP(pci),
     1497                                      MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     1498      if (!(pci->flags & RECFLAGS_ENV)) {
     1499        if ((ULONG) (toupper(*pci->pszFileName) - '@') == ulCurDriveNum ||
     1500            toupper(*pci->pszFileName) > 'B') {
     1501          if (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_INVALID) &&
     1502              !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_NOPRESCAN) &&
     1503              (!fNoRemovableScan ||
     1504              !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE)) &&
     1505              (x == 0 ? (!(TestFlags[x] & (driveflags[toupper(*pci->pszFileName) - 'A']))) :
     1506               x == 3 ? (TestFlags[x] & (driveflags[toupper(*pci->pszFileName) - 'A'])) :
     1507               ((TestFlags[x] & (driveflags[toupper(*pci->pszFileName) - 'A'])) &&
     1508                !((driveflags[toupper(*pci->pszFileName) - 'A']) & DRIVE_SLOW)))) {
     1509            if (!Stubby(hwndCnr, pci) && !DRIVE_RAMDISK) {
     1510              WinSendMsg(hwndCnr,
     1511                         CM_INVALIDATERECORD,
     1512                         MPFROMP(&pci),
     1513                         MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
     1514              goto SkipBadRec;
     1515            }
     1516          }
     1517        }
     1518        else {
     1519          WinSendMsg(hwndCnr,
     1520                     CM_INVALIDATERECORD,
     1521                     MPFROMP(&pci),
     1522                     MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
     1523        }
     1524        WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT),
     1525                                   MAIN_DRIVELIST),
     1526                   LM_INSERTITEM,
     1527                   MPFROM2SHORT(LIT_SORTASCENDING, 0),
     1528                   MPFROMP(pci->pszFileName));
     1529      }
     1530    SkipBadRec:
     1531      pci = pciNext;
     1532    } // while
     1533  } // for
    15221534  if (hwndParent)
    15231535    WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT),
Note: See TracChangeset for help on using the changeset viewer.