Changeset 924 for trunk/dll/comp.c
- Timestamp:
- Jan 17, 2008, 1:40:52 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r919 r924 44 44 05 Jan 08 SHL Use ITIMER_DESC for hogging control 45 45 12 Jan 08 SHL Correct select count display regression 46 12 Jan 08 SHL Localize SpecialSelect here and rename 47 12 Jan 08 SHL Use SleepIfNeeded 48 12 Jan 08 SHL Reduce/eliminate more DosSleep calls 46 49 47 50 ***********************************************************************/ … … 364 367 365 368 case WM_DESTROY: 366 DosSleep(50); // 05 Aug 07 GKY 100369 DosSleep(50); // Let others die first 367 370 break; 368 371 } … … 378 381 HMQ hmq; 379 382 HWND hwndCnrS, hwndCnrD; 380 PCNRITEM pci , pciD, pciNextS, pciNextD;383 PCNRITEM pciS, pciD, pciNextS, pciNextD; 381 384 CHAR szNewName[CCHMAXPATH], szDirName[CCHMAXPATH], *p; 382 385 APIRET rc; 386 ITIMER_DESC itdSleep = { 0 }; 383 387 384 388 if (!cmp) { … … 432 436 } 433 437 434 pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,438 pciS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID, 435 439 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 436 440 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID, … … 438 442 439 443 WinStartTimer(hab, cmp->hwnd, ID_TIMER, 2000); 440 441 while (pci && (INT)pci != -1 && pciD && (INT)pciD != -1) { 442 443 pciNextS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci), 444 InitITimer(&itdSleep, 500); // Sleep every 500 mSec 445 446 while (pciS && (INT)pciS != -1 && pciD && (INT)pciD != -1) { 447 448 pciNextS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pciS), 444 449 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 445 450 pciNextD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD), 446 451 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 447 452 448 if (*pci ->pszFileName && pci->rc.flRecordAttr & CRA_SELECTED) {453 if (*pciS->pszFileName && pciS->rc.flRecordAttr & CRA_SELECTED) { 449 454 450 455 // Source name not blank 451 456 switch (cmp->action) { 452 457 case IDM_DELETE: 453 if (!unlinkf("%s", pci ->pszFileName)) {454 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci ),458 if (!unlinkf("%s", pciS->pszFileName)) { 459 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS), 455 460 MPFROM2SHORT(FALSE, CRA_SELECTED)); 456 461 457 462 if (!*pciD->pszFileName) { 458 463 // Other side is blank - remove from both sides 459 RemoveCnrItems(hwndCnrS, pci , 1, CMA_FREE | CMA_INVALIDATE);464 RemoveCnrItems(hwndCnrS, pciS, 1, CMA_FREE | CMA_INVALIDATE); 460 465 if (pciD->rc.flRecordAttr & CRA_SELECTED) 461 466 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD), … … 465 470 else { 466 471 // Other side is not blank - update just this side 467 FreeCnrItemData(pci );468 pci ->pszDisplayName = pci->pszFileName;469 pci ->rc.pszIcon = pci->pszFileName;470 pci ->flags = 0;471 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci ),472 FreeCnrItemData(pciS); 473 pciS->pszDisplayName = pciS->pszFileName; 474 pciS->rc.pszIcon = pciS->pszFileName; 475 pciS->flags = 0; // Just on one side 476 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 472 477 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 478 pciD->flags = 0; // Just on one side 479 if (pciD->pszSubject != NullStr) { 480 xfree(pciD->pszSubject); 481 pciD->pszSubject = NullStr; 482 } 473 483 } 474 484 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR)) … … 476 486 else 477 487 cmp->cmp->totalright--; 478 DosSleep(0); // 8-26-07 GKY 1488 // DosSleep(0); // 8-26-07 GKY 1 // 12 Jan 08 SHL 479 489 } 480 490 break; … … 482 492 case IDM_MOVE: 483 493 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) 484 BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName); 485 //sprintf(szNewName, "%s%s%s", 486 // cmp->leftdir, 487 // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ? 488 // NullStr : "\\", 489 // pci->pszDisplayName); 494 BldFullPathName(szNewName, cmp->leftdir, pciS->pszDisplayName); 490 495 else 491 BldFullPathName(szNewName, cmp->rightdir, pci->pszDisplayName); 492 //sprintf(szNewName, "%s%s%s", 493 // cmp->rightdir, 494 // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ? 495 // NullStr : "\\", 496 // pci->pszDisplayName); 496 BldFullPathName(szNewName, cmp->rightdir, pciS->pszDisplayName); 497 497 // Make directory if required 498 498 strcpy(szDirName, szNewName); … … 505 505 MassMkdir(hwndMain, szDirName); 506 506 } 507 rc = docopyf(MOVE, pci ->pszFileName, "%s", szNewName);508 if (!rc && stricmp(pci ->pszFileName, szNewName)) {509 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci ),507 rc = docopyf(MOVE, pciS->pszFileName, "%s", szNewName); 508 if (!rc && stricmp(pciS->pszFileName, szNewName)) { 509 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS), 510 510 MPFROM2SHORT(FALSE, CRA_SELECTED)); 511 511 if (pciD->rc.flRecordAttr & CRA_SELECTED) … … 525 525 } 526 526 // 02 Aug 07 SHL fixme to know if LongName transfer is correct? 527 pciD->pszLongName = pci ->pszLongName;527 pciD->pszLongName = pciS->pszLongName; 528 528 if (pciD->pszSubject != NullStr) { 529 529 xfree(pciD->pszSubject); 530 530 pciD->pszSubject = NullStr; 531 531 } 532 pciD->attrFile = pci ->attrFile;533 pciD->pszDispAttr = pci ->pszDispAttr;532 pciD->attrFile = pciS->attrFile; 533 pciD->pszDispAttr = pciS->pszDispAttr; 534 534 pciD->flags = 0; // Just on one side 535 pciD->date = pci ->date;536 pciD->time = pci ->time;537 pciD->ladate = pci ->ladate;538 pciD->latime = pci ->latime;539 pciD->crdate = pci ->crdate;540 pciD->crtime = pci ->crtime;541 pciD->cbFile = pci ->cbFile;542 pciD->easize = pci ->easize;543 544 if (pci ->pszFileName != NullStr) {545 xfree(pci ->pszFileName);546 pci ->pszFileName = NullStr;547 pci ->pszDisplayName = pci->pszFileName;548 pci ->rc.pszIcon = pci->pszFileName;535 pciD->date = pciS->date; 536 pciD->time = pciS->time; 537 pciD->ladate = pciS->ladate; 538 pciD->latime = pciS->latime; 539 pciD->crdate = pciS->crdate; 540 pciD->crtime = pciS->crtime; 541 pciD->cbFile = pciS->cbFile; 542 pciD->easize = pciS->easize; 543 544 if (pciS->pszFileName != NullStr) { 545 xfree(pciS->pszFileName); 546 pciS->pszFileName = NullStr; 547 pciS->pszDisplayName = pciS->pszFileName; 548 pciS->rc.pszIcon = pciS->pszFileName; 549 549 } 550 if (pci ->pszSubject != NullStr) {551 xfree(pci ->pszSubject);552 pci ->pszSubject = NullStr;550 if (pciS->pszSubject != NullStr) { 551 xfree(pciS->pszSubject); 552 pciS->pszSubject = NullStr; 553 553 } 554 pci ->flags = 0;555 556 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci ),554 pciS->flags = 0; // Just on one side 555 556 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 557 557 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 558 558 559 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD), 559 560 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 561 562 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR)) 563 cmp->cmp->totalleft--; 564 else 565 cmp->cmp->totalright--; 560 566 } 561 567 else if (rc) { … … 566 572 __LINE__, 567 573 GetPString(IDS_COMPMOVEFAILEDTEXT), 568 pci ->pszFileName, szNewName);574 pciS->pszFileName, szNewName); 569 575 if (rc == MBID_CANCEL) // Cause loop to break 570 576 pciNextS = NULL; … … 574 580 case IDM_COPY: 575 581 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) 576 BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName); 577 //sprintf(szNewName, "%s%s%s", 578 // cmp->leftdir, 579 // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ? 580 // NullStr : "\\", 581 // pci->pszDisplayName); 582 BldFullPathName(szNewName, cmp->leftdir, pciS->pszDisplayName); 582 583 else 583 BldFullPathName(szNewName, cmp->rightdir, pci->pszDisplayName); 584 //sprintf(szNewName, "%s%s%s", 585 // cmp->rightdir, 586 // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ? 587 // NullStr : "\\", 588 // pci->pszDisplayName); 584 BldFullPathName(szNewName, cmp->rightdir, pciS->pszDisplayName); 589 585 // Make directory if required 590 586 strcpy(szDirName, szNewName); … … 597 593 MassMkdir(hwndMain, szDirName); 598 594 } 599 rc = docopyf(COPY, pci ->pszFileName, "%s", szNewName);595 rc = docopyf(COPY, pciS->pszFileName, "%s", szNewName); 600 596 if (rc) { 601 597 rc = Dos_Error(MB_ENTERCANCEL, … … 605 601 __LINE__, 606 602 GetPString(IDS_COMPCOPYFAILEDTEXT), 607 pci ->pszFileName, szNewName);603 pciS->pszFileName, szNewName); 608 604 if (rc == MBID_CANCEL) 609 605 pciNextS = NULL; // Cause loop to break 610 606 } 611 607 else { 612 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci ),608 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS), 613 609 MPFROM2SHORT(FALSE, CRA_SELECTED)); 614 610 if (pciD->rc.flRecordAttr & CRA_SELECTED) 615 611 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD), 616 612 MPFROM2SHORT(FALSE, CRA_SELECTED)); 613 // 12 Jan 08 SHL 614 if (pciD->pszFileName == NullStr) { 615 if (hwndCnrD == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR)) 616 cmp->totalleft++; 617 else 618 cmp->totalright++; 619 } 617 620 FreeCnrItemData(pciD); 618 621 pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__); … … 627 630 pciD->pszDisplayName++; 628 631 } 629 pciD->attrFile = pci ->attrFile;630 pciD->pszDispAttr = pci ->pszDispAttr;632 pciD->attrFile = pciS->attrFile; 633 pciD->pszDispAttr = pciS->pszDispAttr; 631 634 pciD->flags = CNRITEM_EXISTS; // Now on both sides 632 pciD->date = pci ->date;633 pciD->time = pci ->time;634 pciD->ladate = pci ->ladate;635 pciD->latime = pci ->latime;636 pciD->crdate = pci ->crdate;637 pciD->crtime = pci ->crtime;638 pciD->cbFile = pci ->cbFile;639 pciD->easize = pci ->easize;635 pciD->date = pciS->date; 636 pciD->time = pciS->time; 637 pciD->ladate = pciS->ladate; 638 pciD->latime = pciS->latime; 639 pciD->crdate = pciS->crdate; 640 pciD->crtime = pciS->crtime; 641 pciD->cbFile = pciS->cbFile; 642 pciD->easize = pciS->easize; 640 643 641 644 // Forget status until we regenerate it 642 if (pci ->pszSubject != NullStr) {643 xfree(pci ->pszSubject);644 pci ->pszSubject = NullStr;645 if (pciS->pszSubject != NullStr) { 646 xfree(pciS->pszSubject); 647 pciS->pszSubject = NullStr; 645 648 } 646 pci ->flags = CNRITEM_EXISTS;647 648 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci ),649 pciS->flags = CNRITEM_EXISTS; // Now on both sides 650 651 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS), 649 652 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 650 653 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD), … … 659 662 } // if have name 660 663 661 pci = pciNextS;664 pciS = pciNextS; 662 665 pciD = pciNextD; 663 666 667 SleepIfNeeded(&itdSleep, 0); 664 668 } // while 665 669 Abort: … … 674 678 free(cmp); 675 679 } 680 681 VOID CompSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset); 676 682 677 683 //=== SelectCnrsThread() Update container selection flags thread === … … 710 716 711 717 default: 712 SpecialSelect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR), 713 WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR), 714 cmp->action, cmp->reset); 718 // 13 Jan 08 SHL fixme to decide if cmp->reset can ever get set 719 // if not lots of code can disappear 720 if (cmp->reset) 721 DbgMsg(pszSrcFile, __LINE__, "cmp->reset is TRUE"); 722 CompSelect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR), 723 WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR), 724 cmp->action, cmp->reset); 715 725 break; 716 726 } … … 724 734 } 725 735 free(cmp); 736 } 737 738 /** 739 * Do select actions for compare directories containers 740 * @param action is select mode 741 * @param reset requests flags by regenerated 742 */ 743 744 VOID CompSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset) 745 { 746 PCNRITEM pciS, pciD, *pciSa = NULL, *pciDa = NULL; 747 CNRINFO cnri; 748 BOOL slow = FALSE; 749 UINT x, numD, numS; 750 INT ret = 0; 751 ITIMER_DESC itdSleep = { 0 }; 752 753 if (!hwndCnrS || !hwndCnrD) { 754 Runtime_Error(pszSrcFile, __LINE__, "hwndCnrS %p hwndCnrD %p", hwndCnrS, hwndCnrD); 755 return; 756 } 757 758 memset(&cnri, 0, sizeof(CNRINFO)); 759 cnri.cb = sizeof(CNRINFO); 760 WinSendMsg(hwndCnrD, CM_QUERYCNRINFO, MPFROMP(&cnri), 761 MPFROMLONG(sizeof(CNRINFO))); 762 numD = cnri.cRecords; 763 memset(&cnri, 0, sizeof(CNRINFO)); 764 cnri.cb = sizeof(CNRINFO); 765 WinSendMsg(hwndCnrS, CM_QUERYCNRINFO, MPFROMP(&cnri), 766 MPFROMLONG(sizeof(CNRINFO))); 767 numS = cnri.cRecords; 768 if (!numD || numS != numD) { 769 Runtime_Error(pszSrcFile, __LINE__, "numD %u != numS %u", numD, numS); 770 return; 771 } 772 773 pciDa = xmalloc(sizeof(PCNRITEM) * numD, pszSrcFile, __LINE__); 774 if (!pciDa) 775 return; 776 777 pciSa = xmalloc(sizeof(PCNRITEM) * numS, pszSrcFile, __LINE__); 778 if (!pciSa) { 779 free(pciDa); 780 return; 781 } 782 783 InitITimer(&itdSleep, 500); // Sleep every 500 mSec 784 785 Restart: 786 787 memset(pciDa, 0, sizeof(PCNRITEM) * numD); 788 memset(pciSa, 0, sizeof(PCNRITEM) * numS); 789 790 pciD = (PCNRITEM)WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID, 791 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 792 x = 0; 793 while (pciD && (INT)pciD != -1 && x < numD) { 794 if (reset) 795 pciD->flags = 0; 796 pciDa[x] = pciD; 797 x++; 798 if (!slow) 799 pciD = (PCNRITEM) pciD->rc.preccNextRecord; 800 else 801 pciD = (PCNRITEM) WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD), 802 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 803 SleepIfNeeded(&itdSleep, 0); 804 } // while 805 806 if (numD != x) { 807 // Something out of sync - fixme to document why 808 if (!slow) { 809 slow = TRUE; 810 goto Restart; 811 } 812 free(pciDa); 813 free(pciSa); 814 Runtime_Error(pszSrcFile, __LINE__, "numD %u != x %lu", numD, x); 815 return; 816 } 817 818 pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID, 819 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 820 x = 0; 821 while (pciS && (INT)pciS != -1 && x < numS) { 822 if (reset) 823 pciS->flags = 0; 824 pciSa[x] = pciS; 825 x++; 826 if (!slow) 827 pciS = (PCNRITEM) pciS->rc.preccNextRecord; 828 else 829 pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pciS), 830 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 831 SleepIfNeeded(&itdSleep, 0); 832 } // while 833 834 if (numS != x) { 835 if (!slow) { 836 slow = TRUE; 837 goto Restart; 838 } 839 free(pciSa); 840 free(pciDa); 841 Runtime_Error(pszSrcFile, __LINE__, "numS (%lu) != x (%lu)", numS, x); 842 return; 843 } 844 845 if (reset) { 846 // Update flags for files that exist on both sides 847 for (x = 0; x < numS; x++) { 848 849 if (!*pciSa[x]->pszFileName || !*pciDa[x]->pszFileName) { 850 // 12 Jan 08 SHL clear flags 851 pciSa[x]->flags = 0; // File exists on one side only 852 pciDa[x]->flags = 0; 853 continue; 854 } 855 856 pciSa[x]->flags |= CNRITEM_EXISTS; // File exists on both sides 857 pciDa[x]->flags |= CNRITEM_EXISTS; 858 if (pciSa[x]->cbFile + pciSa[x]->easize > 859 pciDa[x]->cbFile + pciDa[x]->easize) { 860 pciSa[x]->flags |= CNRITEM_LARGER; 861 pciDa[x]->flags |= CNRITEM_SMALLER; 862 } 863 else if (pciSa[x]->cbFile + pciSa[x]->easize < 864 pciDa[x]->cbFile + pciDa[x]->easize) { 865 pciSa[x]->flags |= CNRITEM_SMALLER; 866 pciDa[x]->flags |= CNRITEM_LARGER; 867 } 868 ret = TestCDates(&pciDa[x]->date, &pciDa[x]->time, 869 &pciSa[x]->date, &pciSa[x]->time); 870 if (ret == 1) 871 /* 13 Jan 08 SHL fixme to be gone? 872 ((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE : 873 (pciSa[x]->date.year < pciDa[x]->date.year) ? FALSE : 874 (pciSa[x]->date.month > pciDa[x]->date.month) ? TRUE : 875 (pciSa[x]->date.month < pciDa[x]->date.month) ? FALSE : 876 (pciSa[x]->date.day > pciDa[x]->date.day) ? TRUE : 877 (pciSa[x]->date.day < pciDa[x]->date.day) ? FALSE : 878 (pciSa[x]->time.hours > pciDa[x]->time.hours) ? TRUE : 879 (pciSa[x]->time.hours < pciDa[x]->time.hours) ? FALSE : 880 (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? TRUE : 881 (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? FALSE : 882 (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? TRUE : 883 (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? FALSE : FALSE) 884 */ 885 { 886 pciSa[x]->flags |= CNRITEM_NEWER; 887 pciDa[x]->flags |= CNRITEM_OLDER; 888 } 889 else if (ret == -1) 890 /* 13 Jan 08 SHL fixme to be gone? 891 ((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE : 892 (pciSa[x]->date.year > pciDa[x]->date.year) ? FALSE : 893 (pciSa[x]->date.month < pciDa[x]->date.month) ? TRUE : 894 (pciSa[x]->date.month > pciDa[x]->date.month) ? FALSE : 895 (pciSa[x]->date.day < pciDa[x]->date.day) ? TRUE : 896 (pciSa[x]->date.day > pciDa[x]->date.day) ? FALSE : 897 (pciSa[x]->time.hours < pciDa[x]->time.hours) ? TRUE : 898 (pciSa[x]->time.hours > pciDa[x]->time.hours) ? FALSE : 899 (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? TRUE : 900 (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? FALSE : 901 (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? TRUE : 902 (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? FALSE : 903 FALSE) 904 */ 905 { 906 pciSa[x]->flags |= CNRITEM_OLDER; 907 pciDa[x]->flags |= CNRITEM_NEWER; 908 } 909 SleepIfNeeded(&itdSleep, 0); 910 } // for 911 } // if reset 912 913 switch (action) { 914 case IDM_SELECTIDENTICAL: 915 for (x = 0; x < numS; x++) { 916 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED && 917 pciSa[x]->flags & CNRITEM_EXISTS && 918 ~pciSa[x]->flags & CNRITEM_SMALLER && 919 ~pciSa[x]->flags & CNRITEM_LARGER && 920 ~pciSa[x]->flags & CNRITEM_NEWER && 921 ~pciSa[x]->flags & CNRITEM_OLDER) { 922 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 923 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 924 MPFROM2SHORT(TRUE, CRA_SELECTED)); 925 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 926 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 927 MPFROM2SHORT(TRUE, CRA_SELECTED)); 928 } 929 SleepIfNeeded(&itdSleep, 0); 930 } // for 931 break; 932 933 case IDM_SELECTSAME: 934 for (x = 0; x < numS; x++) { 935 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED && 936 pciSa[x]->flags & CNRITEM_EXISTS && 937 ~pciSa[x]->flags & CNRITEM_SMALLER && 938 ~pciSa[x]->flags & CNRITEM_LARGER) { 939 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 940 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 941 MPFROM2SHORT(TRUE, CRA_SELECTED)); 942 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 943 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 944 MPFROM2SHORT(TRUE, CRA_SELECTED)); 945 } 946 SleepIfNeeded(&itdSleep, 0); 947 } // for 948 break; 949 950 case IDM_SELECTSAMECONTENT: 951 for (x = 0; x < numS; x++) { 952 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED && 953 pciSa[x]->flags & CNRITEM_EXISTS) 954 { 955 FILE *fp1 = NULL; 956 FILE *fp2 = NULL; 957 BOOL gotMatch = FALSE; 958 UINT errLineNo = 0; 959 UINT compErrno = 0; 960 CHAR buf1[1024]; 961 CHAR buf2[1024]; 962 HAB hab = WinQueryAnchorBlock(hwndCnrS); 963 964 if (!*pciSa[x]->pszFileName || 965 !*pciDa[x]->pszFileName) { 966 Runtime_Error(pszSrcFile, __LINE__, 967 "CNRITEM_EXISTS set with null file name for index %u", x); 968 break; 969 } 970 971 fp1 = _fsopen(pciSa[x]->pszFileName, "rb", SH_DENYNO); 972 if (!fp1) { 973 errLineNo = __LINE__; 974 compErrno = errno; 975 } 976 else { 977 fp2 = _fsopen(pciDa[x]->pszFileName, "rb", SH_DENYNO); 978 if (!fp2) { 979 errLineNo = __LINE__; 980 compErrno = errno; 981 } 982 else { 983 size_t len1 = filelength(fileno(fp1)); 984 size_t len2 = filelength(fileno(fp2)); 985 986 if (len1 == len2) { 987 setbuf(fp1, NULL); 988 setbuf(fp2, NULL); 989 while (WinIsWindow(hab, hwndCnrS)) { 990 size_t numread1 = fread(buf1, 1, 1024, fp1); 991 size_t numread2 = fread(buf2, 1, 1024, fp2); 992 993 if (!numread1 || !numread2 || numread1 != numread2) { 994 if (ferror(fp1) || ferror(fp2)) { 995 errLineNo = __LINE__; 996 compErrno = errno; 997 } 998 else if (feof(fp1) && feof(fp2)) 999 gotMatch = TRUE; 1000 break; 1001 } 1002 else if (memcmp(buf1, buf2, numread1)) 1003 break; 1004 } // while 1005 } // same len 1006 } 1007 } 1008 1009 if (fp1) 1010 fclose(fp1); 1011 1012 if (fp2) 1013 fclose(fp2); 1014 1015 if (errLineNo) { 1016 Runtime_Error(pszSrcFile, errLineNo, 1017 "error %d while comparing", compErrno); 1018 } 1019 1020 if (gotMatch) { 1021 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1022 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1023 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1024 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1025 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1026 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1027 } 1028 } 1029 SleepIfNeeded(&itdSleep, 0); 1030 } // for 1031 break; 1032 1033 case IDM_SELECTBOTH: 1034 for (x = 0; x < numS; x++) { 1035 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED && 1036 pciSa[x]->flags & CNRITEM_EXISTS) { 1037 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1038 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1039 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1040 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1041 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1042 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1043 } 1044 SleepIfNeeded(&itdSleep, 0); 1045 } // for 1046 break; 1047 1048 case IDM_SELECTONE: 1049 for (x = 0; x < numS; x++) { 1050 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED && 1051 ~pciSa[x]->flags & CNRITEM_EXISTS) { 1052 if (*pciSa[x]->pszFileName) { 1053 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) { 1054 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1055 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1056 } 1057 } 1058 else if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) { 1059 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1060 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1061 } 1062 } 1063 SleepIfNeeded(&itdSleep, 0); 1064 } // for 1065 break; 1066 1067 case IDM_SELECTBIGGER: 1068 for (x = 0; x < numS; x++) { 1069 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1070 if (pciSa[x]->flags & CNRITEM_LARGER) { 1071 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1072 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1073 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1074 } 1075 else if (pciDa[x]->flags & CNRITEM_LARGER) { 1076 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1077 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1078 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1079 } 1080 } 1081 SleepIfNeeded(&itdSleep, 0); 1082 } // for 1083 break; 1084 1085 case IDM_SELECTSMALLER: 1086 for (x = 0; x < numS; x++) { 1087 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1088 if (pciSa[x]->flags & CNRITEM_SMALLER) { 1089 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1090 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1091 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1092 } 1093 else if (pciDa[x]->flags & CNRITEM_SMALLER) { 1094 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1095 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1096 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1097 } 1098 } 1099 SleepIfNeeded(&itdSleep, 0); 1100 } // for 1101 break; 1102 1103 case IDM_SELECTNEWER: 1104 for (x = 0; x < numS; x++) { 1105 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1106 if (pciSa[x]->flags & CNRITEM_NEWER) { 1107 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1108 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1109 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1110 } 1111 else if (pciDa[x]->flags & CNRITEM_NEWER) { 1112 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1113 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1114 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1115 } 1116 } 1117 SleepIfNeeded(&itdSleep, 0); 1118 } // for 1119 break; 1120 1121 case IDM_SELECTOLDER: 1122 for (x = 0; x < numS; x++) { 1123 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1124 if (pciSa[x]->flags & CNRITEM_OLDER) { 1125 if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1126 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1127 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1128 } 1129 else if (pciDa[x]->flags & CNRITEM_OLDER) { 1130 if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1131 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1132 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1133 } 1134 } 1135 SleepIfNeeded(&itdSleep, 0); 1136 } // for 1137 break; 1138 1139 case IDM_DESELECTBOTH: 1140 for (x = 0; x < numS; x++) { 1141 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED && 1142 pciSa[x]->flags & CNRITEM_EXISTS) { 1143 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1144 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1145 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1146 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1147 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1148 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1149 } 1150 SleepIfNeeded(&itdSleep, 0); 1151 } // for 1152 break; 1153 1154 case IDM_DESELECTONE: 1155 for (x = 0; x < numS; x++) { 1156 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1157 if (~pciSa[x]->flags & CNRITEM_EXISTS) { 1158 if (*pciSa[x]->pszFileName) { 1159 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1160 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1161 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1162 } 1163 else if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1164 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1165 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1166 } 1167 } 1168 SleepIfNeeded(&itdSleep, 0); 1169 } // for 1170 break; 1171 1172 case IDM_DESELECTBIGGER: 1173 for (x = 0; x < numS; x++) { 1174 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1175 if (pciSa[x]->flags & CNRITEM_LARGER) { 1176 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1177 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1178 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1179 } 1180 else if (pciDa[x]->flags & CNRITEM_LARGER) { 1181 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1182 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1183 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1184 } 1185 } 1186 SleepIfNeeded(&itdSleep, 0); 1187 } // for 1188 break; 1189 1190 case IDM_DESELECTSMALLER: 1191 for (x = 0; x < numS; x++) { 1192 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1193 if (pciSa[x]->flags & CNRITEM_SMALLER) { 1194 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1195 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1196 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1197 } 1198 else if (pciDa[x]->flags & CNRITEM_SMALLER) { 1199 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1200 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1201 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1202 } 1203 } 1204 SleepIfNeeded(&itdSleep, 0); 1205 } // for 1206 break; 1207 1208 case IDM_DESELECTNEWER: 1209 for (x = 0; x < numS; x++) { 1210 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1211 if (pciSa[x]->flags & CNRITEM_NEWER) { 1212 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1213 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1214 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1215 } 1216 else if (pciDa[x]->flags & CNRITEM_NEWER) { 1217 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1218 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1219 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1220 } 1221 } 1222 SleepIfNeeded(&itdSleep, 0); 1223 } // for 1224 break; 1225 1226 case IDM_DESELECTOLDER: 1227 for (x = 0; x < numS; x++) { 1228 if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) { 1229 if (pciSa[x]->flags & CNRITEM_OLDER) { 1230 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1231 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]), 1232 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1233 } 1234 else if (pciDa[x]->flags & CNRITEM_OLDER) { 1235 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1236 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]), 1237 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1238 } 1239 } 1240 SleepIfNeeded(&itdSleep, 0); 1241 } // for 1242 break; 1243 1244 default: 1245 break; 1246 } 1247 1248 if (reset) { 1249 while (numS) { 1250 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, 1251 MPFROMP(pciSa), MPFROM2SHORT((min(numS, 65535)), 0)); 1252 // DosSleep(0); //Let screen update // 12 Jan 08 SHL 1253 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, 1254 MPFROMP(pciDa), MPFROM2SHORT((min(numD, 65535)), 0)); 1255 numS -= min(numS, 65535); 1256 // if (numS) // 12 Jan 08 SHL 1257 // DosSleep(0); //26 Aug 07 GKY 1 1258 SleepIfNeeded(&itdSleep, 0); // 12 Jan 08 SHL 1259 } // while 1260 } 1261 1262 free(pciSa); 1263 free(pciDa); 1264 DosPostEventSem(CompactSem); 726 1265 } 727 1266 … … 829 1368 } 830 1369 831 //=== CompNames() Compare names for qsort === 1370 /** 1371 * Compare names for qsort 1372 */ 832 1373 833 1374 static int CompNames(const void *n1, const void *n2) … … 1275 1816 &pcil->date, &pcil->time); 1276 1817 if (ret == 1) 1277 /*((pcil->date.year > pcir->date.year) ? TRUE : 1818 /* 13 Jan 08 SHL fixme to be gone 1819 ((pcil->date.year > pcir->date.year) ? TRUE : 1278 1820 (pcil->date.year < pcir->date.year) ? FALSE : 1279 1821 (pcil->date.month > pcir->date.month) ? TRUE : … … 1286 1828 (pcil->time.minutes < pcir->time.minutes) ? FALSE : 1287 1829 (pcil->time.seconds > pcir->time.seconds) ? TRUE : 1288 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE)*/ { 1830 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) 1831 */ 1832 { 1289 1833 pcil->flags |= CNRITEM_NEWER; 1290 1834 pcir->flags |= CNRITEM_OLDER; … … 1297 1841 } 1298 1842 else if (ret == -1) 1299 /*((pcil->date.year < pcir->date.year) ? TRUE : 1300 (pcil->date.year > pcir->date.year) ? FALSE : 1301 (pcil->date.month < pcir->date.month) ? TRUE : 1302 (pcil->date.month > pcir->date.month) ? FALSE : 1303 (pcil->date.day < pcir->date.day) ? TRUE : 1304 (pcil->date.day > pcir->date.day) ? FALSE : 1305 (pcil->time.hours < pcir->time.hours) ? TRUE : 1306 (pcil->time.hours > pcir->time.hours) ? FALSE : 1307 (pcil->time.minutes < pcir->time.minutes) ? TRUE : 1308 (pcil->time.minutes > pcir->time.minutes) ? FALSE : 1309 (pcil->time.seconds < pcir->time.seconds) ? TRUE : 1310 (pcil->time.seconds > pcir->time.seconds) ? FALSE : 1311 FALSE)*/ { 1843 /* 13 Jan 08 SHL fixme to be gone 1844 ((pcil->date.year < pcir->date.year) ? TRUE : 1845 (pcil->date.year > pcir->date.year) ? FALSE : 1846 (pcil->date.month < pcir->date.month) ? TRUE : 1847 (pcil->date.month > pcir->date.month) ? FALSE : 1848 (pcil->date.day < pcir->date.day) ? TRUE : 1849 (pcil->date.day > pcir->date.day) ? FALSE : 1850 (pcil->time.hours < pcir->time.hours) ? TRUE : 1851 (pcil->time.hours > pcir->time.hours) ? FALSE : 1852 (pcil->time.minutes < pcir->time.minutes) ? TRUE : 1853 (pcil->time.minutes > pcir->time.minutes) ? FALSE : 1854 (pcil->time.seconds < pcir->time.seconds) ? TRUE : 1855 (pcil->time.seconds > pcir->time.seconds) ? FALSE : 1856 FALSE) 1857 */ 1858 { 1312 1859 pcil->flags |= CNRITEM_OLDER; 1313 1860 pcir->flags |= CNRITEM_NEWER; … … 1515 2062 }; 1516 2063 UINT x; 1517 for (x = 0; ids[x]; x++) 2064 for (x = 0; ids[x]; x++) { 1518 2065 SetPresParams(WinWindowFromID(hwnd, ids[x]), 1519 2066 &RGBGREY, 1520 2067 &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT)); 2068 } 1521 2069 } 1522 2070 } … … 1714 2262 } 1715 2263 else { 1716 1717 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED enter");1718 1719 2264 cmp->filling = FALSE; 1720 2265 WinEnableWindow(hwndLeft, TRUE); … … 1772 2317 else 1773 2318 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT)); 1774 1775 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED exit");1776 1777 2319 } 1778 2320 break; … … 2549 3091 TileChildren(cmp->hwndParent, TRUE); 2550 3092 } 2551 DosSleep(32); // 05 Aug 07 GKY 64 3093 // DosSleep(32); // 05 Aug 07 GKY 64 3094 DosSleep(1); // 12 Jan 08 SHL Let screen update 2552 3095 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID); 2553 3096 break; … … 2620 3163 #pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread) 2621 3164 #pragma alloc_text(SNAPSHOT,SnapShot,StartSnap) 2622 3165 #pragma alloc_text(COMPSELECT,CompSelect) 3166
Note:
See TracChangeset
for help on using the changeset viewer.