Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r1878 r1891 6 6 Compare directories 7 7 8 Copyright (c) 1993- 02 M. Kimes9 Copyright (c) 2003 , 2013Steven H. Levine8 Copyright (c) 1993-2002 M. Kimes 9 Copyright (c) 2003-2020 Steven H. Levine 10 10 11 11 16 Oct 02 MK Baseline … … 89 89 09 Mar 13 SHL SetButtonEnables: correct enable support for newish buttons 90 90 10 Mar 13 GKY Improvrd readonly check on delete to allow cancel and don't ask again options 91 91 Added saymsg2 for this purpose 92 92 10 Mar 13 GKY Fixes to snapshot file. 93 93 14 Jun 15 GKY Changes to prvenet access violations when cmp is freed 94 28 Jan 20 SHL ActionCnrThread: report CM_INVALIDATERECORD failures 94 95 95 96 ***********************************************************************/ … … 150 151 #include "excputil.h" // xbeginthread 151 152 #include "info.h" // driveflags 152 #include "worker.h" 153 #include "rename.h" 153 #include "worker.h" // MOVEIT 154 #include "rename.h" // RenameProc 154 155 155 156 typedef struct … … 177 178 HDIR hdir = HDIR_CREATE; 178 179 ULONG ulFindCnt; 179 // CHAR szDate[DATE_BUF_BYTES];180 181 // 13 Aug 07 SHL fixmeto use FileToGet180 // CHAR szDate[DATE_BUF_BYTES]; 181 182 // 13 Aug 07 SHL FIXME to use FileToGet 182 183 pffb = xmalloc(sizeof(FILEFINDBUF4L), pszSrcFile, __LINE__); 183 184 if (pffb) { … … 188 189 enddir++; 189 190 ulFindCnt = 1; 190 // 13 Aug 07 SHL fixmeto report errors191 // 13 Aug 07 SHL FIXME to report errors 191 192 if (!xDosFindFirst(mask, 192 193 &hdir, … … 198 199 strcpy(enddir, pffb->achName); 199 200 if (!(pffb->attrFile & FILE_DIRECTORY)) { 200 // FDateFormat(szDate, pffb->fdateLastWrite);201 // FDateFormat(szDate, pffb->fdateLastWrite); 201 202 fprintf(fp, 202 203 "\"%s\",%u,%llu,%lu/%lu/%lu,%02u:%02u:%02u,%lu,%lu,N\n", 203 204 mask, 204 205 enddir - mask, 205 206 207 208 206 pffb->cbFile, 207 pffb->fdateLastWrite.year + 1980, 208 pffb->fdateLastWrite.month, 209 pffb->fdateLastWrite.day, 209 210 pffb->ftimeLastWrite.hours, 210 211 pffb->ftimeLastWrite.minutes, … … 572 573 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 573 574 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID, 574 575 fConfirmAction = 575 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 576 fConfirmAction = WinQueryButtonCheckstate(cmp->hwnd, COMP_CONFIRMACTION); 576 577 InitITimer(&itdSleep, 500); // Sleep every 500 mSec 577 578 … … 595 596 case IDM_DELETE: 596 597 597 if (fConfirmAction && !dontask) { 598 rc = saymsg2(NULL, 0, cmp->hwnd, GetPString(IDS_CONFIRMDELETE), GetPString(IDS_DOYOUWISHTODELETE), 599 pciS->pszFileName); 600 if (rc == 3 || rc == 4) { 601 if (rc == 4) 602 enddelete = TRUE; 603 break; 604 } 605 else if (rc == 2) 606 dontask = TRUE; 607 } 598 if (fConfirmAction && !dontask) { 599 rc = saymsg2(NULL, 0, cmp->hwnd, GetPString(IDS_CONFIRMDELETE), GetPString(IDS_DOYOUWISHTODELETE), 600 pciS->pszFileName); 601 if (rc == 3 || rc == 4) { 602 if (rc == 4) 603 enddelete = TRUE; 604 break; 605 } 606 else if (rc == 2) 607 dontask = TRUE; 608 } 609 608 610 if (!unlinkf(pciS->pszFileName)) { 609 611 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS), … … 612 614 if (!*pciD->pszFileName) { 613 615 // Other side is blank - remove from both sides 616 617 # ifdef PMPRINTF 618 PmPrintf_Report(pszSrcFile, __LINE__, "ActionCnrThread RemoveCnrItems pciS %p", pciS); 619 # endif 620 614 621 RemoveCnrItems(hwndCnrS, pciS, 1, CMA_FREE | CMA_INVALIDATE); 615 622 if (pciD->rc.flRecordAttr & CRA_SELECTED) 616 623 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD), 617 624 MPFROM2SHORT(FALSE, CRA_SELECTED)); 625 626 # ifdef PMPRINTF 627 PmPrintf_Report(pszSrcFile, __LINE__, "ActionCnrThread RemoveCnrItems pciD %p", pciD); 628 # endif 629 618 630 RemoveCnrItems(hwndCnrD, pciD, 1, CMA_FREE | CMA_INVALIDATE); 619 631 } 620 632 else { 621 633 // Other side is not blank - blank just this side 634 635 # ifdef PMPRINTF 636 PmPrintf_Report(pszSrcFile, __LINE__, "ActionCnrThread FreeCnrItemData pciS %p", pciS); 637 # endif 638 622 639 FreeCnrItemData(pciS); 623 640 // 29 Aug 08 SHL Point pci fields at NullStr to sync with FreeCnrItemData mods … … 626 643 pciS->rc.pszIcon = pciS->pszFileName; 627 644 pciS->flags = 0; // Just on one side 628 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 629 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 630 pciD->flags = 0; // Just on one side 631 if (pciD->pszSubject != NullStr) { 632 xfree(pciD->pszSubject, pszSrcFile, __LINE__); 633 pciD->pszSubject = NullStr; 634 } 635 } 645 if (!WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 646 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED))) { 647 Win_Error(hwndCnrS, cmp->hwnd, pszSrcFile, __LINE__, "CM_INVALIDATERECORD"); 648 } 649 650 pciD->flags = 0; // Just on one side 651 if (pciD->pszSubject != NullStr) { 652 xfree(pciD->pszSubject, pszSrcFile, __LINE__); 653 pciD->pszSubject = NullStr; 654 } 655 } 656 636 657 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR)) 637 658 cmp->cmp->totalleft--; … … 639 660 cmp->cmp->totalright--; 640 661 } 641 break; 662 break; // IDM_DELETE 642 663 643 664 case IDM_MOVE: … … 702 723 pciD->attrFile = pciS->attrFile; 703 724 pciD->pszDispAttr = pciS->pszDispAttr; 704 pciD->flags = 0; 725 pciD->flags = 0; // Just on one side 705 726 pciD->date = pciS->date; 706 727 pciD->time = pciS->time; … … 727 748 pciS->pszSubject = NullStr; 728 749 } 729 pciS->flags = 0; // Just on one side 730 731 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 732 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 733 734 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD), 735 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 750 pciS->flags = 0; // Just on one side 751 752 if (!WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 753 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED))) { 754 Win_Error(hwndCnrS, cmp->hwnd, pszSrcFile, __LINE__, "CM_INVALIDATERECORD"); 755 } 756 757 if (!WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD), 758 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED))) { 759 Win_Error(hwndCnrD, cmp->hwnd, pszSrcFile, __LINE__, "CM_INVALIDATERECORD"); 760 } 736 761 737 762 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR)) … … 868 893 SleepIfNeeded(&itdSleep, 0); 869 894 } // while 895 870 896 WinPostMsg(cmp->hwnd, WM_TIMER, MPFROMLONG(ID_COMP_TIMER), 0); // Force update 871 897 Abort: … … 1077 1103 1078 1104 if (numD != x) { 1079 // Something out of sync - fixmeto document why slow logic needed1105 // Something out of sync - FIXME to document why slow logic needed 1080 1106 if (!slow) { 1081 1107 slow = TRUE; … … 1202 1228 else if (memcmp(buf1, buf2, numread1)) 1203 1229 break; 1204 } 1230 } // while 1205 1231 } // same len 1206 1232 } // if open ok … … 1315 1341 pciD = pciDa[x]; 1316 1342 CompSelectSetSelects(pciS, 1317 1318 1319 1320 1343 pciD, 1344 pciS->flags & CNRITEM_EASDIFFER, 1345 pciD->flags & CNRITEM_EASDIFFER, 1346 wantAnd); 1321 1347 } 1322 1348 SleepIfNeeded(&itdSleep, 0); … … 1596 1622 1597 1623 # ifdef FORTIFY 1598 // 10 May 08 SHL fixmeto suppress W1111624 // 10 May 08 SHL FIXME to suppress W111 1599 1625 Fortify_EnterScope(); 1600 1626 # endif … … 1603 1629 Runtime_Error(pszSrcFile, __LINE__, NULL); 1604 1630 # ifdef FORTIFY 1605 // 10 May 08 SHL fixmeto suppress W1111631 // 10 May 08 SHL FIXME to suppress W111 1606 1632 Fortify_LeaveScope(); 1607 1633 # endif … … 1648 1674 lenr++; 1649 1675 priority_normal(); 1650 // Clear containers 1676 // Clear containers in case restarting 1651 1677 RemoveCnrItems(hwndRight, NULL, 0, CMA_FREE | CMA_INVALIDATE); 1652 1678 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE); … … 1678 1704 CHAR str[CCHMAXPATH * 2], *p; 1679 1705 CHAR *moder = "r"; 1680 1706 BOOL fFixedSnap = TRUE; 1681 1707 1682 1708 memset(&fb4, 0, sizeof(fb4)); … … 1744 1770 p = strchr(p, ','); 1745 1771 if (p) { 1746 1747 1748 1749 1750 1751 1752 1753 i =(strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 3 - p;1754 1755 for (q = szTemp;q = strchr(szTemp, ',');) {1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 p = strchr(p, '/') ?strchr(p, '/') : strchr(p, DateSeparator[0]);1777 1778 1779 1780 1781 1782 1783 p = strchr(p, '/') ? 1784 1785 1786 1787 1788 1789 1790 1791 1772 p++; 1773 if (((strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - strchr(p, ',')) > 5) { 1774 CHAR szTemp[30]; 1775 CHAR *q; 1776 int i; 1777 1778 memset(szTemp, 0, sizeof(szTemp)); 1779 i = (strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 3 - p; 1780 strncpy(&szTemp, p, i); 1781 for (q = szTemp; q = strchr(szTemp, ',');) { 1782 strcpy(q, q + 1); 1783 } 1784 fb4.cbFile = atoll(szTemp); 1785 fFixedSnap = FALSE; 1786 1787 } 1788 else 1789 fb4.cbFile = atoll(p); 1790 if (!strchr(p, '/')) 1791 fFixedSnap = FALSE; 1792 p = (strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 6; 1793 p = strchr(p, ','); 1794 if (p) { 1795 p++; 1796 if (ulDateFmt == 2 || ulDateFmt == 3 || fFixedSnap) 1797 fb4.fdateLastWrite.year = atol(p) - 1980; 1798 else if (ulDateFmt == 1) 1799 fb4.fdateLastWrite.day = atol(p); 1800 else 1801 fb4.fdateLastWrite.month = atol(p); 1802 p = strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0]); 1803 if (p) { 1804 p++; 1805 if (ulDateFmt == 2 || ulDateFmt == 1 || fFixedSnap) 1806 fb4.fdateLastWrite.month = atol(p); 1807 else 1808 fb4.fdateLastWrite.day = atol(p); 1809 p = strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0]); 1810 if (p) { 1811 p++; 1812 if (ulDateFmt == 2 || fFixedSnap) 1813 fb4.fdateLastWrite.day = atol(p); 1814 else if (ulDateFmt == 3) 1815 fb4.fdateLastWrite.month = atol(p); 1816 else 1817 fb4.fdateLastWrite.year = atol(p) - 1980; 1792 1818 p = strchr(p, ','); 1793 1819 if (p) { 1794 1820 p++; 1795 1821 fb4.ftimeLastWrite.hours = atol(p); 1796 p = strchr(p, ':') ?strchr(p, ':') : strchr(p, TimeSeparator[0]);1797 1822 p = strchr(p, ':') ? strchr(p, ':') : strchr(p, TimeSeparator[0]); 1823 if (p) { 1798 1824 p++; 1799 1825 fb4.ftimeLastWrite.minutes = atol(p); 1800 p = strchr(p, ':') ?strchr(p, ':') : strchr(p, TimeSeparator[0]);1801 1826 p = strchr(p, ':') ? strchr(p, ':') : strchr(p, TimeSeparator[0]); 1827 if (p) { 1802 1828 p++; 1803 1829 fb4.ftimeLastWrite.twosecs = atol(p); 1804 1830 p = strchr(p, ','); 1805 1831 if (p) { 1806 1832 p++; 1807 1833 fb4.attrFile = atol(p); 1808 1834 p = strchr(p, ','); 1809 1835 if (p) { 1810 1836 p++; 1811 1837 fb4.cbList = atol(p) * 2; … … 1813 1839 strupr(str + 1); 1814 1840 else if (fForceLower) 1815 1841 strlwr(str + 1); 1816 1842 if (AddToFileList((str + 1) + lenr, 1817 1843 &fb4, … … 1835 1861 } // while 1836 1862 } // if have rightdir 1837 1838 1839 1863 fclose(fp); 1864 if (!filesr) 1865 saymsg(MB_OK | MB_ICONASTERISK, HWND_DESKTOP, 1840 1866 GetPString(IDS_WARNINGTEXT), 1841 1867 GetPString(IDS_SNAPSHOTFILEBADFORMAT)); 1842 1843 1844 1845 1846 1868 } 1869 else 1870 saymsg(MB_OK | MB_ICONASTERISK, HWND_DESKTOP, 1871 GetPString(IDS_WARNINGTEXT), 1872 GetPString(IDS_SNAPSHOTFILELOADFAILED), cmp->rightlist); 1847 1873 } // if snapshot file 1848 1874 … … 1905 1931 while ((filesl && filesl[l]) || (filesr && filesr[r])) { 1906 1932 1907 ULONG ulRecsToInsert; // limited to USHRT_MAX1933 ULONG ulRecsToInsert; // limited to USHRT_MAX 1908 1934 1909 1935 if (cmp->stop) … … 1971 1997 pcil->pszDispAttr = FileAttrToString(pcil->attrFile); 1972 1998 pcil->cbFile = filesl[l]->cbFile; 1973 // 12 Jan 08 SHL fixmeto use cached size here too1999 // 12 Jan 08 SHL FIXME to use cached size here too 1974 2000 CommaFmtULL(szBuf, sizeof(szBuf), pcil->cbFile, ' '); 1975 2001 pcil->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__); … … 1992 2018 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2; 1993 2019 pcil->crtime.minutes = filesl[l]->crtime.minutes; 1994 1995 2020 pcil->crtime.hours = filesl[l]->crtime.hours; 2021 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1996 2022 if (cmp && *cmp->dcd.mask.szMask) { 1997 2023 if (!Filter((PMINIRECORDCORE)pcil, (PVOID)&cmp->dcd.mask)) { 1998 2024 pcil->rc.flRecordAttr |= CRA_FILTERED; 1999 2025 pcir->rc.flRecordAttr |= CRA_FILTERED; 2000 2001 2002 2026 } 2027 } 2028 DosReleaseMutexSem(hmtxFiltering); 2003 2029 } // if on left 2004 2030 … … 2013 2039 pcir->pszDispAttr = FileAttrToString(pcir->attrFile); 2014 2040 pcir->cbFile = filesr[r]->cbFile; 2015 // 12 Jan 08 SHL fixmeto used cached size here too2041 // 12 Jan 08 SHL FIXME to used cached size here too 2016 2042 CommaFmtULL(szBuf, sizeof(szBuf), pcir->cbFile, ' '); 2017 2043 pcir->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__); … … 2035 2061 pcir->crtime.minutes = filesr[r]->crtime.minutes; 2036 2062 pcir->crtime.hours = filesr[r]->crtime.hours; 2037 2038 2063 // Bypass check if already filtered on left side 2064 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 2039 2065 if (cmp && ~pcir->rc.flRecordAttr & CRA_FILTERED && 2040 2066 *cmp->dcd.mask.szMask) { … … 2042 2068 pcil->rc.flRecordAttr |= CRA_FILTERED; 2043 2069 pcir->rc.flRecordAttr |= CRA_FILTERED; 2044 2045 2046 2070 } 2071 } 2072 DosReleaseMutexSem(hmtxFiltering); 2047 2073 } // if on right 2048 2074 … … 2181 2207 MPFROMP(pcirFirst), MPFROMP(&ri))) { 2182 2208 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD"); 2183 // 2011-05-29 SHL fixme?2209 // 2011-05-29 SHL FIXME? 2184 2210 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE); 2185 2211 FreeCnrItemList(hwndRight, pcirFirst); … … 2318 2344 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), fEnable); 2319 2345 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), fEnable); 2320 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTEAS), fEnable); 2346 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTEAS), fEnable); // 2013-03-09 SHL 2321 2347 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), fEnable); 2322 2348 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), fEnable); … … 2325 2351 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), fEnable); 2326 2352 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), fEnable); 2327 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTEAS), fEnable); 2353 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTEAS), fEnable); // 2013-03-09 SHL 2328 2354 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), fEnable); 2329 2355 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), fEnable); … … 2346 2372 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), fEnable); 2347 2373 WinEnableWindow(WinWindowFromID(hwnd, COMP_HIDENOTSELECTED), fEnable); 2348 WinEnableWindow(WinWindowFromID(hwnd, COMP_CONFIRMACTION), fEnable); 2374 WinEnableWindow(WinWindowFromID(hwnd, COMP_CONFIRMACTION), fEnable); // 2013-03-09 SHL 2349 2375 } 2350 2376 … … 2404 2430 { 2405 2431 USHORT ids[] = {COMP_FRAME, COMP_LEFTDIR, COMP_RIGHTDIR, COMP_COLLECT, 2406 2407 2408 2409 2410 2411 2432 COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT, 2433 COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU, 2434 COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT, 2435 COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT, 2436 COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR, 2437 COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0}; 2412 2438 UINT x; 2413 2439 CHAR s[24]; … … 2569 2595 pci = (PCNRITEM)pcown->pRecord; 2570 2596 // 01 Aug 07 SHL if field null or blank, we draw 2571 // fixmeto document why - probably to optimize and bypass draw?2597 // FIXME to document why - probably to optimize and bypass draw? 2572 2598 if (pci && (INT)pci != -1 && !*pci->pszFileName && pci->pszFileName != NullStr) 2573 2599 return MRFROMLONG(TRUE); … … 2728 2754 if (cmp) { 2729 2755 PCNRITEM pci = (PCNRITEM)mp2; 2730 USHORT id = COMP_CNRMENU; 2756 USHORT id = COMP_CNRMENU; // Assume container menu 2731 2757 2732 2758 if (cmp->dcd.hwndLastMenu) … … 2779 2805 case CN_BEGINEDIT: 2780 2806 case CN_REALLOCPSZ: 2781 // fixmeto be gone - field edits not allowed?2807 // FIXME to be gone - field edits not allowed? 2782 2808 Runtime_Error(pszSrcFile, __LINE__, 2783 2809 "CN_BEGINEDIT/CN_REALLOCPSZ unexpected"); … … 2871 2897 CA_DETAILSVIEWTITLES | CA_OWNERDRAW; 2872 2898 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri), 2873 2899 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR)); 2874 2900 WinSetDlgItemText(hwnd, COMP_LISTLOADED, ""); 2875 2901 cnri.pszCnrTitle = cmp->rightdir; … … 2999 3025 3000 3026 case WM_COMMAND: 3001 // 29 Apr 09 SHL fixmeto support more context menu items - IDM_VIEW, IDM_EDIT etc.3027 // 29 Apr 09 SHL FIXME to support more context menu items - IDM_VIEW, IDM_EDIT etc. 3002 3028 switch (SHORT1FROMMP(mp1)) { 3003 3029 case IDM_COMPARE: … … 3325 3351 ULONG size = sizeof(SWP); 3326 3352 USHORT ids[] = {COMP_FRAME, COMP_LEFTDIR, COMP_RIGHTDIR, COMP_COLLECT, 3327 3328 3329 3330 3331 3332 3353 COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT, 3354 COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU, 3355 COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT, 3356 COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT, 3357 COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR, 3358 COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0}; 3333 3359 UINT x; 3334 3360 CHAR s[24]; 3335 3361 WinQueryWindowPos(hwnd, &swp); 3336 3362 PrfWriteProfileData(fmprof, FM3Str, "CompDir.Position", (PVOID) &swp, 3337 3363 size); 3338 3364 for (x = 0; ids[x]; x++) { 3339 3365 sprintf(s, "CompDir%i", ids[x]); … … 3348 3374 Runtime_Error(pszSrcFile, __LINE__, NULL); 3349 3375 else { 3350 cmp->stop = TRUE; 3376 cmp->stop = TRUE; // In case thread running 3351 3377 if (cmp->filling) 3352 break; 3378 break; // UM_CONTAINER_FILLED will dismiss 3353 3379 } 3354 3380 { … … 3387 3413 case IDM_SELECTSAME: // Name and size 3388 3414 case IDM_INVERT: 3389 3390 3391 3415 cmp = INSTDATA(hwnd); 3392 3416 if (!cmp) … … 3533 3557 cmp = INSTDATA(hwnd); 3534 3558 if (cmp) { 3535 // 17 Jan 08 SHL fixmeto know if stop really needed?3559 // 17 Jan 08 SHL FIXME to know if stop really needed? 3536 3560 WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_COMP_TIMER); 3537 3561 if (cmp->dcd.hwndLastMenu) … … 3547 3571 DosReleaseMutexSem(hmtxFiltering); 3548 3572 } 3573 3574 # ifdef PMPRINTF 3575 PmPrintf_Report(pszSrcFile, __LINE__, "CompareDlgProc EmptyCnr Left"); 3576 # endif 3549 3577 EmptyCnr(GetHwndLeft(hwnd)); 3578 3579 # ifdef PMPRINTF 3580 PmPrintf_Report(pszSrcFile, __LINE__, "CompareDlgProc EmptyCnr Right"); 3581 # endif 3550 3582 EmptyCnr(GetHwndRight(hwnd)); 3583 3551 3584 DosPostEventSem(CompactSem); 3552 3585 break; -
trunk/dll/dircnrs.h
r1871 r1891 6 6 dircnrs common definitions 7 7 8 Copyright (c) 1993- 98 M. Kimes9 Copyright (c) 2001 , 2015Steven H. Levine8 Copyright (c) 1993-1998 M. Kimes 9 Copyright (c) 2001-2020 Steven H. Levine 10 10 11 11 05 Jan 08 SHL Move dircnrs.c definitions here … … 17 17 20 Sep 15 GKY Add a flag to indicate when a directory needed to be Fleshed and a PCNRITEM 18 18 previous to try to keep the pci chain intact on renames, delete etc to PCNRITEM 19 29 Jan 20 SHL Get rid of unused pciPrevious 19 20 20 21 ***********************************************************************/ … … 62 63 ULONG flags; 63 64 BOOL fleshed; 64 struct _CNRITEM *pciPrevious; // Address of pci we are linked to65 65 } 66 66 CNRITEM, *PCNRITEM; … … 168 168 MRESULT EXPENTRY SearchContainer(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); 169 169 170 // 05 Jan 08 SHL fixmefor dircnrs.c globals to be here170 // 05 Jan 08 SHL FIXME for dircnrs.c globals to be here 171 171 172 172 #ifdef DEFINE_GLOBALS -
trunk/dll/errutil.c
r1880 r1891 6 6 Error reporting 7 7 8 Copyright (c) 1993- 98 M. Kimes9 Copyright (c) 2004 , 2015Steven H. Levine8 Copyright (c) 1993-1998 M. Kimes 9 Copyright (c) 2004-2020 Steven H. Levine 10 10 11 11 12 Aug 04 SHL Comments … … 41 41 15 Feb 14 GKY Improvements to saymsg2 some code cleanup 42 42 16 Feb 14 GKY Rework readonly check on delete code so it actually works in a logical way 43 43 and so it works with move to trashcan inabled. 44 44 09 Nov 13 SHL Use GetTidForThread in DbgMsg and tweak for for editors that understand file:line 45 28 Jan 20 SHL Add PmPrintf_Report 45 46 46 47 ***********************************************************************/ … … 66 67 #include "fm3dll2.h" 67 68 69 #ifdef PMPRINTF 70 #define _PMPRINTF_ // Enable debug macros 71 #include "PMPRINTF.H" 72 #endif 73 68 74 #pragma data_seg(DATA1) 69 75 … … 86 92 va_list va; 87 93 88 #if 1 // fixmeto be selectable94 #if 1 // FIXME to be selectable 89 95 90 96 static ULONG ul1stMSec; … … 94 100 95 101 if (!ul1stMSec) { 96 ul1stMSec = msec; 102 ul1stMSec = msec; // Avoid big delta 1st time 97 103 } 98 104 … … 124 130 */ 125 131 126 // 2010-12-01 SHL fixmefor ULONG to be APIRET132 // 2010-12-01 SHL FIXME for ULONG to be APIRET 127 133 128 134 INT Dos_Error(ULONG mb_type, ULONG apiret, HWND hwndOwner, … … 240 246 if (pszBuf[cBufBytes - 1]) { 241 247 fprintf(stderr, "Buffer overflow in formatWinError - need %u bytes\n", 242 248 strlen(pszBuf) + 1); 243 249 fflush(stderr); 244 250 } … … 263 269 if (!hwndOwner) 264 270 hwndOwner = HWND_DESKTOP; 265 // Find message offset in array of message offsets Assume 1 message - fixme?271 // Find message offset in array of message offsets Assume 1 message - FIXME? 266 272 pszOffset = ((PSZ) pErrInfoBlk) + pErrInfoBlk->offaoffszMsg; 267 273 // Address error message in array of messages and append error message to source code linenumber … … 303 309 } 304 310 311 #ifdef PMPRINTF 312 313 /** 314 * Format runtime error message and output using PmPrintf 315 * @note: Local errors written directly to stderr 316 * @note: If pszFmt is NULL a No Data error message is returned GKY 20 Feb 09 (Replaces Runtime_Error2) 317 */ 318 319 VOID PmPrintf_Report(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...) 320 { 321 CHAR szMsg[4096]; 322 va_list va; 323 324 // Format caller's message 325 if (!pszFmt) 326 pszFmt = PCSZ_NODATA; 327 va_start(va, pszFmt); 328 szMsg[sizeof(szMsg) - 1] = 0; 329 vsprintf(szMsg, pszFmt, va); 330 va_end(va); 331 332 if (szMsg[sizeof(szMsg) - 1]) { 333 fprintf(stderr, "Buffer overflow in PmPrintf_Report - need %u bytes\n", strlen(szMsg) + 1); 334 fflush(stderr); 335 } 336 337 if (strchr(szMsg, ' ') == NULL) { 338 strcat(szMsg, " "); 339 strcat(szMsg, GetPString(IDS_FAILEDTEXT)); // Assume simple function name 340 } 341 342 // Avoid leading \n in IDS_GENERR1TEXT 343 strcat(szMsg, " "); 344 sprintf(szMsg + strlen(szMsg), 345 GetPString(IDS_GENERR1TEXT) + 1, pszSrcFile, uSrcLineNo); 346 347 PmPrintfString(szMsg); 348 349 } // PmPrintf_Report 350 351 #endif 352 305 353 /** 306 354 * Format runtime error message and output using showMsg … … 369 417 370 418 APIRET saymsg2(PCSZ pszButtonNames, int DefaultButton, HWND hwnd, 371 419 PCSZ pszTitle, PCSZ pszFmt, ...) 372 420 { 373 421 ULONG i; … … 412 460 rc = WinMessageBox2(HWND_DESKTOP, hwnd, 413 461 szMsg, pszTitle, SM2_DIALOG, 414 462 pmbInfo); 415 463 WinSetFocus(HWND_DESKTOP, SM2_DIALOG); 416 464 free(pmbInfo); … … 460 508 va_start(va, pszFmt); 461 509 formatWinError(szMsg, sizeof(szMsg), hwndErr, hwndOwner, pszSrcFile, 462 510 uSrcLineNo, pszFmt, va); 463 511 va_end(va); 464 512 … … 484 532 va_start(va, pszFmt); 485 533 formatWinError(szMsg, sizeof(szMsg), hwndErr, hwndOwner, pszSrcFile, uSrcLineNo, 486 534 pszFmt, va); 487 535 va_end(va); 488 536 -
trunk/dll/errutil.h
r1686 r1891 6 6 Error reporting utilities interface 7 7 8 Copyright (c) 1993- 98 M. Kimes9 Copyright (c) 2008 , 2010 Steven H. Levine8 Copyright (c) 1993-1998 M. Kimes 9 Copyright (c) 2008-2020 Steven H. Levine 10 10 11 11 05 Jan 08 SHL Move from fm3dll.h to here … … 13 13 08 Mar 09 GKY Remove Dos_Error2 (unused) and Runtime_Error2 (no advantage over using Runtime_Error) 14 14 10 Mar 13 GKY Improvrd readonly check on delete to allow cancel and don't ask again options 15 Added saymsg2 for this purpose 15 Added saymsg2 for this purpose 16 28 Jan 20 SHL Add PmPrintfReport 16 17 17 18 ***********************************************************************/ … … 37 38 PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...); 38 39 40 #ifdef PMPRINTF 41 VOID PmPrintf_Report(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...); 42 #endif 43 39 44 #endif // ERRUTIL_H -
trunk/dll/filldir.c
r1890 r1891 6 6 Fill Directory Tree Containers 7 7 8 Copyright (c) 1993- 98 M. Kimes9 Copyright (c) 2001 , 2015Steven H. Levine8 Copyright (c) 1993-1998 M. Kimes 9 Copyright (c) 2001-2020 Steven H. Levine 10 10 11 11 10 Jan 04 SHL ProcessDirectory: avoid most large drive failures … … 121 121 24 Aug 15 GKY Remove fDummy code 122 122 20 Sep 15 GKY Add code for Flesh to skip the directory entry added by Stubby (eliminate 123 124 123 use of NULL/Nullstr pszFileNames by Stubby). Add code to relink pci chain 124 following rename, delete, etc. Add "Expanding" window text. 125 125 26 Sep 15 GKY Remove fInitialDriveScan code 126 28 Jan 20 SHL EmptyCnr: report more errors 127 29 Jan 20 SHL RemoveCnrItems: rework removal from prev/next chain 126 128 127 129 ***********************************************************************/ … … 168 170 #include "pathutil.h" // AddBackslashToPath 169 171 #include "tmrsvcs.h" // ITIMER_DESC 170 171 #ifdef PMPRINTF172 #define _PMPRINTF_ // Enable debug macros173 #include "PMPRINTF.H"174 #endif175 172 176 173 // Data definitions … … 370 367 ULONG flags = driveflags[toupper(*pci->pszFileName) - 'A']; 371 368 BOOL fLoadSubjectForDrive = fLoadSubject && ~flags & DRIVE_NOLOADSUBJS; 372 BOOL fLoadLongNameForDrive = fLoadLongnames && //~flags & DRIVE_NOLONGNAMES &&369 BOOL fLoadLongNameForDrive = fLoadLongnames && // ~flags & DRIVE_NOLONGNAMES && 373 370 ~flags & DRIVE_NOLOADLONGS; 374 371 if (fLoadSubjectForDrive || fLoadLongNameForDrive) { … … 626 623 pci->rc.hptrIcon = hptr; 627 624 628 629 625 // check to see if record should be visible 630 626 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); … … 821 817 const BOOL recurse, 822 818 const BOOL partial, 823 819 CHAR *stopflag, 824 820 DIRCNRDATA *dcd, // Optional 825 821 ULONG *pulTotalFiles, // Optional 826 827 CHAR *LoadedFirstChild)// Optional822 PULONGLONG pullTotalBytes, // Optional 823 CHAR *LoadedFirstChild) // Optional 828 824 { 829 825 /** … … 899 895 do { 900 896 /** 901 902 897 * remove . and .. and directories already added 898 * by Stubby from list if present 903 899 * also counter file system bugs that sometimes 904 900 * allows normal files to slip through when … … 911 907 pffbFile = paffbFound; 912 908 ulSelCnt = 0; 913 909 for (;;) { 914 910 if (!*pffbFile->achName || 915 911 (!filestoo && ~pffbFile->attrFile & FILE_DIRECTORY) || … … 917 913 !pffbFile->achName[0] || pffbFile->achName[0] == '.' && 918 914 (!pffbFile->achName[1] || 919 920 921 915 (pffbFile->achName[1] == '.' && !pffbFile->achName[2])) || 916 (LoadedFirstChild && !stricmp(LoadedFirstChild, pffbFile->achName)))) { 917 // Got . or .. or file to be skipped 922 918 } 923 919 else … … 957 953 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 958 954 pffbFile, partial, dcd); 959 pciNext = pci; 960 pci = (PCNRITEM) pci->rc.preccNextRecord; 961 if (pci && (INT) pci != -1) 962 pci->pciPrevious = pciNext; 955 pciNext = pci; 956 pci = (PCNRITEM) pci->rc.preccNextRecord; 963 957 ullTotalBytes += ullBytes; 964 958 } // for … … 1058 1052 break; 1059 1053 } 1060 ulRecsToInsert = cAffbTotal - x < USHRT_MAX? cAffbTotal - x : USHRT_MAX;1054 ulRecsToInsert = cAffbTotal - x < USHRT_MAX ? cAffbTotal - x : USHRT_MAX; 1061 1055 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 1062 1056 MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulRecsToInsert)); … … 1071 1065 else { 1072 1066 // 04 Jan 08 SHL FIXME like comp.c to handle less than ulSelCnt records 1073 1074 1075 1076 1077 1067 if (hwndStatus && dcd && dcd->hwndFrame == 1068 WinQueryActiveWindow(dcd->hwndParent)) { 1069 WinSetWindowText(hwndStatus, (CHAR *) GetPString(LoadedFirstChild ? 1070 IDS_PLEASEWAITEXPANDINGTEXT : 1071 IDS_PLEASEWAITCOUNTINGTEXT)); 1078 1072 } 1079 1073 pci = pciFirst; … … 1081 1075 } 1082 1076 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 1083 pffbFile, partial, dcd); 1084 pciNext = pci; 1085 pci = (PCNRITEM) pci->rc.preccNextRecord; 1086 if (pci && (INT) pci != -1) 1087 pci->pciPrevious = pciNext; 1077 pffbFile, partial, dcd); 1078 pciNext = pci; 1079 pci = (PCNRITEM)pci->rc.preccNextRecord; 1088 1080 ullTotalBytes += ullBytes; 1089 1081 // 15 Sep 09 SHL allow timed updates to see … … 1196 1188 } 1197 1189 if ((pci->attrFile & FILE_DIRECTORY)) 1198 1190 AddFleshWorkRequest(hwndCnr, pci, eStubby); 1199 1191 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci), 1200 1192 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); … … 1225 1217 dcd, 1226 1218 NULL, // total files 1227 1228 1219 pullTotalBytes, 1220 0); 1229 1221 DosPostEventSem(CompactSem); 1230 1222 … … 1253 1245 ULONG ulDriveType; 1254 1246 PCNRITEM pci, pciFirst = NULL; 1255 PCNRITEM 1256 PCNRITEM 1247 PCNRITEM pciNext; 1248 PCNRITEM pciParent = NULL; 1257 1249 UINT iDrvNum; 1258 1250 ULONG ulDriveMapMask; … … 1749 1741 } // FillTreeCnr 1750 1742 1751 1752 1743 /** 1753 1744 * Empty all records from a container and free associated storage and … … 1759 1750 PFIELDINFO pfi; 1760 1751 1761 #if 0 // fixmeto be gone or to be configurable1752 #if 0 // FIXME to be gone or to be configurable 1762 1753 { 1763 1754 int state = _heapchk(); … … 1768 1759 1769 1760 // Remove all records 1770 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE); 1761 if (RemoveCnrItems(hwnd, NULL, 0, CMA_FREE)) 1762 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"RemoveCnrItems"); 1771 1763 1772 1764 // Remove field info descriptors … … 1786 1778 VOID FreeCnrItemData(PCNRITEM pci) 1787 1779 { 1788 1789 1780 // 2015-08-23 SHL FIXME debug 1790 1781 if ((pci->pszSubject && (ULONG)pci->pszSubject < 0x10000) || … … 1798 1789 } 1799 1790 1791 # ifdef PMPRINTF 1792 { 1793 PSZ psz = pci->pszFileName; 1794 if (!psz) 1795 psz = "(NULL)"; 1796 else if (psz == NullStr) 1797 psz = "NullStr"; 1798 PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItemData freeing pci %p data for fileName \"%.260s\"", 1799 pci, psz); 1800 } 1801 # endif 1802 1800 1803 if (pci->pszSubject) { 1801 1804 if (pci->pszSubject != NullStr) … … 1823 1826 } 1824 1827 1825 #if 1// 2009-09-26 SHL FIXME debug dup free complaints1828 #if 0 // 2009-09-26 SHL FIXME debug dup free complaints 1826 1829 if (!pci->pszFileName) 1827 1830 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); … … 1832 1835 } 1833 1836 #else 1837 # if 0 // FIXME to be gone 1834 1838 { 1835 // 2015-08-23 SHL FIXME to work again now that Flesh/Stubby on thread 1836 #define HIST_COUNT 50 1839 static BOOL first; 1840 if (!first) { 1841 first=1; 1842 DebugHereIAm(); 1843 } 1844 } 1845 # endif 1846 { 1847 // Add CNRITEM to history list 1848 // 2015-08-23 SHL FIXME to verify OK now that Flesh/Stubby on thread 1849 #define HIST_CNT 5000 1850 static INT volatile iHistLock; // Cheap spin lock 1837 1851 static struct { 1838 1852 PCNRITEM pci; 1839 1853 PSZ pszFileName; 1840 } hist ory[HIST_COUNT];1841 static volatile UINT iHistNdx; 1842 UINT i ;1854 } histList[HIST_CNT]; 1855 static volatile UINT iHistNdx; // Last used 1856 UINT iCurNdx; 1843 1857 1844 1858 if (!pci->pszFileName) { 1845 1859 // Looks like pci was already freed 1846 // Try to locate original file name in history buffer 1847 for (i = 0; i < HIST_COUNT && pci != history[i].pci; i++) { } // Scan 1848 if (i < HIST_COUNT) { 1849 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was %.260s", 1850 pci, history[i].pszFileName); 1860 // Try to locate original file name in history list 1861 for (iCurNdx = 0; iCurNdx < HIST_CNT && pci != histList[iCurNdx].pci; iCurNdx++) { } // Scan 1862 if (iCurNdx < HIST_CNT) { 1863 PSZ psz = histList[iCurNdx].pszFileName; 1864 # ifdef PMPRINTF 1865 PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was \"%.260s\"", 1866 pci, psz == NullStr ? "NullStr" : psz); 1867 # endif 1868 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was \"%.260s\"", 1869 pci, psz == NullStr ? "NullStr" : psz); 1851 1870 } else { 1871 1872 # ifdef PMPRINTF 1873 PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); 1874 # endif 1852 1875 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); 1853 1876 } 1854 1877 } 1855 1878 else { 1879 // Add to history list 1856 1880 PSZ psz; 1857 1881 PSZ *ppsz; 1858 // Grab a history slot1882 static PSZ pszNull = "(NULL)"; 1859 1883 // This should work well enoungh to prevent MT/SMP conflicts 1860 for (;;) { 1861 i = iHistNdx; 1862 if (++i >= HIST_COUNT) 1863 i = 0; 1864 if (++iHistNdx >= HIST_COUNT) 1865 iHistNdx = 0; 1866 if (i == iHistNdx) break; 1867 } 1868 ppsz = &history[iHistNdx].pszFileName; 1884 for (; ++iHistLock > 1; iHistLock--) 1885 DosSleep(0); // Spin if list locked 1886 if (++iHistNdx >= HIST_CNT) 1887 iHistNdx = 0; 1888 ppsz = &histList[iHistNdx].pszFileName; 1869 1889 psz = *ppsz; 1870 if (psz )1890 if (psz && psz != NullStr && psz != pszNull) 1871 1891 free(psz); 1872 if (pci->pszFileName && pci->pszFileName != NullStr) 1873 *ppsz = strdup(pci->pszFileName); 1892 if (pci->pszFileName) { 1893 if (pci->pszFileName != NullStr) 1894 *ppsz = strdup(pci->pszFileName); 1895 else 1896 *ppsz = NullStr; 1897 } 1874 1898 else 1875 *ppsz = NULL; 1876 history[iHistNdx].pci = pci; 1899 *ppsz = pszNull; 1900 histList[iHistNdx].pci = pci; 1901 iHistLock--; 1902 1877 1903 if (pci->pszFileName != NullStr) 1878 1904 free(pci->pszFileName); … … 1902 1928 VOID FreeCnrItem(HWND hwnd, PCNRITEM pci) 1903 1929 { 1930 # ifdef PMPRINTF 1931 PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItem freeing pci %p"); 1932 # endif 1933 1904 1934 FreeCnrItemData(pci); 1905 1935 … … 1949 1979 * Remove item(s) from container and free associated storage if requested 1950 1980 * @param pciFirst points to first item to remove or NULL to remove all 1951 * @param usCnt is remove count or 0 to remove all 1952 * @returns count of items remaining in container or -1 if error 1981 * @param usCnt is 0 to remove all or 1 to remove specific record 1982 * @param usFlags for CM_REMOVERECORD 1983 * @returns count of items remaining to delete or -1 if error 1953 1984 */ 1954 1985 … … 1957 1988 INT remaining = usCnt; 1958 1989 BOOL bIdlePrioritySet = FALSE; 1959 // #define RCI_ITEMS_PER_TIMER_CHECK (10)1960 // 10 seems a very conservative number1961 // USHORT usTimerCheckCountdown = RCI_ITEMS_PER_TIMER_CHECK;1962 1990 PCNRITEM pci; 1963 PCNRITEM pciPrevious;1964 1991 ITIMER_DESC itdSleep = { 0 }; // 30 May 11 GKY 1965 1992 1966 if ((usCnt && !pciFirst) || (!usCnt && pciFirst)) { 1967 Runtime_Error(pszSrcFile, __LINE__, "pciFirst %p usCnt %u mismatch", pciFirst, usCnt); 1993 // Counted remove requires pciFirst and can only remove 1 record 1994 // Remove all does not allow pciFirst 1995 if ((usCnt && !pciFirst) || (usCnt != 1 && pciFirst)) { 1996 Runtime_Error(pszSrcFile, __LINE__, "pciFirst %p usCnt %u mismatch", pciFirst, usCnt); 1997 remaining = -1; 1998 } 1999 else if (!usFlags & CMA_FREE) { 2000 Runtime_Error(pszSrcFile, __LINE__, "usFlags must have CMA_FREE set"); 2001 remaining = -1; 2002 } 2003 else if (!pciFirst) { 2004 // Removing all - query first 2005 pciFirst = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID, 2006 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 2007 if ((INT)pciFirst == -1) { 2008 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD"); 1968 2009 remaining = -1; 1969 } 1970 else { 1971 // Free our buffers if free requested 1972 if (usFlags & CMA_FREE) { 1973 if (pciFirst) 1974 pci = pciFirst; 1975 else { 1976 pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID, 1977 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 1978 if ((INT)pci == -1) { 1979 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD"); 1980 remaining = -1; 1981 pci = NULL; 1982 } 1983 } 1984 InitITimer(&itdSleep, 500); 1985 while (pci) { 1986 FreeCnrItemData(pci); 1987 if (usCnt > 0) 1988 pciPrevious = pci; 1989 pci = (PCNRITEM)pci->rc.preccNextRecord; 1990 if (!pci) 1991 break; 1992 if (usCnt > 0 && pciPrevious && pciPrevious->pciPrevious) { 1993 pciPrevious->pciPrevious->rc.preccNextRecord = (MINIRECORDCORE *) pci; 1994 pci->pciPrevious = pciPrevious->pciPrevious; 1995 pciPrevious->pciPrevious = NULL; 1996 pciPrevious->rc.preccNextRecord = NULL; 1997 } 1998 if (remaining && --remaining == 0) 1999 break; 2000 if (!bIdlePrioritySet) { 2001 bIdlePrioritySet = !IdleIfNeeded(&itdSleep, 30); 2002 } 2003 } // while 2004 if (bIdlePrioritySet) 2005 priority_normal(); 2006 2007 DosPostEventSem(CompactSem); 2008 } 2009 } 2010 if (remaining != - 1) { 2010 } 2011 } 2012 2013 InitITimer(&itdSleep, 500); 2014 2015 # ifdef PMPRINTF 2016 PmPrintf_Report(pszSrcFile, __LINE__, "RemoveCnrItems freeing data pciFirst %p usCnt %d remaining %d", 2017 pciFirst, usCnt, remaining); 2018 # endif 2019 2020 // Free data 2021 // 2020-01-28 SHL Rework to use CMA_NEXT - preccNextRecord method was never reliable 2022 pci = pciFirst; 2023 while (pci && (INT)pci != -1) { 2024 FreeCnrItemData(pci); 2025 if (remaining && --remaining == 0) 2026 break; // pci point to last CNRITEM to be deleted 2027 pci = WinSendMsg(hwnd, CM_QUERYRECORD, MPFROMP(pci), 2028 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 2029 if (!bIdlePrioritySet) 2030 bIdlePrioritySet = !IdleIfNeeded(&itdSleep, 30); 2031 } // while 2032 2033 if (bIdlePrioritySet) 2034 priority_normal(); 2035 2036 DosPostEventSem(CompactSem); 2037 2038 // Free CNRITEM record(s) if OK so far 2039 if (remaining != -1 && pciFirst && (INT)pciFirst != -1) { 2040 # ifdef PMPRINTF 2041 PmPrintf_Report(pszSrcFile, __LINE__, "RemoveCnrItems CM_REMOVERECORD pciFirst %p usCnt %d", pciFirst, usCnt); 2042 # endif 2011 2043 remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&pciFirst), MPFROM2SHORT(usCnt, usFlags)); 2012 if (remaining == -1) {2044 if (remaining == -1) 2013 2045 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pci %p cnt %u", hwnd, pciFirst, usCnt); 2014 } 2046 else if (usCnt == 0 && remaining != 0) 2047 Runtime_Error(pszSrcFile, __LINE__, "%u records remain after CM_REMOVERECORD", remaining); 2015 2048 } 2016 2049 -
trunk/dll/flesh.c
r1890 r1891 6 6 Drive tree container management 7 7 8 Copyright (c) 1993- 98 M. Kimes9 Copyright (c) 2005 , 2015Steven H. Levine8 Copyright (c) 1993-1998 M. Kimes 9 Copyright (c) 2005-2020 Steven H. Levine 10 10 11 11 24 May 05 SHL Rework Win_Error usage … … 38 38 23 Aug 15 GKY Fixed code to notify on drive with no subdirectories in first 64 entries 39 39 20 Sep 15 GKY Add code for Flesh to skip the directory entry added by Stubby (eliminate 40 41 42 40 use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a 41 complete container item. Add a flag to indicate when a directory needed to be 42 Fleshed 43 43 26 Sep 15 GKY Changes to speed up ExpandAll 44 44 26 Sep 15 GKY WaitFleshWorkListEmpty now gives error message and returns if semaphore request 45 45 fails more than 5 consecutive times. 46 46 27 Sep 15 GKY DosSleep times in WaitFleshWorkListEmpty set by caller 47 47 10 Oct 15 GKY Don't use Flesh thread for floppy drive scans fix them getting mistakenly identified 48 as directories and add nonexistent subdirectories. 48 as directories and add nonexistent subdirectories. 49 25 Jan 20 SHL Complain if AddFleshWorkRequest returns empty string 50 27 Jan 20 SHL Avoid more traps if passed bogus pciParent 49 51 50 52 ***********************************************************************/ … … 81 83 82 84 #ifdef PMPRINTF 83 #define 85 #define _PMPRINTF_ // Enable debug macros 84 86 #include "PMPRINTF.H" 85 87 #endif … … 92 94 static INT tidFleshWorkListThread = -1; // 2015-08-08 SHL 93 95 94 static PCSZ pszFleshFocusPath; // 2015-08-20 SHL96 static PCSZ pszFleshFocusPath; // 2015-08-20 SHL 95 97 96 98 #pragma data_seg(GLOBAL1) … … 193 195 ri.cRecordsInsert = 1; 194 196 ri.fInvalidateRecord = FALSE; 195 197 if (!WinSendMsg(hwndCnr, 196 198 CM_INSERTRECORD, MPFROMP(pciL), MPFROMP(&ri))) 197 199 FreeCnrItem(hwndCnr, pciL); … … 223 225 * @param hwnCnr is container to receive CNRITEMs 224 226 * @param pciParent is CNRITEM to have children inserted 225 * @return TRUE if OK, FALSE i serror detected227 * @return TRUE if OK, FALSE if error detected 226 228 */ 227 229 … … 241 243 if (!pciParent->fleshed) { 242 244 pciL = (PCNRITEM)WinSendMsg(hwndCnr, 243 244 245 245 CM_QUERYRECORD, 246 MPFROMP(pciParent), 247 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER)); 246 248 // Added by Stubby to create plus sign run Stubby on it here and skip it in ProcessDirectory 247 249 if (pciL && (INT)pciL != -1) { 248 250 AddFleshWorkRequest(hwndCnr, pciL, eStubby); 249 // 2015-08-06 SHL FIXME to ensure this can not happen 250 if (!*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) 251 Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName (null)", 252 pciL); 251 /* Under some condtions AddFleshWorkRequest will return before pciL is populated 252 2015-08-06 SHL FIXME to ensure pciL->szFileName not empty string 253 2020-01-25 SHL FIXME to ensure pciL->szFileName not null 254 */ 255 if (!pciL->pszFileName || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) 256 DosSleep(250); 257 if (!pciL->pszFileName || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) { 258 Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName %p = %s", 259 pciL, 260 pciL ? pciL->pszFileName : 0, 261 pciL ? pciL->pszFileName ? pciL->pszFileName : "(null)" : "(null)"); 262 return FALSE; 263 } 264 253 265 } 254 266 dcd = INSTDATA(hwndCnr); … … 269 281 dcd, 270 282 NULL, // total files 271 NULL,// total bytes272 283 NULL, // total bytes 284 (pciL && (INT)pciL != -1) ? pciL->pszDisplayName : 0); 273 285 pciParent->fleshed = TRUE; 274 286 return TRUE; … … 296 308 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER)); 297 309 if (!pciL || (INT)pciL == -1) 298 break; 310 break; 299 311 RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE); 300 312 removed = TRUE; … … 305 317 CM_INVALIDATERECORD, 306 318 MPFROMP(&pciParent), 307 319 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION)); 308 320 pciParent->fleshed = FALSE; 309 321 DosSleep(1); // Let container items go away … … 347 359 static BOOL brokenlan = FALSE, isbroken = FALSE; 348 360 349 if (!pciParent || (INT)pciParent == -1 || !*pciParent->pszFileName 350 || pciParent->pszFileName == NullStr || !hwndCnr) 361 // 2020-01-27 SHL FIXME to doc how can get here with unitialized pciParent 362 if (!pciParent || (INT)pciParent == -1|| 363 !pciParent->pszFileName || 364 !*pciParent->pszFileName || 365 pciParent->pszFileName == NullStr || 366 !hwndCnr) { 351 367 return FALSE; 368 } 369 352 370 // Build wildcard 353 371 len = strlen(pciParent->pszFileName); … … 507 525 (pffb->achName[1] != '.' || pffb->achName[2])))) 508 526 { 509 527 // Got directory other than . or .. (or a file) 510 528 isadir = TRUE; 511 529 break; … … 530 548 } 531 549 else { 532 533 534 535 536 537 538 539 540 pci->pszFileName = xstrdup(szBuffer, pszSrcFile, __LINE__);541 542 543 pci->pszDisplayName = p; 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 550 RECORDINSERT ri; 551 CHAR szBuffer[CCHMAXPATH + 14]; 552 CHAR *p; 553 HPOINTER hptr; 554 555 p = strchr(wildcard, '*'); 556 *p = 0;; 557 BldFullPathName(szBuffer, wildcard, pffb->achName); 558 pci->pszFileName = xstrdup(szBuffer, pszSrcFile, __LINE__); 559 p = strrchr(pci->pszFileName, '\\'); 560 p++; 561 pci->pszDisplayName = p; 562 pci->rc.pszIcon = pci->pszDisplayName; 563 if (fForceUpper) 564 strupr(pci->pszFileName); 565 else if (fForceLower) 566 strlwr(pci->pszFileName); 567 568 flags = driveflags[toupper(*pci->pszFileName) - 'A']; 569 570 // get an icon to use with it 571 if (pffb->attrFile & FILE_DIRECTORY) { 572 // is directory 573 if (fNoIconsDirs || 574 (flags & DRIVE_NOLOADICONS) || 575 !isalpha(*pci->pszFileName)) { 576 hptr = (HPOINTER) 0; 577 } 578 else 579 hptr = WinLoadFileIcon(pci->pszFileName, FALSE); 580 } 581 else { 582 // is file 583 if (fNoIconsFiles || 584 (flags & DRIVE_NOLOADICONS) || 585 !isalpha(*pci->pszFileName)) { 586 hptr = (HPOINTER) 0; 587 } 588 else 589 hptr = WinLoadFileIcon(pci->pszFileName, FALSE); 590 591 if (!hptr || IsDefaultIcon(hptr)) 592 hptr = IDFile(pci->pszFileName); 593 } 594 595 if (!hptr) { 596 hptr = pffb->attrFile & FILE_DIRECTORY ? 597 hptrDir : pffb->attrFile & FILE_SYSTEM ? 598 hptrSystem : pffb->attrFile & FILE_HIDDEN ? 599 hptrHidden : pffb->attrFile & FILE_READONLY ? 600 hptrReadonly : hptrFile; 601 } 602 pci->rc.hptrIcon = hptr; 585 603 memset(&ri, 0, sizeof(RECORDINSERT)); 586 604 ri.cb = sizeof(RECORDINSERT); … … 590 608 ri.cRecordsInsert = 1; 591 609 ri.fInvalidateRecord = TRUE; 592 610 if (!WinSendMsg(hwndCnr, 593 611 CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) { 594 612 // Assume busy and try again 595 DosSleep(50); 613 DosSleep(50); 596 614 WinSetFocus(HWND_DESKTOP, hwndCnr); 597 615 if (WinIsWindow((HAB)0, hwndCnr)) { 598 616 if (!WinSendMsg(hwndCnr, 599 617 CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) { … … 602 620 FreeCnrItem(hwndCnr, pci); 603 621 } 604 605 622 else 623 ok = TRUE; 606 624 } 607 625 } … … 652 670 653 671 HMTX hmtxFleshWork; 654 HEV 672 HEV hevFleshWorkListChanged; 655 673 656 674 /** … … 691 709 */ 692 710 693 694 711 BOOL AddFleshWorkRequest(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action) 695 712 { … … 702 719 return FALSE; 703 720 704 705 721 xDosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT); 706 722 … … 749 765 * @parse pszFileName is dependent pathName 750 766 */ 751 752 767 753 768 VOID WaitFleshWorkListEmpty(PCSZ pszDirName, ULONG ulSleep) … … 761 776 INT rcCount = 0; 762 777 763 if (tid == 1 || tid == tidFleshWorkListThread) { // 11 Oct 15 GKY Fixme did we intend to keep this 778 // 11 Oct 15 GKY FIXME did we intend to keep this 779 if (tid == 1 || tid == tidFleshWorkListThread) { 764 780 Runtime_Error(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called by tid %u", tid); 765 return; // Avoid hang781 return; // Avoid hang 766 782 } 767 783 // Can not wait if call from thread 1 or FleshWorkListThread … … 775 791 rc = xDosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT); 776 792 if (rc) { 777 778 779 780 781 782 783 784 793 rcCount++; 794 if (rcCount < 6) 795 continue; // Maybe should return ??? 796 else { 797 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 798 PCSZ_DOSREQUESTMUTEXSEM); 799 return; 800 } 785 801 786 802 } … … 800 816 if (!item) { 801 817 if (waited) 802 818 DosSleep(ulSleep); // Let PM do some work 803 819 break; // Dependents gone from work list 804 820 } … … 871 887 if (!item) { 872 888 xfree((PSZ)pszFleshFocusPath, pszSrcFile, __LINE__); 873 pszFleshFocusPath = NULL; 889 pszFleshFocusPath = NULL; // Revert to normal 874 890 } 875 891 else … … 886 902 // Wait for new items to be added to list 887 903 if (!item) { 888 889 890 891 904 ULONG ul; 905 xDosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT); 906 xDosResetEventSem(hevFleshWorkListChanged, &ul); 907 continue; 892 908 } 893 909 894 910 if (WinIsWindow((HAB)0, item->hwndCnr)) { 895 911 896 912 switch (item->action) { 897 898 913 case eUnFlesh: 914 UnFlesh(item->hwndCnr, item->pci); 899 915 break; 900 916 case eFleshEnv: … … 902 918 break; 903 919 case eStubby: 904 905 906 920 priority_bumped(); 921 Stubby(item->hwndCnr, item->pci); 922 priority_normal(); 907 923 break; 908 924 case eFlesh: … … 915 931 } // switch 916 932 917 918 933 } // if window 919 934 -
trunk/dll/init.c
r1877 r1891 218 218 #include "systemf.h" // runemf2 219 219 220 #if 0221 #define _ _PMPRINTF__220 #ifdef PMPRINTF 221 #define _PMPRINTF_ // Enable debug macros 222 222 #include "PMPRINTF.H" 223 223 #endif … … 748 748 } 749 749 750 #if 0750 #ifdef PMPRINTF 751 751 PmPrintfDisplayInterfaceVersionInfo(); 752 752 PmPrintfQueueNameThisProcess(NULL); … … 940 940 strcpy(inipath, profile); 941 941 } 942 } // fixmethe DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11942 } // FIXME the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11 943 943 if (!*inipath) 944 944 strcpy(inipath, profile); … … 953 953 fWantFirstTimeInit = TRUE; 954 954 } 955 if (!fWantFirstTimeInit) { //Check the ini file header and restore from backup if corupted 955 if (!fWantFirstTimeInit) { 956 // Check the ini file header and restore from backup if corupted 956 957 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) { 957 958 saymsg(MB_ENTER,HWND_DESKTOP, GetPString(IDS_DEBUG_STRING), … … 984 985 } 985 986 986 // 10 Jan 08 SHL fixmeto do first time if new ini987 // 10 Jan 08 SHL FIXME to do first time if new ini 987 988 // 10 Jan 08 SHL post UM_FIRSTTIME to main window 988 989 if (!fmprof) { … … 1225 1226 prntabspaces = 8; 1226 1227 CollectorsortFlags = sortFlags = SORT_FILENAME | SORT_DIRSFIRST; 1227 // Get default Country info1228 // Get default Country info 1228 1229 { 1229 1230 COUNTRYCODE Country = {0}; … … 1261 1262 fLVM = TRUE; 1262 1263 1263 // Check for unlock.exe1264 // Check for unlock.exe 1264 1265 if (!xDosQueryAppType(PCSZ_UNLOCKEXE, &ulAppType)) 1265 1266 fUnlock = TRUE; … … 1324 1325 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1325 1326 if (!editor) 1326 return 0; // already complained1327 return 0; // already complained 1327 1328 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1328 1329 if (!viewer) 1329 return 0; // already complained1330 return 0; // already complained 1330 1331 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1331 1332 if (!virus) 1332 return 0; // already complained1333 return 0; // already complained 1333 1334 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1334 1335 if (!compare) 1335 return 0; // already complained1336 return 0; // already complained 1336 1337 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1337 1338 if (!binview) 1338 return 0; // already complained1339 return 0; // already complained 1339 1340 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1340 1341 if (!bined) 1341 return 0; // already complained1342 return 0; // already complained 1342 1343 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1343 1344 if (!dircompare) 1344 return 0; // already complained1345 return 0; // already complained 1345 1346 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1346 1347 if (!ftprun) 1347 return 0; // already complained1348 return 0; // already complained 1348 1349 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1349 1350 if (!httprun) 1350 return 0; // already complained1351 return 0; // already complained 1351 1352 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1352 1353 if (!mailrun) 1353 return 0; // already complained1354 return 0; // already complained 1354 1355 pszTreeEnvVarList = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 1355 1356 if (!pszTreeEnvVarList) 1356 return 0; // already complained1357 return 0; // already complained 1357 1358 size = sizeof(BOOL); 1358 1359 PrfQueryProfileData(fmprof, FM3Str, "DontSuggestAgain", &fDontSuggestAgain, &size); … … 1803 1804 int ok = 0; 1804 1805 1805 // fixmeto do useful check - was missing in base source1806 // FIXME to do useful check - was missing in base source 1806 1807 1807 1808 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.