Changeset 1611 for trunk/dll/collect.c
- Timestamp:
- Aug 9, 2011, 12:08:03 AM (14 years ago)
- File:
-
- 1 edited
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);
Note:
See TracChangeset
for help on using the changeset viewer.