Changeset 1682 for trunk/dll/comp.c
- Timestamp:
- Jan 7, 2013, 1:36:38 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r1681 r1682 84 84 05 Jan 13 GKY Toggle of include subdirectories leaves snapshot file loaded. 85 85 05 Jan 13 GKY Added an indicator (textbox) that a list (snapshot) file is loaded. 86 06 Jan 13 GKY Added optional confirmation dialogs for delete move and copy to compare dir Ticket 277 87 06 Jan 13 GKY Added EA compare option to compare dir Ticket 80 86 88 87 89 ***********************************************************************/ … … 142 144 #include "excputil.h" // xbeginthread 143 145 #include "info.h" // driveflags 146 #include "worker.h" // MOVEIT 147 #include "rename.h" // RenameProc 144 148 145 149 typedef struct … … 167 171 HDIR hdir = HDIR_CREATE; 168 172 ULONG ulFindCnt; 169 CHAR sz CmmaFmtFileSize[81], szDate[DATE_BUF_BYTES];170 171 // 13 Aug 07 SHL fi mxe to use FileToGet173 CHAR szDate[DATE_BUF_BYTES]; 174 175 // 13 Aug 07 SHL fixme to use FileToGet 172 176 pffb = xmalloc(sizeof(FILEFINDBUF4L), pszSrcFile, __LINE__); 173 177 if (pffb) { … … 188 192 strcpy(enddir, pffb->achName); 189 193 if (!(pffb->attrFile & FILE_DIRECTORY)) { 190 ulltoa(pffb->cbFile, szCmmaFmtFileSize, 10);191 194 FDateFormat(szDate, pffb->fdateLastWrite); 192 195 fprintf(fp, 193 "\"%s\",%u,% s,%s,%02u%s%02u%s%02u,%lu,%lu,N\n",196 "\"%s\",%u,%llu,%s,%02u%s%02u%s%02u,%lu,%lu,N\n", 194 197 mask, 195 198 enddir - mask, 196 szCmmaFmtFileSize,199 pffb->cbFile, 197 200 szDate, 198 201 pffb->ftimeLastWrite.hours, … … 459 462 return WinDefDlgProc(hwnd, msg, mp1, mp2); 460 463 } 461 464 int ConfirmAction(HWND hwnd, CHAR *OldName, CHAR *NewName); 465 466 /** 467 * ConfirmAction provides an optional confirmation dialog 468 * for move and copy operations. 469 */ 470 int ConfirmAction(HWND hwnd, CHAR *OldName, CHAR *NewName) 471 { 472 MOVEIT mv; 473 int rc; 474 475 memset(&mv, 0, sizeof(MOVEIT)); 476 mv.rename = FALSE; 477 mv.source = OldName; 478 mv.compare = TRUE; 479 strcpy(mv.target, NewName); 480 rc = WinDlgBox(HWND_DESKTOP, 481 hwnd, 482 RenameProc, 483 FM3ModHandle, REN_FRAME, (PVOID) & mv); 484 if (!rc) 485 return 1; 486 487 DosSleep(1); 488 if (mv.skip || !*mv.target) 489 return 1; 490 if (mv.dontask) 491 return 2; 492 return 0; 493 } 494 495 #define NUM_BUT 4 462 496 /** 463 497 * Action Thread 464 498 * Do requested action on container contents 465 499 */ 466 467 500 static VOID ActionCnrThread(VOID *args) 468 501 { … … 475 508 APIRET rc; 476 509 ITIMER_DESC itdSleep = { 0 }; 510 BOOL fConfirmAction = FALSE; 511 BOOL dontask = FALSE; 512 BOOL enddelete = FALSE; 477 513 478 514 if (!cmp) { … … 532 568 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 533 569 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID, 534 535 570 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 571 fConfirmAction = WinQueryButtonCheckstate(cmp->hwnd, COMP_CONFIRMACTION); 536 572 InitITimer(&itdSleep, 500); // Sleep every 500 mSec 537 573 … … 553 589 // Source name not blank 554 590 switch (cmp->action) { 555 case IDM_DELETE: 591 case IDM_DELETE: 592 593 if (fConfirmAction && !dontask) { 594 ULONG i; 595 CHAR s[CCHMAXPATH + 20]; 596 MB2INFO *pmbInfo; 597 MB2D mb2dBut[NUM_BUT] = //fixme to use GetPString 598 { 599 { "Yes", 1, 0}, 600 { "Yes don't ask again", 2, 1}, 601 { "No", 3, 2}, 602 { "Cancel delete operation", 4, 3} 603 }; 604 ULONG ulInfoSize = (sizeof(MB2INFO) + (sizeof(MB2D) * (NUM_BUT-1))); 605 pmbInfo = malloc (ulInfoSize); 606 if (pmbInfo) { 607 pmbInfo->cb = ulInfoSize; 608 pmbInfo->hIcon = 0; 609 pmbInfo->cButtons = NUM_BUT; 610 pmbInfo->flStyle = MB_MOVEABLE; 611 pmbInfo->hwndNotify = NULLHANDLE; 612 for (i = 0; i < NUM_BUT; i++) { 613 memcpy( pmbInfo->mb2d+i , mb2dBut+i , sizeof(MB2D)); 614 } //fixme to use GetPString 615 sprintf(s, "Do you wish to delete %s", pciS->pszFileName); 616 rc = WinMessageBox2(HWND_DESKTOP, cmp->hwnd, 617 s, "Confirm Delete", 1234, 618 pmbInfo); 619 free(pmbInfo); 620 if (rc == 2 || rc == 3) { 621 if (rc == 3) 622 enddelete = TRUE; 623 break; 624 } 625 else if (rc == 1) 626 dontask = TRUE; 627 } 628 } 556 629 if (!unlinkf(pciS->pszFileName)) { 557 630 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS), … … 612 685 MassMkdir(hwndMain, szDirName); 613 686 } 687 if (fConfirmAction && pciS->flags & CNRITEM_EXISTS && !dontask) { 688 rc = ConfirmAction(cmp->hwnd, pciS->pszFileName, szNewName); 689 if (rc == 1) 690 break; 691 else if (rc == 2) 692 dontask = TRUE; 693 } 614 694 rc = docopyf(MOVE, pciS->pszFileName, szNewName); 615 695 if (fResetVerify) { … … 713 793 if (IsFile(szDirName) == -1) 714 794 MassMkdir(hwndMain, szDirName); 715 } 716 rc = docopyf(COPY, pciS->pszFileName, szNewName); 795 } 796 if (fConfirmAction && pciS->flags & CNRITEM_EXISTS && !dontask) { 797 rc = ConfirmAction(cmp->hwnd, pciS->pszFileName, szNewName); 798 if (rc == 1) 799 break; 800 else if (rc == 2) 801 dontask = TRUE; 802 } 803 rc = docopyf(COPY, pciS->pszFileName, szNewName); 717 804 if (fResetVerify) { 718 805 DosSetVerify(fVerify); … … 787 874 788 875 } // if have name 789 876 if (enddelete) 877 break; 790 878 pciS = pciNextS; 791 879 pciD = pciNextD; … … 1036 1124 switch (action) { 1037 1125 case IDM_SELECTIDENTICAL: 1038 // Same Date/size 1126 // Same Date/size including EAs 1039 1127 for (x = 0; x < numS; x++) { 1040 1128 pciS = pciSa[x]; … … 1044 1132 ~pciS->flags & CNRITEM_LARGER && 1045 1133 ~pciS->flags & CNRITEM_NEWER && 1046 ~pciS->flags & CNRITEM_OLDER; 1134 ~pciS->flags & CNRITEM_OLDER && 1135 ~pciS->flags & CNRITEM_EASDIFFER; 1047 1136 CompSelectSetSelects(pciS, pciDa[x], matched, matched, wantAnd); 1048 1137 } … … 1052 1141 1053 1142 case IDM_SELECTSAME: 1054 // Same Size 1143 // Same Size including EAs 1055 1144 for (x = 0; x < numS; x++) { 1056 1145 pciS = pciSa[x]; … … 1058 1147 matched = pciS->flags & CNRITEM_EXISTS && 1059 1148 ~pciS->flags & CNRITEM_SMALLER && 1060 ~pciS->flags & CNRITEM_LARGER; 1149 ~pciS->flags & CNRITEM_LARGER && 1150 ~pciS->flags & CNRITEM_EASDIFFER; 1061 1151 CompSelectSetSelects(pciS, pciDa[x], matched, matched, wantAnd); 1062 1152 } … … 1228 1318 break; 1229 1319 1320 case IDM_SELECTEAS: 1321 for (x = 0; x < numS; x++) { 1322 pciS = pciSa[x]; 1323 if (~pciS->rc.flRecordAttr & CRA_FILTERED) { 1324 pciD = pciDa[x]; 1325 CompSelectSetSelects(pciS, 1326 pciD, 1327 pciS->flags & CNRITEM_EASDIFFER, 1328 pciD->flags & CNRITEM_EASDIFFER, 1329 wantAnd); 1330 } 1331 SleepIfNeeded(&itdSleep, 0); 1332 } // for 1333 break; 1334 1230 1335 case IDM_DESELECTBOTH: 1231 1336 for (x = 0; x < numS; x++) { … … 1313 1418 pciS->flags & CNRITEM_OLDER, 1314 1419 pciD->flags & CNRITEM_OLDER)) { 1420 fUpdateHideButton = TRUE; 1421 } 1422 } 1423 SleepIfNeeded(&itdSleep, 0); 1424 } // for 1425 break; 1426 1427 case IDM_DESELECTEAS: 1428 for (x = 0; x < numS; x++) { 1429 pciS = pciSa[x]; 1430 if (~pciS->rc.flRecordAttr & CRA_FILTERED) { 1431 pciD = pciDa[x]; 1432 if (CompSelectClearSelects(pciS, 1433 pciD, 1434 pciS->flags & CNRITEM_EASDIFFER, 1435 pciD->flags & CNRITEM_EASDIFFER)) { 1315 1436 fUpdateHideButton = TRUE; 1316 1437 } … … 1643 1764 if (ulDateFmt == 2 || ulDateFmt == 3) 1644 1765 fb4.fdateLastWrite.year = atol(p) - 1980; 1645 if (ulDateFmt == 1)1766 else if (ulDateFmt == 1) 1646 1767 fb4.fdateLastWrite.day = atol(p); 1647 1768 else … … 1659 1780 if (ulDateFmt == 2) 1660 1781 fb4.fdateLastWrite.day = atol(p); 1661 if (ulDateFmt == 3)1782 else if (ulDateFmt == 3) 1662 1783 fb4.fdateLastWrite.month = atol(p); 1663 1784 else … … 1778 1899 if (!pcil || !pcir) { 1779 1900 if (pcil != pcir) { 1780 // 2011-05-29 SHL fixme to GetPString 1781 Runtime_Error(pszSrcFile, __LINE__, "pcil and pcir out of sync"); 1901 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_LEFTRIGHTOUTOFSYNC)); 1782 1902 cmp->stop = TRUE; 1783 1903 break; … … 1917 2037 // Subject field holds status messages 1918 2038 *pch = 0; 1919 if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) {2039 if (pcil->cbFile > pcir->cbFile) { 1920 2040 pcil->flags |= CNRITEM_LARGER; 1921 2041 pcir->flags |= CNRITEM_SMALLER; … … 1923 2043 pch += 6; 1924 2044 } 1925 else if (pcil->cbFile + pcil->easize < 1926 pcir->cbFile + pcir->easize) { 2045 else if (pcil->cbFile < pcir->cbFile) { 1927 2046 pcil->flags |= CNRITEM_SMALLER; 1928 2047 pcir->flags |= CNRITEM_LARGER; 1929 2048 strcpy(pch, GetPString(IDS_SMALLERTEXT)); 1930 2049 pch += 7; 1931 } 2050 } 2051 if (pcil->easize != pcir->easize) { 2052 pcil->flags |= CNRITEM_EASDIFFER; 2053 pcir->flags |= CNRITEM_EASDIFFER; 2054 if (pch != szBuf) { 2055 strcpy(pch, ", "); 2056 pch += 2; 2057 } 2058 strcpy(pch, GetPString(IDS_EASDIFFERTEXT)); 2059 pch += 10; 2060 } 1932 2061 ret = TestCDates(&pcir->date, &pcir->time, 1933 2062 &pcil->date, &pcil->time); … … 2186 2315 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), fEnable); 2187 2316 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), fEnable); 2188 if (!fEnable || !*cmp->rightlist 2317 if (!fEnable || !*cmp->rightlist) { 2189 2318 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), fEnable); 2190 2319 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), fEnable); … … 2838 2967 MPFROMP(&cmp->dcd.mask)); 2839 2968 } 2840 // cmp->dcd.suspendview = 0; // 12 Jan 08 SHL appears not to be used here2841 2969 if (*cmp->dcd.mask.szMask) { 2842 2970 sprintf(s, … … 3066 3194 else 3067 3195 strcpy(sf->dirname, cmp->rightdir); 3068 cmp->includesubdirs = WinQueryButtonCheckstate(hwnd, 3069 COMP_INCLUDESUBDIRS); 3070 sf->recurse = cmp->includesubdirs; 3196 sf->recurse = WinQueryButtonCheckstate(hwnd, COMP_INCLUDESUBDIRS); 3071 3197 //DbgMsg(pszSrcFile, __LINE__, "recurse %i %i", sf->recurse, cmp->includesubdirs); 3072 3198 if (xbeginthread(StartSnapThread, … … 3192 3318 size); 3193 3319 for (x = 0; ids[x]; x++) { 3194 //fixme to allow user to change presparams 1-10-09 GKY3195 3320 sprintf(s, "CompDir%i", ids[x]); 3196 3321 SavePresParams(WinWindowFromID(hwnd, ids[x]), s); … … 3229 3354 case IDM_SELECTBIGGER: 3230 3355 case IDM_SELECTSMALLER: 3356 case IDM_SELECTEAS: 3231 3357 case IDM_DESELECTNEWER: 3232 3358 case IDM_DESELECTOLDER: … … 3235 3361 case IDM_DESELECTONE: 3236 3362 case IDM_DESELECTBOTH: 3363 case IDM_DESELECTEAS: 3237 3364 case IDM_SELECTBOTH: 3238 3365 case IDM_SELECTONE: … … 3241 3368 case IDM_SELECTSAME: // Name and size 3242 3369 case IDM_INVERT: 3370 3371 3243 3372 cmp = INSTDATA(hwnd); 3244 3373 if (!cmp)
Note:
See TracChangeset
for help on using the changeset viewer.