Changeset 1611
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/collect.c
r1563 r1611 74 74 including the option to use walk directories to select path 75 75 28 May 11 GKY Fixed trap caused by passing a nonexistant pci to FillInRecordFromFFB in 76 76 UM_COLLECT because pci is limited to 65535 files. (nRecord is a USHORT) 77 77 29 May 11 SHL Rework UM_COLLECT >65K records logic to not require double loop 78 78 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 79 80 80 81 ***********************************************************************/ … … 669 670 PCNRITEM pci = NULL; 670 671 PCNRITEM pciFirst = NULL; 671 PCNRITEM pciNext; 672 PCNRITEM pciPrev = NULL; 672 PCNRITEM pciPrev; 673 673 ULONG nm; 674 674 ULONG ulRecsAtStart; 675 675 ULONG ulRecsToInsert; 676 ULONG ulRecs Allocated = 0;676 ULONG ulRecsInserted = 0; 677 677 ULONGLONG ullTotalBytes; 678 BOOL checkToInsert = FALSE; 678 679 CNRINFO cnri; 679 680 RECORDINSERT ri; … … 697 698 698 699 for (x = 0; li->list[x]; x++) { 699 // Allocate container items if needed 700 701 // Allocate more container items if needed 700 702 if (!pci) { 701 ulRecsToInsert = ulMaxFiles - ulRecs Allocated;703 ulRecsToInsert = ulMaxFiles - ulRecsInserted; // Left to do 702 704 if (ulRecsToInsert > USHRT_MAX) 703 ulRecsToInsert = USHRT_MAX; 704 pciPrev = NULL; 705 ulRecsToInsert = USHRT_MAX; // Avoid USHORT overflows 705 706 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD, 706 707 MPFROMLONG(EXTRA_RECORD_BYTES), 707 708 MPFROMLONG(ulRecsToInsert)); 709 pciFirst = pci; 710 pciPrev = NULL; 708 711 if (!pci) { 709 712 Runtime_Error(pszSrcFile, __LINE__, PCSZ_CM_ALLOCRECORD); 710 713 break; 711 714 } 712 pciFirst = pci;713 715 } // if need allocate 716 714 717 nm = 1; 715 718 hdir = HDIR_CREATE; … … 722 725 FALSE, 723 726 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 728 733 Runtime_Error(pszSrcFile, __LINE__, "pci NULL for list[%u]", x); 729 pci = pciNext; // Try to recover730 734 } 731 735 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 734 739 // 2011-05-29 SHL fixme to check fail 735 740 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID, 736 741 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE)); 737 742 } 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 751 748 else if (*li->list[x] && 752 749 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME, … … 758 755 FILE_ARCHIVED | FILE_SYSTEM | 759 756 FILE_HIDDEN | FILE_READONLY, 760 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) { 757 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) 758 { 759 // OK to add 761 760 DosFindClose(hdir); 762 761 priority_normal(); … … 772 771 // DosQueryPathInfo etc. failed - try to recover 773 772 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 781 787 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 786 793 // Check if time to insert 787 794 if (!pci) { 795 // All allocated CNRITEMs filled 788 796 if (ulRecsToInsert) { 797 // Have CNRITEMs to insert 789 798 memset(&ri, 0, sizeof(RECORDINSERT)); 790 799 ri.cb = sizeof(RECORDINSERT); … … 798 807 // 2011-05-29 SHL fixme to complain on failure 799 808 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID); 800 ulRecs Allocated += ulRecsToInsert;809 ulRecsInserted += ulRecsToInsert; 801 810 pciFirst = NULL; 802 811 ulRecsToInsert = 0; … … 807 816 808 817 // Clean up in case stopped early by error 809 if (pci) {818 if (pci) 810 819 Runtime_Error(pszSrcFile, __LINE__, "pci not NULL"); 811 } 820 812 821 if (pciFirst) { 813 822 Runtime_Error(pszSrcFile, __LINE__, "pciFirst not NULL"); … … 1402 1411 p = pci->pszFileName; 1403 1412 else { 1413 if (!pci->pszFileName) 1414 Runtime_Error(pszSrcFile, __LINE__, "pci->pszFileName NULL for %p", pci); 1404 1415 p = strrchr(pci->pszFileName, '\\'); 1405 1416 if (p) { … … 2753 2764 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY; 2754 2765 break; 2755 } 2756 } 2766 } // switch 2767 } // if !collect 2757 2768 if (!li->list || !li->list[0]) 2758 2769 FreeListInfo(li); -
trunk/dll/update.c
r1444 r1611 72 72 return pci->rc.hptrIcon; 73 73 } 74 PCNRITEM UpdateCnrRecord(HWND hwndCnr, CHAR * filename, BOOL partial, 75 DIRCNRDATA * dcd) 74 75 /* Update/add CNRITEM record for filename 76 * Deletes existing CNRITEM if file has disappeared 77 * @returns pci pointer to CNRITEM record or NULL if not found or if stale CNRITEM deleted 78 */ 79 80 PCNRITEM UpdateCnrRecord(HWND hwndCnr, CHAR *filename, BOOL partial, 81 DIRCNRDATA *dcd) 76 82 { 77 83 PCNRITEM pci; … … 129 135 filename, (PCNRITEM) NULL, partial, FALSE, TRUE); 130 136 Update: 131 if (pci) { /* update record? */ 137 if (pci) { 138 // Check if record needs to be updated 132 139 if ((!fForceUpper && !fForceLower && strcmp(pci->pszFileName, filename)) || 133 140 pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile || … … 140 147 pci->ladate.year != ffb.fdateLastAccess.year + 1980 || pci->latime.seconds != 141 148 ffb.ftimeLastAccess.twosecs * 2 || pci->latime.minutes != 142 ffb.ftimeLastAccess.minutes || pci->latime.hours != ffb.ftimeLastAccess.hours) { /* changed; update */ 143 *ffb.achName = 0; 149 ffb.ftimeLastAccess.minutes || pci->latime.hours != ffb.ftimeLastAccess.hours) 150 { 151 // Something changed - update 152 *ffb.achName = 0; // Tell FillInRecordFromFFB that filename contains full pathname 144 153 ffb.cchName = 0; 145 154 FillInRecordFromFFB(hwndCnr, pci, filename, &ffb, partial, dcd); 146 155 if (strlen(pci->pszFileName) < 4) 147 SelectDriveIcon(pci);156 SelectDriveIcon(pci); 148 157 oldemphasis = pci->rc.flRecordAttr & (CRA_SELECTED | CRA_CURSORED); 149 158 if (oldemphasis) … … 152 161 MPFROMP(pci), MPFROM2SHORT(FALSE, oldemphasis)); 153 162 WinSendMsg(hwndCnr, 154 CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, 155 /* CMA_ERASE | */ 156 CMA_TEXTCHANGED)); 163 CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, CMA_TEXTCHANGED)); 157 164 if (oldemphasis) 158 165 WinSendMsg(hwndCnr, … … 163 170 return pci; 164 171 } 165 else { /* add record */ 172 else { 173 // Add record 166 174 if (dcd->type == DIR_FRAME) { 167 175 … … 191 199 dcd->ullTotalBytes += ullTotalBytes; 192 200 PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID); 193 194 195 201 if (pci->attrFile & FILE_DIRECTORY) { 202 Stubby(hwndCnr, pci); 203 } 196 204 } 197 205 } … … 285 293 if (dcd->type == DIR_FRAME) { 286 294 dcd->ullTotalBytes += ullTotalBytes; 287 288 295 } 296 Stubby(hwndCnr, pci); 289 297 } 290 298 } … … 299 307 TRUE)) != 300 308 NULL && (INT) pci != -1 && strlen(pci->pszFileName) > 3) { 301 / * file doesn't exist; delete record */309 // File has disappeared and found stale CNRITEM record delete it 302 310 if (!dcd) 303 311 dcd = INSTDATA(hwndCnr); … … 438 446 &ffb, partial, dcd); 439 447 if (strlen(pci->pszFileName) < 4) 440 448 SelectDriveIcon(pci); 441 449 memset(&ri, 0, sizeof(RECORDINSERT)); 442 450 ri.cb = sizeof(RECORDINSERT); … … 453 461 } 454 462 repos = TRUE; 455 456 457 463 if (pci->attrFile & FILE_DIRECTORY) { 464 Stubby(hwndCnr, pci); 465 } 458 466 } 459 467 else … … 552 560 dcd->ullTotalBytes += ullTotalBytes; 553 561 } 554 555 562 repos = TRUE; 563 Stubby(hwndCnr, pci); 556 564 } 557 565 else … … 579 587 if (RemoveCnrItems(hwndCnr, pci, 1, 580 588 CMA_FREE | 581 582 589 numremain == 1 ? CMA_INVALIDATE : 0) != -1) { 590 pci = NULL; 583 591 numremain--; 584 592 repos = TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.