Changeset 1683 for trunk/dll/comp.c
- Timestamp:
- Mar 7, 2013, 3:23:34 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r1682 r1683 7 7 8 8 Copyright (c) 1993-02 M. Kimes 9 Copyright (c) 2003, 201 2Steven H. Levine9 Copyright (c) 2003, 2013 Steven H. Levine 10 10 11 11 16 Oct 02 MK Baseline … … 86 86 06 Jan 13 GKY Added optional confirmation dialogs for delete move and copy to compare dir Ticket 277 87 87 06 Jan 13 GKY Added EA compare option to compare dir Ticket 80 88 06 Mar 13 SHL ActionCnrThread: need to strdup pszFmtFileSize to avoid aliased pointers 88 89 89 90 ***********************************************************************/ … … 242 243 fp = xfopen(sf->filename, modew, pszSrcFile, __LINE__, FALSE); 243 244 if (fp) { 244 245 245 fprintf(fp, "\"%s\"\n", sf->dirname); 246 //DbgMsg(pszSrcFile, __LINE__, "recurse %i", sf->recurse); 246 247 SnapShot(sf->dirname, fp, sf->recurse); 247 248 fclose(fp); … … 479 480 strcpy(mv.target, NewName); 480 481 rc = WinDlgBox(HWND_DESKTOP, 481 482 483 482 hwnd, 483 RenameProc, 484 FM3ModHandle, REN_FRAME, (PVOID) & mv); 484 485 if (!rc) 485 486 return 1; … … 568 569 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 569 570 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID, 570 571 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 571 572 fConfirmAction = WinQueryButtonCheckstate(cmp->hwnd, COMP_CONFIRMACTION); 572 573 InitITimer(&itdSleep, 500); // Sleep every 500 mSec … … 589 590 // Source name not blank 590 591 switch (cmp->action) { 591 592 593 594 595 596 MB2INFO *pmbInfo; 597 598 599 600 601 602 603 604 605 606 607 pmbInfo->cb = ulInfoSize; 608 609 pmbInfo->cButtons = NUM_BUT; 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 592 case IDM_DELETE: 593 594 if (fConfirmAction && !dontask) { 595 ULONG i; 596 CHAR s[CCHMAXPATH + 20]; 597 MB2INFO *pmbInfo; 598 MB2D mb2dBut[NUM_BUT] = //fixme to use GetPString 599 { 600 { "Yes", 1, 0}, 601 { "Yes don't ask again", 2, 1}, 602 { "No", 3, 2}, 603 { "Cancel delete operation", 4, 3} 604 }; 605 ULONG ulInfoSize = (sizeof(MB2INFO) + (sizeof(MB2D) * (NUM_BUT-1))); 606 pmbInfo = malloc (ulInfoSize); 607 if (pmbInfo) { 608 pmbInfo->cb = ulInfoSize; 609 pmbInfo->hIcon = 0; 610 pmbInfo->cButtons = NUM_BUT; 611 pmbInfo->flStyle = MB_MOVEABLE; 612 pmbInfo->hwndNotify = NULLHANDLE; 613 for (i = 0; i < NUM_BUT; i++) { 614 memcpy( pmbInfo->mb2d+i , mb2dBut+i , sizeof(MB2D)); 615 } //fixme to use GetPString 616 sprintf(s, "Do you wish to delete %s", pciS->pszFileName); 617 rc = WinMessageBox2(HWND_DESKTOP, cmp->hwnd, 618 s, "Confirm Delete", 1234, 619 pmbInfo); 620 free(pmbInfo); 621 if (rc == 2 || rc == 3) { 622 if (rc == 3) 623 enddelete = TRUE; 624 break; 625 } 626 else if (rc == 1) 627 dontask = TRUE; 628 } 629 } 629 630 if (!unlinkf(pciS->pszFileName)) { 630 631 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS), … … 685 686 MassMkdir(hwndMain, szDirName); 686 687 } 687 688 689 690 691 692 693 688 if (fConfirmAction && pciS->flags & CNRITEM_EXISTS && !dontask) { 689 rc = ConfirmAction(cmp->hwnd, pciS->pszFileName, szNewName); 690 if (rc == 1) 691 break; 692 else if (rc == 2) 693 dontask = TRUE; 694 } 694 695 rc = docopyf(MOVE, pciS->pszFileName, szNewName); 695 696 if (fResetVerify) { … … 730 731 pciD->crdate = pciS->crdate; 731 732 pciD->crtime = pciS->crtime; 732 pciD->pszFmtFileSize = pciS->pszFmtFileSize; 733 // 2013-03-06 SHL 734 if (pciS->pszFmtFileSize == NullStr) 735 pciD->pszFmtFileSize = pciS->pszFmtFileSize; 736 else 737 pciD->pszFmtFileSize = strdup(pciS->pszFmtFileSize); 733 738 pciD->cbFile = pciS->cbFile; 734 739 pciD->easize = pciS->easize; … … 793 798 if (IsFile(szDirName) == -1) 794 799 MassMkdir(hwndMain, szDirName); 795 796 797 798 799 800 801 802 803 800 } 801 if (fConfirmAction && pciS->flags & CNRITEM_EXISTS && !dontask) { 802 rc = ConfirmAction(cmp->hwnd, pciS->pszFileName, szNewName); 803 if (rc == 1) 804 break; 805 else if (rc == 2) 806 dontask = TRUE; 807 } 808 rc = docopyf(COPY, pciS->pszFileName, szNewName); 804 809 if (fResetVerify) { 805 810 DosSetVerify(fVerify); … … 849 854 pciD->latime = pciS->latime; 850 855 pciD->crdate = pciS->crdate; 851 pciD->crtime = pciS->crtime; 852 pciD->pszFmtFileSize = pciS->pszFmtFileSize; 856 pciD->crtime = pciS->crtime; 857 // 2013-03-06 SHL 858 if (pciS->pszFmtFileSize == NullStr) 859 pciD->pszFmtFileSize = pciS->pszFmtFileSize; 860 else 861 pciD->pszFmtFileSize = strdup(pciS->pszFmtFileSize); 853 862 pciD->cbFile = pciS->cbFile; 854 863 pciD->easize = pciS->easize; … … 874 883 875 884 } // if have name 876 877 885 if (enddelete) 886 break; 878 887 pciS = pciNextS; 879 888 pciD = pciNextD; … … 1132 1141 ~pciS->flags & CNRITEM_LARGER && 1133 1142 ~pciS->flags & CNRITEM_NEWER && 1134 1135 1143 ~pciS->flags & CNRITEM_OLDER && 1144 ~pciS->flags & CNRITEM_EASDIFFER; 1136 1145 CompSelectSetSelects(pciS, pciDa[x], matched, matched, wantAnd); 1137 1146 } … … 1148 1157 ~pciS->flags & CNRITEM_SMALLER && 1149 1158 ~pciS->flags & CNRITEM_LARGER && 1150 1159 ~pciS->flags & CNRITEM_EASDIFFER; 1151 1160 CompSelectSetSelects(pciS, pciDa[x], matched, matched, wantAnd); 1152 1161 } … … 1323 1332 if (~pciS->rc.flRecordAttr & CRA_FILTERED) { 1324 1333 pciD = pciDa[x]; 1325 1326 1327 1328 1329 1334 CompSelectSetSelects(pciS, 1335 pciD, 1336 pciS->flags & CNRITEM_EASDIFFER, 1337 pciD->flags & CNRITEM_EASDIFFER, 1338 wantAnd); 1330 1339 } 1331 1340 SleepIfNeeded(&itdSleep, 0); … … 1683 1692 strupr(cmp->rightdir); 1684 1693 FillDirList(cmp->rightdir, lenr, cmp->includesubdirs, 1685 1694 &filesr, &cmp->cmp->totalright, &numallocr); 1686 1695 } 1687 1696 else { … … 1690 1699 FILEFINDBUF4L fb4; 1691 1700 CHAR str[CCHMAXPATH * 2], *p; 1692 1701 CHAR *moder = "r"; 1693 1702 1694 1703 memset(&fb4, 0, sizeof(fb4)); 1695 1704 fp = xfopen(cmp->rightlist, moder, pszSrcFile, __LINE__, FALSE); 1696 1705 if (fp) { 1697 1706 while (!feof(fp)) { 1698 1707 // First get name of directory … … 1724 1733 1725 1734 memset(&cnri, 0, sizeof(cnri)); 1726 1727 1735 cnri.cb = sizeof(cnri); 1736 WinSetDlgItemText(cmp->hwnd, COMP_LISTLOADED, "List File Loaded"); 1728 1737 cnri.pszCnrTitle = cmp->rightdir; 1729 1738 if (!WinSendMsg(hwndRight, CM_SETCNRINFO, 1730 1739 MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE))) { 1731 1732 1740 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_SETCNRINFO"); 1741 WinSetDlgItemText(cmp->hwnd, COMP_LISTLOADED, ""); 1733 1742 } 1734 1743 … … 1736 1745 lenr = strlen(cmp->rightdir); 1737 1746 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\') 1738 1739 1740 1747 lenr++; 1748 //DbgMsg(pszSrcFile, __LINE__, "end of file %i", feof(fp)); 1749 while (!feof(fp)) { 1741 1750 if (!xfgets_bstripcr 1742 1743 1744 1751 (str, sizeof(str), fp, pszSrcFile, __LINE__)) { 1752 break; 1753 } 1745 1754 p = str; 1746 1755 if (*p == '\"') { … … 1748 1757 if (*p && *p != '\"') { 1749 1758 p = strchr(p, '\"'); 1750 1759 if (p) { 1751 1760 *p = 0; 1752 1761 p++; 1753 1762 if (*p == ',') { 1754 1763 p++; 1755 1764 if (!cmp->includesubdirs && atol(p) > lenr) 1756 1765 continue; 1757 1766 p = strchr(p, ','); 1758 1767 if (p) { 1759 1768 p++; 1760 1769 fb4.cbFile = atoll(p); 1761 1770 p = strchr(p, ','); 1762 1763 1764 1765 1766 1767 1768 1769 1771 if (p) { 1772 p++; 1773 if (ulDateFmt == 2 || ulDateFmt == 3) 1774 fb4.fdateLastWrite.year = atol(p) - 1980; 1775 else if (ulDateFmt == 1) 1776 fb4.fdateLastWrite.day = atol(p); 1777 else 1778 fb4.fdateLastWrite.month = atol(p); 1770 1779 p = strchr(p, DateSeparator[0]); 1771 1772 1773 1774 1775 1776 1780 if (p) { 1781 p++; 1782 if (ulDateFmt == 2 || ulDateFmt == 3) 1783 fb4.fdateLastWrite.month = atol(p); 1784 else 1785 fb4.fdateLastWrite.day = atol(p); 1777 1786 p = strchr(p, DateSeparator[0]); 1778 1779 1780 1781 1782 1783 1784 1785 1787 if (p) { 1788 p++; 1789 if (ulDateFmt == 2) 1790 fb4.fdateLastWrite.day = atol(p); 1791 else if (ulDateFmt == 3) 1792 fb4.fdateLastWrite.month = atol(p); 1793 else 1794 fb4.fdateLastWrite.year = atol(p) - 1980; 1786 1795 p = strchr(p, ','); 1787 1796 if (p) { 1788 1797 p++; 1789 1798 fb4.ftimeLastWrite.hours = atol(p); 1790 1791 1799 p = strchr(p, TimeSeparator[0]); 1800 if (p) { 1792 1801 p++; 1793 1802 fb4.ftimeLastWrite.minutes = atol(p); 1794 1803 p = strchr(p, TimeSeparator[0]); 1795 1804 if (p) { 1796 1805 p++; 1797 1806 fb4.ftimeLastWrite.twosecs = atol(p); 1798 1807 p = strchr(p, ','); 1799 1808 if (p) { 1800 1809 p++; 1801 1810 fb4.attrFile = atol(p); 1802 1811 p = strchr(p, ','); 1803 1812 if (p) { 1804 1813 p++; 1805 1814 fb4.cbList = atol(p) * 2; … … 1807 1816 strupr(str + 1); 1808 1817 else if (fForceLower) 1809 1818 strlwr(str + 1); 1810 1819 if (AddToFileList((str + 1) + lenr, 1811 1820 &fb4, … … 1829 1838 } // while 1830 1839 } // if have rightdir 1831 1832 1840 fclose(fp); 1841 } 1833 1842 } // if snapshot file 1834 1843 1835 1844 if (filesr) 1836 1845 qsort(filesr, cmp->cmp->totalright, sizeof(CHAR *), CompNames); 1837 1846 1838 1847 // We now have two lists of files, both sorted. … … 2048 2057 strcpy(pch, GetPString(IDS_SMALLERTEXT)); 2049 2058 pch += 7; 2050 2051 2052 2053 2054 2059 } 2060 if (pcil->easize != pcir->easize) { 2061 pcil->flags |= CNRITEM_EASDIFFER; 2062 pcir->flags |= CNRITEM_EASDIFFER; 2063 if (pch != szBuf) { 2055 2064 strcpy(pch, ", "); 2056 2065 pch += 2; 2057 2066 } 2058 2067 strcpy(pch, GetPString(IDS_EASDIFFERTEXT)); 2059 2060 2068 pch += 10; 2069 } 2061 2070 ret = TestCDates(&pcir->date, &pcir->time, 2062 2071 &pcil->date, &pcil->time); … … 2369 2378 SetCnrCols(GetHwndRight(hwnd), TRUE); 2370 2379 if (cmp->listfile) { 2371 2380 CHAR fullname[CCHMAXPATH]; 2372 2381 2373 2382 strcpy(fullname, PCSZ_STARDOTPMD); 2374 2383 if (insert_filename(HWND_DESKTOP, fullname, TRUE, FALSE) && 2375 2384 *fullname && !strchr(fullname, '*') && !strchr(fullname, '?')) 2376 2385 strcpy(cmp->rightlist, fullname); 2377 2386 } 2378 2387 WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID); … … 2380 2389 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID); 2381 2390 { 2382 2383 2384 2385 2386 2387 2388 2391 USHORT ids[] = {COMP_FRAME, COMP_LEFTDIR, COMP_RIGHTDIR, COMP_COLLECT, 2392 COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT, 2393 COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU, 2394 COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT, 2395 COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT, 2396 COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR, 2397 COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0}; 2389 2398 UINT x; 2390 2399 CHAR s[24]; 2391 2400 2392 2401 for (x = 0; ids[x]; x++) { 2393 2394 2402 sprintf(s, "CompDir%i", ids[x]); 2403 RestorePresParams(WinWindowFromID(hwnd, ids[x]), s); 2395 2404 } 2396 2405 } … … 2840 2849 CNRINFO cnri; 2841 2850 if (cmp->includesubdirs) 2842 2851 WinCheckButton(hwnd, COMP_INCLUDESUBDIRS, TRUE); 2843 2852 cmp->includesubdirs = WinQueryButtonCheckstate(hwnd, 2844 2853 COMP_INCLUDESUBDIRS); 2845 2854 memset(&cnri, 0, sizeof(CNRINFO)); 2846 2855 cnri.cb = sizeof(CNRINFO); … … 2850 2859 CA_DETAILSVIEWTITLES | CA_OWNERDRAW; 2851 2860 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri), 2852 2861 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR)); 2853 2862 WinSetDlgItemText(hwnd, COMP_LISTLOADED, ""); 2854 2863 cnri.pszCnrTitle = cmp->rightdir; … … 2881 2890 WinSetDlgItemText(hwnd, COMP_NOTE, 2882 2891 (CHAR *) GetPString(IDS_COMPHOLDREADDISKTEXT)); 2883 2884 2892 SetButtonEnables(cmp, FALSE); 2893 cmp->includesubdirs = FALSE; 2885 2894 cmp->selleft = 0; 2886 2895 cmp->selright = 0; … … 3193 3202 strcpy(sf->dirname, cmp->leftdir); 3194 3203 else 3195 3196 3197 3204 strcpy(sf->dirname, cmp->rightdir); 3205 sf->recurse = WinQueryButtonCheckstate(hwnd, COMP_INCLUDESUBDIRS); 3206 //DbgMsg(pszSrcFile, __LINE__, "recurse %i %i", sf->recurse, cmp->includesubdirs); 3198 3207 if (xbeginthread(StartSnapThread, 3199 3208 65536, … … 3216 3225 wa.size = sizeof(wa); 3217 3226 strcpy(wa.szCurrentPath1, cmp->leftdir); 3218 3219 3220 3227 strcpy(wa.szCurrentPath2, cmp->rightdir); 3228 wa.includesubdirs = WinQueryButtonCheckstate(hwnd, 3229 COMP_INCLUDESUBDIRS); 3221 3230 if (WinDlgBox(HWND_DESKTOP, 3222 3231 hwnd, … … 3228 3237 !IsFile(wa.szCurrentPath2)) { 3229 3238 strcpy(cmp->leftdir, wa.szCurrentPath1); 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3239 strcpy(cmp->rightdir, wa.szCurrentPath2); 3240 cmp->includesubdirs = wa.includesubdirs; 3241 if (!cmp->includesubdirs) 3242 WinCheckButton(hwnd, COMP_INCLUDESUBDIRS, FALSE); 3243 cmp->listfile = wa.listfile; 3244 if (cmp->listfile) { 3245 CHAR fullname[CCHMAXPATH]; 3246 3247 strcpy(fullname, PCSZ_STARDOTPMD); 3248 if (insert_filename(HWND_DESKTOP, fullname, TRUE, FALSE) && 3249 *fullname && !strchr(fullname, '*') && !strchr(fullname, '?')) 3250 strcpy(cmp->rightlist, fullname); 3251 } 3252 else 3253 *cmp->rightlist = 0; 3245 3254 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); 3246 3255 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID); … … 3305 3314 SWP swp; 3306 3315 ULONG size = sizeof(SWP); 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 USHORT ids[] = {COMP_FRAME, COMP_LEFTDIR, COMP_RIGHTDIR, COMP_COLLECT, 3317 COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT, 3318 COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU, 3319 COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT, 3320 COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT, 3321 COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR, 3322 COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0}; 3323 UINT x; 3324 CHAR s[24]; 3316 3325 WinQueryWindowPos(hwnd, &swp); 3317 3326 PrfWriteProfileData(fmprof, FM3Str, "CompDir.Position", (PVOID) &swp, 3318 3327 size); 3319 3328 for (x = 0; ids[x]; x++) { 3320 3321 3322 3329 sprintf(s, "CompDir%i", ids[x]); 3330 SavePresParams(WinWindowFromID(hwnd, ids[x]), s); 3331 } 3323 3332 } 3324 3333 WinDismissDlg(hwnd, 0); … … 3368 3377 case IDM_SELECTSAME: // Name and size 3369 3378 case IDM_INVERT: 3370 3379 3371 3380 3372 3381 cmp = INSTDATA(hwnd);
Note:
See TracChangeset
for help on using the changeset viewer.