Changeset 748 for trunk/dll/comp.c
- Timestamp:
- Aug 2, 2007, 7:09:27 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r746 r748 25 25 22 Mar 07 GKY Use QWL_USER 26 26 29 Jul 07 SHL Use Win_Error to report container errors 27 01 Aug 07 SHL Rework to sync with CNRITEM mods 28 01 Aug 07 SHL Rework to remove vast amount of duplicate code 27 29 28 30 ***********************************************************************/ … … 353 355 HMQ hmq; 354 356 HWND hwndCnrS, hwndCnrD; 355 PCNRITEM pci, pci O, pcin, pciOn;357 PCNRITEM pci, pciD, pciNextS, pciNextD; 356 358 CHAR newname[CCHMAXPATH], dirname[CCHMAXPATH], *p; 357 359 APIRET rc; 358 360 359 if (!cmp) 361 if (!cmp) { 362 Runtime_Error(pszSrcFile, __LINE__, "no data"); 360 363 return; 364 } 361 365 362 366 DosError(FERR_DISABLEHARDERR); … … 407 411 pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID, 408 412 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 409 pci O= WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,413 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID, 410 414 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 411 while (pci && (INT) pci != -1 && pciO && (INT) pciO != -1) { 412 413 pcin = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci), 415 416 while (pci && (INT)pci != -1 && pciD && (INT)pciD != -1) { 417 418 pciNextS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci), 414 419 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 415 pci On = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciO),420 pciNextD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD), 416 421 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 417 if (*pci->pszFileName && (pci->rc.flRecordAttr & CRA_SELECTED)) { 422 423 if (*pci->pszFileName && pci->rc.flRecordAttr & CRA_SELECTED) { 424 425 // Source name not blank 418 426 switch (cmp->action) { 419 427 case IDM_DELETE: … … 421 429 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci), 422 430 MPFROM2SHORT(FALSE, CRA_SELECTED)); 423 if (!*pciO->pszFileName) { 431 432 if (!*pciD->pszFileName) { 433 // Other side is blank 424 434 WinSendMsg(hwndCnrS, CM_REMOVERECORD, MPFROMP(&pci), 425 435 MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE)); 426 if (pci O->rc.flRecordAttr & CRA_SELECTED)427 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pci O),436 if (pciD->rc.flRecordAttr & CRA_SELECTED) 437 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD), 428 438 MPFROM2SHORT(FALSE, CRA_SELECTED)); 429 WinSendMsg(hwndCnrD, CM_REMOVERECORD, MPFROMP(&pci O),439 WinSendMsg(hwndCnrD, CM_REMOVERECORD, MPFROMP(&pciD), 430 440 MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE)); 431 441 } 432 442 else { 433 pci->pszFileName = xstrdup(NullStr, pszSrcFile, __LINE__);434 //pci->pszFileName = pci->szFileName;443 // Other side is not blank 444 FreeCnrItemData(pci); 435 445 pci->flags = 0; 436 446 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci), … … 441 451 else 442 452 cmp->cmp->totalright--; 443 DosSleep( 0L);453 DosSleep(1); 444 454 } 445 455 break; … … 454 464 cmp->rightdir[strlen(cmp->rightdir) - 1] == 455 465 '\\' ? NullStr : "\\", pci->pszFileName); 456 / * make directory if required */466 // Make directory if required 457 467 strcpy(dirname, newname); 458 468 p = strrchr(dirname, '\\'); … … 468 478 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci), 469 479 MPFROM2SHORT(FALSE, CRA_SELECTED)); 470 if (pci O->rc.flRecordAttr & CRA_SELECTED)471 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pci O),480 if (pciD->rc.flRecordAttr & CRA_SELECTED) 481 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD), 472 482 MPFROM2SHORT(FALSE, CRA_SELECTED)); 473 pciO->pszFileName = xstrdup(newname, pszSrcFile, __LINE__); 483 FreeCnrItemData(pciD); 484 pciD->pszFileName = xstrdup(newname, pszSrcFile, __LINE__); 474 485 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) { 475 pci O->pszDisplayName = pciO->pszFileName + strlen(cmp->leftdir);486 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir); 476 487 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\') 477 pci O->pszFileName++;488 pciD->pszFileName++; 478 489 } 479 490 else { 480 pci O->pszDisplayName = pciO->pszFileName + strlen(cmp->rightdir);491 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir); 481 492 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\') 482 pci O->pszFileName++;493 pciD->pszFileName++; 483 494 } 484 strcpy(pciO->szDispAttr, pci->szDispAttr); 485 pciO->attrFile = pci->attrFile; 486 pciO->flags = 0; 487 pciO->date = pci->date; 488 pciO->time = pci->time; 489 pciO->ladate = pci->ladate; 490 pciO->latime = pci->latime; 491 pciO->crdate = pci->crdate; 492 pciO->crtime = pci->crtime; 493 pciO->cbFile = pci->cbFile; 494 pciO->easize = pci->easize; 495 pciO->pszSubject = xstrdup(NullStr, pszSrcFile, __LINE__); 496 pci->pszFileName = xstrdup(NullStr, pszSrcFile, __LINE__); 497 //pci->pszFileName = pci->szFileName; 495 strcpy(pciD->szDispAttr, pci->szDispAttr); 496 pciD->attrFile = pci->attrFile; 497 pciD->flags = 0; 498 pciD->date = pci->date; 499 pciD->time = pci->time; 500 pciD->ladate = pci->ladate; 501 pciD->latime = pci->latime; 502 pciD->crdate = pci->crdate; 503 pciD->crtime = pci->crtime; 504 pciD->cbFile = pci->cbFile; 505 pciD->easize = pci->easize; 506 pciD->pszSubject = NullStr; 507 pci->pszFileName = NullStr; 498 508 pci->flags = 0; 499 509 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci), 500 510 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 501 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pci O),511 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD), 502 512 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 503 513 } … … 510 520 GetPString(IDS_COMPMOVEFAILEDTEXT), 511 521 pci->pszFileName, newname); 512 if (rc == MBID_CANCEL) / * cause loop to break */513 pci n= NULL;522 if (rc == MBID_CANCEL) // Cause loop to break 523 pciNextS = NULL; 514 524 } 515 525 break; … … 524 534 cmp->rightdir[strlen(cmp->rightdir) - 1] == 525 535 '\\' ? NullStr : "\\", pci->pszFileName); 526 / * make directory if required */536 // Make directory if required 527 537 strcpy(dirname, newname); 528 538 p = strrchr(dirname, '\\'); … … 544 554 pci->pszFileName, newname); 545 555 if (rc == MBID_CANCEL) 546 pci n = NULL; /* cause loop to break */556 pciNextS = NULL; // Cause loop to break 547 557 } 548 558 else { 549 559 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci), 550 560 MPFROM2SHORT(FALSE, CRA_SELECTED)); 551 if (pci O->rc.flRecordAttr & CRA_SELECTED)552 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pci O),561 if (pciD->rc.flRecordAttr & CRA_SELECTED) 562 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD), 553 563 MPFROM2SHORT(FALSE, CRA_SELECTED)); 554 pciO->pszFileName = xstrdup(newname, pszSrcFile, __LINE__); 564 FreeCnrItemData(pciD); 565 pciD->pszFileName = xstrdup(newname, pszSrcFile, __LINE__); 555 566 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) { 556 pci O->pszDisplayName = pciO->pszFileName + strlen(cmp->leftdir);567 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir); 557 568 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\') 558 pci O->pszFileName++;569 pciD->pszFileName++; 559 570 } 560 571 else { 561 pci O->pszDisplayName = pciO->pszFileName + strlen(cmp->rightdir);572 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir); 562 573 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\') 563 pci O->pszFileName++;574 pciD->pszFileName++; 564 575 } 565 strcpy(pciO->szDispAttr, pci->szDispAttr); 566 pciO->attrFile = pci->attrFile; 567 pciO->flags = CNRITEM_EXISTS; 568 pciO->date = pci->date; 569 pciO->time = pci->time; 570 pciO->ladate = pci->ladate; 571 pciO->latime = pci->latime; 572 pciO->crdate = pci->crdate; 573 pciO->crtime = pci->crtime; 574 pciO->cbFile = pci->cbFile; 575 pciO->easize = pci->easize; 576 pci->pszSubject = xstrdup(NullStr, pszSrcFile, __LINE__); 576 strcpy(pciD->szDispAttr, pci->szDispAttr); 577 pciD->attrFile = pci->attrFile; 578 pciD->flags = CNRITEM_EXISTS; 579 pciD->date = pci->date; 580 pciD->time = pci->time; 581 pciD->ladate = pci->ladate; 582 pciD->latime = pci->latime; 583 pciD->crdate = pci->crdate; 584 pciD->crtime = pci->crtime; 585 pciD->cbFile = pci->cbFile; 586 pciD->easize = pci->easize; 587 pci->pszSubject = NullStr; 588 pci->pszLongname = NullStr; 577 589 pci->flags = CNRITEM_EXISTS; 578 590 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci), 579 591 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 580 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pci O),592 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD), 581 593 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 582 594 } … … 585 597 default: 586 598 break; 587 } // switch 588 } 589 pci = pcin; 590 pciO = pciOn; 591 } // while 599 } // switch 600 601 } // if have name 602 603 pci = pciNextS; 604 pciD = pciNextD; 605 606 } // while 592 607 Abort: 593 608 WinDestroyMsgQueue(hmq); … … 648 663 } 649 664 650 static VOID FillDirList(CHAR * str, INT skiplen, BOOL recurse, 651 FILELIST *** list, INT * numfiles, INT * numalloc) 665 /** 666 * Build FILELIST given pathname 667 */ 668 669 static VOID FillDirList(CHAR *str, INT skiplen, BOOL recurse, 670 FILELIST ***list, INT *numfiles, INT *numalloc) 652 671 { 653 672 654 registerBYTE *fb;655 registerCHAR *enddir;656 registerULONG x;673 BYTE *fb; 674 CHAR *enddir; 675 ULONG x; 657 676 CHAR *maskstr; 658 677 FILEFINDBUF4 *ffb4, *pffb; … … 661 680 APIRET rc; 662 681 663 if (!str || !*str) 682 if (!str || !*str) { 683 Runtime_Error(pszSrcFile, __LINE__, "no data"); 664 684 return; 685 } 686 665 687 if (!recurse) 666 688 ulM = 128; … … 731 753 Abort: 732 754 DosFindClose(hDir); 733 DosSleep( 0L);755 DosSleep(1); 734 756 } 735 757 free(maskstr); … … 755 777 HMQ hmq; 756 778 BOOL notified = FALSE; 757 static CHAR attrstring[]= "RHS\0DA";779 const PSZ attrstring = "RHS\0DA"; 758 780 HWND hwndLeft, hwndRight; 759 760 if (!cmp) 781 CHAR szBuf[CCHMAXPATH]; 782 CNRINFO cnri; 783 784 if (!cmp) { 785 Runtime_Error(pszSrcFile, __LINE__, "no data"); 761 786 _endthread(); 787 } 762 788 763 789 DosError(FERR_DISABLEHARDERR); … … 776 802 INT r; 777 803 INT y; 804 UINT i; 778 805 ULONG cntr; 779 806 FILELIST **filesl = NULL; … … 783 810 INT numallocl = 0; 784 811 INT numallocr = 0; 785 INT lenl; // Directory prefix length812 INT lenl; // Directory prefix length 786 813 INT lenr; 787 UINT recsNeeded; // fixme to check ovf814 UINT recsNeeded; 788 815 PCNRITEM pcilFirst; 789 816 PCNRITEM pcirFirst; … … 805 832 lenr++; 806 833 priority_normal(); 807 / * clear containers */834 // Clear containers 808 835 WinSendMsg(hwndRight, CM_REMOVERECORD, 809 836 MPVOID, MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE)); … … 812 839 cmp->cmp->totalleft = cmp->cmp->totalright = 0; 813 840 814 / * build list of all files in left directory */841 // Build list of all files in left directory 815 842 if (fForceLower) 816 843 strlwr(cmp->leftdir); … … 822 849 if (filesl) 823 850 qsort(filesl, numfilesl, sizeof(CHAR *), CompNames); 824 /* build list of all files in right directory */ 851 852 // Build list of all files in right directory 825 853 if (!*cmp->rightlist) { 826 854 if (fForceLower) … … 832 860 } 833 861 else { 834 / * use snapshot file */862 // Use snapshot file 835 863 FILE *fp; 836 864 FILEFINDBUF4 fb4; … … 844 872 else { 845 873 while (!feof(fp)) { 846 / * first get name of directory */874 // First get name of directory 847 875 if (!xfgets_bstripcr(str, sizeof(str), fp, pszSrcFile, __LINE__)) 848 876 break; // EOF 849 877 p = str; 850 878 if (*p == '\"') { 851 / * Quoted */879 // Quoted 852 880 p++; 853 881 if (*p && *p != '\"') { … … 869 897 } 870 898 } 871 } 872 { 873 CNRINFO cnri;874 875 memset(&cnri, 0, sizeof(cnri));876 cnri.cb = sizeof(cnri);877 cnri.pszCnrTitle = cmp->rightdir;878 Win SendMsg(hwndRight, CM_SETCNRINFO,879 MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));880 } 899 } // while !EOF 900 901 memset(&cnri, 0, sizeof(cnri)); 902 cnri.cb = sizeof(cnri); 903 cnri.pszCnrTitle = cmp->rightdir; 904 if (!WinSendMsg(hwndRight, CM_SETCNRINFO, 905 MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE))) { 906 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_SETCNRINFO"); 907 } 908 881 909 if (*cmp->rightdir) { 882 910 lenr = strlen(cmp->rightdir) + … … 957 985 } 958 986 } 959 } 960 } 987 } // while 988 } // if have rightdir 961 989 fclose(fp); 962 990 } 963 } 991 } // if snapshot file 964 992 965 993 if (filesr) 966 994 qsort(filesr, numfilesr, sizeof(CHAR *), CompNames); 967 995 968 / * we now have two lists of files, both sorted. */969 / * first, count total number of container entries required */996 // We now have two lists of files, both sorted. 997 // Count total number of container entries required on each side 970 998 l = r = 0; 971 999 recsNeeded = 0; 972 1000 while ((filesl && filesl[l]) || (filesr && filesr[r])) { 973 if ((filesl && filesl[l]) && (filesr && filesr[r])) { 974 x = stricmp(filesl[l]->fname, filesr[r]->fname); 975 if (!x) { 976 l++; // In both 977 r++; 978 } 979 else if (x < 0) 980 l++; // In left only 1001 1002 if (filesl && filesl[l]) { 1003 if (filesr && filesr[r]) 1004 x = stricmp(filesl[l]->fname, filesr[r]->fname); 981 1005 else 982 r++; // In right only 983 } 984 else if (filesl && filesl[l]) 985 l++; // In left only 986 else /* filesr && filesr[r] */ 987 r++; // In right only 988 recsNeeded++; /* keep count of how many entries req'd */ 989 } 1006 x = -1; // Left side list longer 1007 } 1008 else 1009 x = +1; // Right side list longer 1010 1011 if (x <= 0) 1012 l++; // On left side 1013 if (x >= 0) 1014 r++; // On right side 1015 1016 recsNeeded++; // Keep count of how many entries req'd 1017 1018 } // while 1019 990 1020 WinSendMsg(cmp->hwnd, UM_CONTAINERHWND, MPVOID, MPVOID); 991 /* now insert records into the containers */ 1021 1022 // Now insert records into the containers 992 1023 cntr = 0; 993 1024 l = r = 0; … … 1020 1051 } 1021 1052 } 1053 1022 1054 if (recsNeeded) { 1055 1023 1056 pcil = pcilFirst; 1024 1057 pcir = pcirFirst; 1025 1058 while ((filesl && filesl[l]) || (filesr && filesr[r])) { 1026 1059 pcir->hwndCnr = hwndRight; 1027 //pcir->pszFileName = pcir->szFileName; 1028 // 23 Jul 07 SHL fixme to set pszIcon after pszFileName allocated 1029 // 23 Jul 07 SHL fixme to set pszLongName after pszFileName allocated 1030 pcir->pszFileName = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);//29 Jul 07 GKY Temp fix to crash 1031 pcir->rc.pszIcon = pcir->pszFileName; 1032 pcir->rc.hptrIcon = (HPOINTER) 0; 1033 pcir->pszDisplayName = NULL; // Not used here 1034 pcir->pszSubject = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); 1035 //pcir->pszLongname = pcir->pszFileName; 1060 pcir->rc.hptrIcon = (HPOINTER) 0; 1036 1061 pcir->pszDispAttr = pcir->szDispAttr; 1062 1037 1063 pcil->hwndCnr = hwndLeft; 1038 //pcil->pszFileName = pcil->szFileName;1039 pcil->pszFileName = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);//29 Jul 07 GKY Temp fix to crash1040 pcil->rc.pszIcon = pcil->pszFileName;1041 1064 pcil->rc.hptrIcon = (HPOINTER) 0; 1042 1065 pcil->pszDispAttr = pcil->szDispAttr; 1043 pcil->pszDisplayName = NULL; // Not used here 1044 pcil->pszSubject = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__) ; 1045 //pcil->pszLongname = pcil->pszFileName; 1046 if ((filesl && filesl[l]) && (filesr && filesr[r])) { 1066 1067 if (filesl && filesl[l]) { 1068 if (filesr && filesr[r]) 1069 x = stricmp(filesl[l]->fname, filesr[r]->fname); 1070 else 1071 x = -1; // Left side list longer 1072 } 1073 else 1074 x = +1; // Right side list longer 1075 1076 if (x <= 0) { 1077 // File appears on left side 1078 sprintf(szBuf, "%s%s%s", cmp->leftdir, 1079 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ? 1080 NullStr : "\\", filesl[l]->fname); 1081 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 1082 pcil->pszDisplayName = pcil->pszFileName + lenl; 1083 pcil->attrFile = filesl[l]->attrFile; 1084 y = 0; 1085 for (i = 0; i < 6; i++) { 1086 if (attrstring[i]) { 1087 pcil->szDispAttr[y++] = (CHAR)(pcil->attrFile & (1 << i) ? 1088 attrstring[i] : '-'); 1089 } 1090 } 1091 pcil->szDispAttr[5] = 0; 1092 pcil->cbFile = filesl[l]->cbFile; 1093 pcil->easize = filesl[l]->easize; 1094 pcil->date.day = filesl[l]->date.day; 1095 pcil->date.month = filesl[l]->date.month; 1096 pcil->date.year = filesl[l]->date.year + 1980; 1097 pcil->time.seconds = filesl[l]->time.twosecs * 2; 1098 pcil->time.minutes = filesl[l]->time.minutes; 1099 pcil->time.hours = filesl[l]->time.hours; 1100 pcil->ladate.day = filesl[l]->ladate.day; 1101 pcil->ladate.month = filesl[l]->ladate.month; 1102 pcil->ladate.year = filesl[l]->ladate.year + 1980; 1103 pcil->latime.seconds = filesl[l]->latime.twosecs * 2; 1104 pcil->latime.minutes = filesl[l]->latime.minutes; 1105 pcil->latime.hours = filesl[l]->latime.hours; 1106 pcil->crdate.day = filesl[l]->crdate.day; 1107 pcil->crdate.month = filesl[l]->crdate.month; 1108 pcil->crdate.year = filesl[l]->crdate.year + 1980; 1109 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2; 1110 pcil->crtime.minutes = filesl[l]->crtime.minutes; 1111 pcil->crtime.hours = filesl[l]->crtime.hours; 1112 if (*cmp->dcd.mask.szMask) { 1113 if (!Filter((PMINIRECORDCORE) pcil, (PVOID)&cmp->dcd.mask)) { 1114 pcil->rc.flRecordAttr |= CRA_FILTERED; 1115 pcir->rc.flRecordAttr |= CRA_FILTERED; 1116 } 1117 } 1118 pcil->flags |= CNRITEM_EXISTS; 1119 } // if on left 1120 1121 if (x >= 0) { 1122 // File appears on right side 1123 sprintf(szBuf, "%s%s%s", cmp->rightdir, 1124 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ? 1125 NullStr : "\\", filesr[r]->fname); 1126 pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL 1127 pcir->pszDisplayName = pcir->pszFileName + lenr; 1128 pcir->attrFile = filesr[r]->attrFile; 1129 // pcir->rc.hptrIcon = hptrFile; 1130 y = 0; 1131 for (i = 0; i < 6; i++) { 1132 if (attrstring[i]) { 1133 pcir->szDispAttr[y++] = (CHAR)(pcir->attrFile & (1 << i) ? 1134 attrstring[i] : '-'); 1135 } 1136 } 1137 pcir->szDispAttr[5] = 0; 1138 pcir->cbFile = filesr[r]->cbFile; 1139 pcir->easize = filesr[r]->easize; 1140 pcir->date.day = filesr[r]->date.day; 1141 pcir->date.month = filesr[r]->date.month; 1142 pcir->date.year = filesr[r]->date.year + 1980; 1143 pcir->time.seconds = filesr[r]->time.twosecs * 2; 1144 pcir->time.minutes = filesr[r]->time.minutes; 1145 pcir->time.hours = filesr[r]->time.hours; 1146 pcir->ladate.day = filesr[r]->ladate.day; 1147 pcir->ladate.month = filesr[r]->ladate.month; 1148 pcir->ladate.year = filesr[r]->ladate.year + 1980; 1149 pcir->latime.seconds = filesr[r]->latime.twosecs * 2; 1150 pcir->latime.minutes = filesr[r]->latime.minutes; 1151 pcir->latime.hours = filesr[r]->latime.hours; 1152 pcir->crdate.day = filesr[r]->crdate.day; 1153 pcir->crdate.month = filesr[r]->crdate.month; 1154 pcir->crdate.year = filesr[r]->crdate.year + 1980; 1155 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2; 1156 pcir->crtime.minutes = filesr[r]->crtime.minutes; 1157 pcir->crtime.hours = filesr[r]->crtime.hours; 1158 if (~pcil->rc.flRecordAttr & CRA_FILTERED && 1159 *cmp->dcd.mask.szMask) { 1160 if (!Filter((PMINIRECORDCORE)pcir, (PVOID)&cmp->dcd.mask)) { 1161 pcil->rc.flRecordAttr |= CRA_FILTERED; 1162 pcir->rc.flRecordAttr |= CRA_FILTERED; 1163 } 1164 } 1165 pcir->flags |= CNRITEM_EXISTS; 1166 } // if on right 1167 1168 if (x == 0) { 1169 // File appears on both sides 1170 pch = szBuf; 1171 // Subject field holds status messages 1172 *pch = 0; 1173 if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) { 1174 pcil->flags |= CNRITEM_LARGER; 1175 pcir->flags |= CNRITEM_SMALLER; 1176 strcpy(pch, GetPString(IDS_LARGERTEXT)); 1177 pch += 6; 1178 } 1179 else if (pcil->cbFile + pcil->easize < 1180 pcir->cbFile + pcir->easize) { 1181 pcil->flags |= CNRITEM_SMALLER; 1182 pcir->flags |= CNRITEM_LARGER; 1183 strcpy(pch, GetPString(IDS_SMALLERTEXT)); 1184 pch += 7; 1185 } 1186 if ((pcil->date.year > pcir->date.year) ? TRUE : 1187 (pcil->date.year < pcir->date.year) ? FALSE : 1188 (pcil->date.month > pcir->date.month) ? TRUE : 1189 (pcil->date.month < pcir->date.month) ? FALSE : 1190 (pcil->date.day > pcir->date.day) ? TRUE : 1191 (pcil->date.day < pcir->date.day) ? FALSE : 1192 (pcil->time.hours > pcir->time.hours) ? TRUE : 1193 (pcil->time.hours < pcir->time.hours) ? FALSE : 1194 (pcil->time.minutes > pcir->time.minutes) ? TRUE : 1195 (pcil->time.minutes < pcir->time.minutes) ? FALSE : 1196 (pcil->time.seconds > pcir->time.seconds) ? TRUE : 1197 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) { 1198 pcil->flags |= CNRITEM_NEWER; 1199 pcir->flags |= CNRITEM_OLDER; 1200 if (pch != szBuf) { 1201 strcpy(pch, ", "); 1202 pch += 2; 1203 } 1204 strcpy(pch, GetPString(IDS_NEWERTEXT)); 1205 pch += 5; 1206 } 1207 else if ((pcil->date.year < pcir->date.year) ? TRUE : 1208 (pcil->date.year > pcir->date.year) ? FALSE : 1209 (pcil->date.month < pcir->date.month) ? TRUE : 1210 (pcil->date.month > pcir->date.month) ? FALSE : 1211 (pcil->date.day < pcir->date.day) ? TRUE : 1212 (pcil->date.day > pcir->date.day) ? FALSE : 1213 (pcil->time.hours < pcir->time.hours) ? TRUE : 1214 (pcil->time.hours > pcir->time.hours) ? FALSE : 1215 (pcil->time.minutes < pcir->time.minutes) ? TRUE : 1216 (pcil->time.minutes > pcir->time.minutes) ? FALSE : 1217 (pcil->time.seconds < pcir->time.seconds) ? TRUE : 1218 (pcil->time.seconds > pcir->time.seconds) ? FALSE : 1219 FALSE) { 1220 pcil->flags |= CNRITEM_OLDER; 1221 pcir->flags |= CNRITEM_NEWER; 1222 if (pch != szBuf) { 1223 strcpy(pch, ", "); 1224 pch += 2; 1225 } 1226 strcpy(pch, GetPString(IDS_OLDERTEXT)); 1227 pch += 5; 1228 } 1229 *pch = 0; // fixme to be gone? 1230 // fixme to known why not displayed - defect? 1231 pcil->pszSubject = *szBuf ? strdup(szBuf) : NullStr; 1232 1233 } // if on both sides 1234 1235 if (x <= 0) { 1236 free(filesl[l]); 1237 l++; 1238 } 1239 1240 if (x >= 0) { 1241 free(filesr[r]); 1242 r++; 1243 } 1244 1245 #if 0 //============================ fixme to be gone ================= 1246 1247 if (filesl && filesl[l] && filesr && filesr[r]) { 1248 // Got two names 1047 1249 x = stricmp(filesl[l]->fname, filesr[r]->fname); 1048 1250 if (!x) { 1049 // Same1050 sprintf( pcil->pszFileName, "%s%s%s", cmp->leftdir,1251 // Names match - insert on both sides 1252 sprintf(szBuf, "%s%s%s", cmp->leftdir, 1051 1253 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ? 1052 1254 NullStr : "\\", filesl[l]->fname); 1053 1255 // pcil->rc.hptrIcon = hptrFile; 1256 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL 1054 1257 pcil->pszDisplayName = pcil->pszFileName + lenl; 1055 1258 pcil->attrFile = filesl[l]->attrFile; … … 1088 1291 } 1089 1292 } 1090 sprintf( pcir->pszFileName, "%s%s%s", cmp->rightdir,1293 sprintf(szBuf, "%s%s%s", cmp->rightdir, 1091 1294 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ? 1092 1295 NullStr : "\\", filesr[r]->fname); 1296 pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL 1093 1297 pcir->pszDisplayName = pcir->pszFileName + lenr; 1094 1298 pcir->attrFile = filesr[r]->attrFile; … … 1123 1327 pcil->flags |= CNRITEM_EXISTS; 1124 1328 pcir->flags |= CNRITEM_EXISTS; 1125 pch = pcil->pszSubject; 1329 pch = szBuf; 1330 // Subject field holds status messages 1331 // pch = pcil->pszSubject; 1332 *pch = 0; 1126 1333 if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) { 1127 1334 pcil->flags |= CNRITEM_LARGER; … … 1151 1358 pcil->flags |= CNRITEM_NEWER; 1152 1359 pcir->flags |= CNRITEM_OLDER; 1153 if (pch != pcil->pszSubject) {1360 if (pch != szBuf) { 1154 1361 strcpy(pch, ", "); 1155 1362 pch += 2; … … 1173 1380 pcil->flags |= CNRITEM_OLDER; 1174 1381 pcir->flags |= CNRITEM_NEWER; 1175 if (pch != pcil->pszSubject) {1382 if (pch != szBuf) { 1176 1383 strcpy(pch, ", "); 1177 1384 pch += 2; … … 1181 1388 } 1182 1389 *pch = 0; 1390 pcil->pszSubject = *szBuf ? strdup(szBuf) : NullStr; 1183 1391 r++; 1184 1392 l++; 1185 1393 } 1186 1394 else if (x < 0) { 1187 // Just on left 1188 sprintf(pcil->pszFileName, "%s%s%s", cmp->leftdir, 1189 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ? 1190 NullStr : "\\", filesl[l]->fname); 1395 // Left side name less than right side name 1396 // Insert name on left, leave blank filler on right 1397 sprintf(szBuf, "%s%s%s", cmp->leftdir, 1398 cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ? 1399 NullStr : "\\", 1400 filesl[l]->fname); 1401 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 1191 1402 pcil->pszDisplayName = pcil->pszFileName + lenl; 1192 1403 pcil->attrFile = filesl[l]->attrFile; … … 1229 1440 } 1230 1441 else { 1231 // Just on right 1232 sprintf(pcir->pszFileName, "%s%s%s", cmp->rightdir, 1233 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ? 1234 NullStr : "\\", filesr[r]->fname); 1442 // Left side name larger than right side name 1443 // Insert name on right, leave blank filler on left 1444 sprintf(szBuf, "%s%s%s", cmp->rightdir, 1445 cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ? 1446 NullStr : "\\", 1447 filesr[r]->fname); 1448 pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 1235 1449 pcir->pszDisplayName = pcir->pszFileName + lenr; 1236 1450 pcir->attrFile = filesr[r]->attrFile; … … 1275 1489 } 1276 1490 else if (filesl && filesl[l]) { 1277 // Just on left 1278 sprintf(pcil->pszFileName, "%s%s%s", cmp->leftdir, 1279 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ? 1280 NullStr : "\\", filesl[l]->fname); 1491 // Left side list longer than right side list 1492 // Insert name on left, leave blank filler on right 1493 sprintf(szBuf, "%s%s%s", cmp->leftdir, 1494 cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ? 1495 NullStr : "\\", 1496 filesl[l]->fname); 1497 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 1281 1498 pcil->pszDisplayName = pcil->pszFileName + lenl; 1282 1499 pcil->attrFile = filesl[l]->attrFile; … … 1318 1535 } 1319 1536 else { 1320 /* filesr && filesr[r] */ 1321 // Just on right 1322 sprintf(pcir->pszFileName, "%s%s%s", cmp->rightdir, 1323 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ? 1324 NullStr : "\\", filesr[r]->fname); 1537 // filesr && filesr[r] 1538 // Right side list longer than left side 1539 // Insert name on right, leave blank filler on left 1540 sprintf(szBuf, "%s%s%s", cmp->rightdir, 1541 cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ? 1542 NullStr : "\\", 1543 filesr[r]->fname); 1544 pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 1325 1545 pcir->pszDisplayName = pcir->pszFileName + lenr; 1326 1546 pcir->attrFile = filesr[r]->attrFile; … … 1362 1582 r++; 1363 1583 } 1584 1585 #endif //=========================== fixme to be gone ================= 1586 1587 // Ensure empty buffers point somewhere 1588 if (!pcil->pszFileName) { 1589 pcil->pszFileName = NullStr; 1590 pcil->pszDisplayName = pcil->pszFileName; 1591 } 1592 1593 if (!pcir->pszFileName) { 1594 pcir->pszFileName = NullStr; 1595 pcir->pszDisplayName = pcir->pszFileName; 1596 } 1597 1598 pcil->rc.pszIcon = pcil->pszFileName; // fixme to be pszDisplayName? 1599 pcir->rc.pszIcon = pcir->pszFileName; 1600 pcil->pszLongname = pcil->pszFileName; 1601 pcir->pszLongname = pcir->pszFileName; 1602 1603 if (!pcil->pszSubject) 1604 pcil->pszSubject = NullStr; 1605 if (!pcir->pszSubject) 1606 pcil->pszSubject = NullStr; 1607 1608 // fixme to be time based - every 2 sec should be OK 1364 1609 if (!(cntr % 500)) 1365 DosSleep(1 L);1610 DosSleep(1); 1366 1611 else if (!(cntr % 50)) 1367 DosSleep(0L); 1612 DosSleep(1); 1613 1368 1614 cntr++; 1615 1369 1616 pcil = (PCNRITEM) pcil->rc.preccNextRecord; 1370 1617 pcir = (PCNRITEM) pcir->rc.preccNextRecord; 1371 } // while 1618 1619 } // while filling left or right 1620 1372 1621 if (filesl) 1373 1622 free(filesl); // Free header - have already freed elements … … 1376 1625 free(filesr); 1377 1626 filesr = NULL; 1378 / * insert 'em */1627 // Insert 'em 1379 1628 WinSendMsg(cmp->hwnd, UM_CONTAINERDIR, MPVOID, MPVOID); 1629 1380 1630 memset(&ri, 0, sizeof(RECORDINSERT)); 1381 1631 ri.cb = sizeof(RECORDINSERT); … … 1397 1647 numfilesl = 0; 1398 1648 } 1649 1399 1650 memset(&ri, 0, sizeof(RECORDINSERT)); 1400 1651 ri.cb = sizeof(RECORDINSERT); … … 1418 1669 numfilesr = 0; 1419 1670 } 1671 1420 1672 cmp->cmp->totalleft = numfilesl; 1421 1673 cmp->cmp->totalright = numfilesr; 1422 } // if recsNeeded 1674 1675 } // if recsNeeded 1676 1423 1677 Deselect(hwndLeft); 1424 1678 Deselect(hwndRight); 1679 1425 1680 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID)) 1426 1681 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID); 1427 1682 notified = TRUE; 1683 1428 1684 if (filesl) 1429 FreeList((CHAR **) 1685 FreeList((CHAR **)filesl); // Must have failed to create container 1430 1686 if (filesr) 1431 FreeList((CHAR **) filesr); 1687 FreeList((CHAR **)filesr); 1688 1432 1689 WinDestroyMsgQueue(hmq); 1433 1690 } … … 1580 1837 LoadDetailsSwitches("DirCmp", &cmp->dcd); 1581 1838 cmp->dcd.detailslongname = FALSE; 1582 cmp->dcd.detailsicon = FALSE; / * TRUE; */1839 cmp->dcd.detailsicon = FALSE; // TRUE; 1583 1840 } 1584 1841 memset(&cnri, 0, sizeof(CNRINFO)); … … 1622 1879 case WM_DRAWITEM: 1623 1880 if (mp2) { 1624 1625 POWNERITEM pown = (POWNERITEM) mp2; 1881 POWNERITEM pown = (POWNERITEM)mp2; 1626 1882 PCNRDRAWITEMINFO pcown; 1627 1883 PCNRITEM pci; 1628 1884 1629 pcown = (PCNRDRAWITEMINFO) 1885 pcown = (PCNRDRAWITEMINFO)pown->hItem; 1630 1886 if (pcown) { 1631 1887 pci = (PCNRITEM) pcown->pRecord; 1632 if (pci && (INT) pci != -1 && !*pci->pszFileName) 1888 // 01 Aug 07 SHL if field null or blank, we draw 1889 // fixme to know why - probably to optimize and bypass draw? 1890 if (pci && (INT)pci != -1 && !*pci->pszFileName) 1633 1891 return MRFROMLONG(TRUE); 1634 1892 } … … 1770 2028 SetShiftState(); 1771 2029 if (pci) { 1772 if ( (pci->rc.flRecordAttr & CRA_INUSE)|| !*pci->pszFileName)2030 if (pci->rc.flRecordAttr & CRA_INUSE || !pci || !*pci->pszFileName) 1773 2031 break; 1774 2032 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci), … … 1803 2061 cmp->hwndCalling = WinWindowFromID(hwnd, SHORT1FROMMP(mp1)); 1804 2062 if (pci) { 1805 if (! *pci->pszFileName || *cmp->rightlist)2063 if (!pci || !*pci->pszFileName || *cmp->rightlist) 1806 2064 break; 1807 2065 id = COMP_MENU; … … 1851 2109 pci = (PCNRITEM) pre->pRecord; 1852 2110 if (pci) { 1853 if (! *pci->pszFileName) {2111 if (!pci || !*pci->pszFileName) { 1854 2112 if (pci->rc.flRecordAttr & CRA_SELECTED) 1855 2113 WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), … … 2049 2307 pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPFROMP(pcir), 2050 2308 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 2051 } 2309 } // while 2052 2310 if (needRefresh) { 2053 2311 WinSendMsg(hwndl, CM_INVALIDATERECORD, … … 2085 2343 MPFROMLONG(CMA_FIRST), 2086 2344 MPFROMSHORT(CRA_CURSORED)); 2087 if (pci) { 2345 // 01 Aug 07 SHL 2346 if (pci && *pci->pszFileName) { 2088 2347 if (cmp->hwndCalling == hwndLeft) 2089 2348 strcpy(ofile, cmp->rightdir); … … 2094 2353 strcat(ofile, pci->pszFileName); 2095 2354 if (*compare) { 2096 2097 2355 CHAR *fakelist[3]; 2098 2099 2356 fakelist[0] = pci->pszFileName; 2100 2357 fakelist[1] = ofile; … … 2104 2361 } 2105 2362 else { 2106 2107 2363 FCOMPARE fc; 2108 2109 2364 memset(&fc, 0, sizeof(fc)); 2110 2365 fc.size = sizeof(fc); … … 2133 2388 temp = fSelectedAlways; 2134 2389 fSelectedAlways = TRUE; 2135 pci = (PCNRITEM) 2390 pci = (PCNRITEM)CurrentRecord(hwnd); 2136 2391 fSelectedAlways = temp; 2137 if (pci && !(pci->attrFile & FILE_DIRECTORY)) { 2392 // 01 Aug 07 SHL 2393 if (pci && ~pci->attrFile & FILE_DIRECTORY) { 2138 2394 p = strrchr(pci->pszFileName, '\\'); 2139 2395 if (p) { … … 2371 2627 case IDM_SELECTONE: 2372 2628 case IDM_SELECTSAMECONTENT: 2373 case IDM_SELECTIDENTICAL: // name, size and time2374 case IDM_SELECTSAME: // name and size2629 case IDM_SELECTIDENTICAL: // Name, size and time 2630 case IDM_SELECTSAME: // Name and size 2375 2631 case IDM_INVERT: 2376 2632 cmp = INSTDATA(hwnd); … … 2481 2737 !strcmp(realappname, FM3Str)) 2482 2738 TileChildren(cmp->hwndParent, TRUE); 2483 DosSleep(64 L);2739 DosSleep(64); 2484 2740 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID); 2485 2741 break;
Note:
See TracChangeset
for help on using the changeset viewer.