Changeset 1611 for trunk/dll/collect.c


Ignore:
Timestamp:
Aug 9, 2011, 12:08:03 AM (14 years ago)
Author:
Steven Levine
Message:

Allow SVN/CVS file ignore in Seek and scan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/collect.c

    r1563 r1611  
    7474                including the option to use walk directories to select path
    7575  28 May 11 GKY Fixed trap caused by passing a nonexistant pci to FillInRecordFromFFB in
    76                 UM_COLLECT because pci is limited to 65535 files. (nRecord is a USHORT)
     76                UM_COLLECT because pci is limited to 65535 files. (nRecord is a USHORT)
    7777  29 May 11 SHL Rework UM_COLLECT >65K records logic to not require double loop
    7878  29 May 11 SHL Tweak UM_COLLECT to bypass FindCnrRecord when container initially empty
     79  08 Aug 11 SHL Rework UM_COLLECT to avoid spurious container items free
    7980
    8081***********************************************************************/
     
    669670        PCNRITEM pci = NULL;
    670671        PCNRITEM pciFirst = NULL;
    671         PCNRITEM pciNext;
    672         PCNRITEM pciPrev = NULL;
     672        PCNRITEM pciPrev;
    673673        ULONG nm;
    674674        ULONG ulRecsAtStart;
    675675        ULONG ulRecsToInsert;
    676         ULONG ulRecsAllocated = 0;
     676        ULONG ulRecsInserted = 0;
    677677        ULONGLONG ullTotalBytes;
     678        BOOL checkToInsert = FALSE;
    678679        CNRINFO cnri;
    679680        RECORDINSERT ri;
     
    697698
    698699        for (x = 0; li->list[x]; x++) {
    699           // Allocate container items if needed
     700
     701          // Allocate more container items if needed
    700702          if (!pci) {
    701             ulRecsToInsert = ulMaxFiles - ulRecsAllocated;
     703            ulRecsToInsert = ulMaxFiles - ulRecsInserted;       // Left to do
    702704            if (ulRecsToInsert > USHRT_MAX)
    703               ulRecsToInsert = USHRT_MAX;
    704             pciPrev = NULL;
     705              ulRecsToInsert = USHRT_MAX;               // Avoid USHORT overflows
    705706            pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
    706707                             MPFROMLONG(EXTRA_RECORD_BYTES),
    707708                             MPFROMLONG(ulRecsToInsert));
     709            pciFirst = pci;
     710            pciPrev = NULL;
    708711            if (!pci) {
    709712              Runtime_Error(pszSrcFile, __LINE__, PCSZ_CM_ALLOCRECORD);
    710713              break;
    711714            }
    712             pciFirst = pci;
    713715          } // if need allocate
     716
    714717          nm = 1;
    715718          hdir = HDIR_CREATE;
     
    722725                            FALSE,
    723726                            FALSE,
    724                             TRUE)) {
    725             pciNext = (PCNRITEM)pci->rc.preccNextRecord;
    726             pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
    727             if (!pci) {
     727                            TRUE))
     728          {
     729            // Updating existing record
     730            PCNRITEM pciUpd = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
     731            if (!pciUpd) {
     732              // file has disappeared
    728733              Runtime_Error(pszSrcFile, __LINE__, "pci NULL for list[%u]", x);
    729               pci = pciNext;            // Try to recover
    730734            }
    731735            else {
    732               if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
    733                 pci->rc.flRecordAttr &= ~CRA_FILTERED;  // Ensure visible
     736              // Update OK
     737              if (Filter((PMINIRECORDCORE) pciUpd, (PVOID) & dcd->mask)) {
     738                pciUpd->rc.flRecordAttr &= ~CRA_FILTERED;       // Ensure visible
    734739                // 2011-05-29 SHL fixme to check fail
    735740                WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
    736741                           MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
    737742              }
    738               // Remove extra record from chain and free
    739               if (pciPrev)
    740                 pciPrev->rc.preccNextRecord = (PMINIRECORDCORE)pciNext;
    741               else
    742                 pciFirst = pciNext;
    743               if (pci)
    744                 FreeCnrItem(dcd->hwndCnr, pci);
    745               pci = pciNext;
    746               ulRecsToInsert--;         // Remember gone
    747               ulMaxFiles--;             // Remember gone
    748             }
    749           }
    750           // Add new entry
     743            }
     744            ulMaxFiles--;               // No insert needed
     745            checkToInsert = TRUE;
     746          }
     747          // Add new entry maybe
    751748          else if (*li->list[x] &&
    752749              !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
     
    758755                             FILE_ARCHIVED | FILE_SYSTEM |
    759756                             FILE_HIDDEN | FILE_READONLY,
    760                              &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
     757                             &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL))
     758          {
     759            // OK to add
    761760            DosFindClose(hdir);
    762761            priority_normal();
     
    772771            // DosQueryPathInfo etc. failed - try to recover
    773772            Runtime_Error(pszSrcFile, __LINE__, "DosQueryPathInfo failed for %s", fullname);
    774             // Remove extra CNRITEM from chain
    775             pciNext = (PCNRITEM)pci->rc.preccNextRecord;
    776             if (pciPrev)
    777               pciPrev->rc.preccNextRecord = (PMINIRECORDCORE)pciNext;
    778             else
    779               pciFirst = pciNext;
    780             if (pci)
     773            ulMaxFiles--;               // Nothing to insert
     774            checkToInsert = TRUE;
     775          }
     776
     777          if (checkToInsert) {
     778            checkToInsert = FALSE;
     779            // Remove extra records from chain
     780            while (ulRecsInserted + ulRecsToInsert > ulMaxFiles) {
     781              PCNRITEM pciNext = (PCNRITEM)pci->rc.preccNextRecord;
     782              if (pciPrev)
     783                pciPrev->rc.preccNextRecord = (PMINIRECORDCORE)pciNext;
     784              else
     785                pciFirst = pciNext;
     786              pci->pszFileName = NullStr;       // Avoid spurious complaints
    781787              FreeCnrItem(dcd->hwndCnr, pci);
    782             pci = pciNext;
    783             ulRecsToInsert--;           // Remember gone
    784             ulMaxFiles--;               // Remember gone
    785           }
     788              pci = pciNext;
     789              ulRecsToInsert--;         // Remember gone
     790            }
     791          }
     792
    786793          // Check if time to insert
    787794          if (!pci) {
     795            // All allocated CNRITEMs filled
    788796            if (ulRecsToInsert) {
     797              // Have CNRITEMs to insert
    789798              memset(&ri, 0, sizeof(RECORDINSERT));
    790799              ri.cb = sizeof(RECORDINSERT);
     
    798807              // 2011-05-29 SHL fixme to complain on failure
    799808              PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
    800               ulRecsAllocated += ulRecsToInsert;
     809              ulRecsInserted += ulRecsToInsert;
    801810              pciFirst = NULL;
    802811              ulRecsToInsert = 0;
     
    807816
    808817        // Clean up in case stopped early by error
    809         if (pci) {
     818        if (pci)
    810819          Runtime_Error(pszSrcFile, __LINE__, "pci not NULL");
    811         }
     820
    812821        if (pciFirst) {
    813822          Runtime_Error(pszSrcFile, __LINE__, "pciFirst not NULL");
     
    14021411              p = pci->pszFileName;
    14031412            else {
     1413              if (!pci->pszFileName)
     1414                Runtime_Error(pszSrcFile, __LINE__, "pci->pszFileName NULL for %p", pci);
    14041415              p = strrchr(pci->pszFileName, '\\');
    14051416              if (p) {
     
    27532764                  li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
    27542765                break;
    2755               }
    2756             }
     2766              } // switch
     2767            } // if !collect
    27572768            if (!li->list || !li->list[0])
    27582769              FreeListInfo(li);
Note: See TracChangeset for help on using the changeset viewer.