Changeset 924


Ignore:
Timestamp:
Jan 17, 2008, 1:40:52 AM (18 years ago)
Author:
Steven Levine
Message:

Avoid error reports for R/O FAT directories (ticket #116)
Change Config->Edit and Config->Palette menus to have no default
Move SpecialSelect to comp.c

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/HISTORY

    r922 r924  
    1010 o Rework Walk dialog.  Put entry field at the top. (Steven)
    1111 o Get Subjectwidth/left working in the collector. (Gregg)
     12 o Change Config->Edit and Config->Palette menus to have no default (Steven)
     13 o Avoid spurious error reports for R/O directories on FAT volumes.  Ticket #116. (Steven)
    1214
    13153.09
  • trunk/dll/comp.c

    r919 r924  
    4444  05 Jan 08 SHL Use ITIMER_DESC for hogging control
    4545  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
    4649
    4750***********************************************************************/
     
    364367
    365368  case WM_DESTROY:
    366     DosSleep(50);                       // 05 Aug 07 GKY 100
     369    DosSleep(50);                       // Let others die first
    367370    break;
    368371  }
     
    378381  HMQ hmq;
    379382  HWND hwndCnrS, hwndCnrD;
    380   PCNRITEM pci, pciD, pciNextS, pciNextD;
     383  PCNRITEM pciS, pciD, pciNextS, pciNextD;
    381384  CHAR szNewName[CCHMAXPATH], szDirName[CCHMAXPATH], *p;
    382385  APIRET rc;
     386  ITIMER_DESC itdSleep = { 0 };
    383387
    384388  if (!cmp) {
     
    432436      }
    433437
    434       pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
     438      pciS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
    435439                       MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    436440      pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
     
    438442
    439443      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),
    444449                          MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    445450        pciNextD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
    446451                           MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    447452
    448         if (*pci->pszFileName && pci->rc.flRecordAttr & CRA_SELECTED) {
     453        if (*pciS->pszFileName && pciS->rc.flRecordAttr & CRA_SELECTED) {
    449454
    450455          // Source name not blank
    451456          switch (cmp->action) {
    452457          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),
    455460                         MPFROM2SHORT(FALSE, CRA_SELECTED));
    456461
    457462              if (!*pciD->pszFileName) {
    458463                // 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);
    460465                if (pciD->rc.flRecordAttr & CRA_SELECTED)
    461466                  WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
     
    465470              else {
    466471                // 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),
    472477                           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                }
    473483              }
    474484              if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
     
    476486              else
    477487                cmp->cmp->totalright--;
    478               DosSleep(0);              // 8-26-07 GKY 1
     488              // DosSleep(0);           // 8-26-07 GKY 1 // 12 Jan 08 SHL
    479489            }
    480490            break;
     
    482492          case IDM_MOVE:
    483493            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);
    490495            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);
    497497            // Make directory if required
    498498            strcpy(szDirName, szNewName);
     
    505505                MassMkdir(hwndMain, szDirName);
    506506            }
    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),
    510510                         MPFROM2SHORT(FALSE, CRA_SELECTED));
    511511              if (pciD->rc.flRecordAttr & CRA_SELECTED)
     
    525525              }
    526526              // 02 Aug 07 SHL fixme to know if LongName transfer is correct?
    527               pciD->pszLongName = pci->pszLongName;
     527              pciD->pszLongName = pciS->pszLongName;
    528528              if (pciD->pszSubject != NullStr) {
    529529                xfree(pciD->pszSubject);
    530530                pciD->pszSubject = NullStr;
    531531              }
    532               pciD->attrFile = pci->attrFile;
    533               pciD->pszDispAttr = pci->pszDispAttr;
     532              pciD->attrFile = pciS->attrFile;
     533              pciD->pszDispAttr = pciS->pszDispAttr;
    534534              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;
    549549              }
    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;
    553553              }
    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),
    557557                         MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
     558
    558559              WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
    559560                         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--;
    560566            }
    561567            else if (rc) {
     
    566572                             __LINE__,
    567573                             GetPString(IDS_COMPMOVEFAILEDTEXT),
    568                              pci->pszFileName, szNewName);
     574                             pciS->pszFileName, szNewName);
    569575              if (rc == MBID_CANCEL)    // Cause loop to break
    570576                pciNextS = NULL;
     
    574580          case IDM_COPY:
    575581            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);
    582583            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);
    589585            // Make directory if required
    590586            strcpy(szDirName, szNewName);
     
    597593                MassMkdir(hwndMain, szDirName);
    598594            }
    599             rc = docopyf(COPY, pci->pszFileName, "%s", szNewName);
     595            rc = docopyf(COPY, pciS->pszFileName, "%s", szNewName);
    600596            if (rc) {
    601597              rc = Dos_Error(MB_ENTERCANCEL,
     
    605601                             __LINE__,
    606602                             GetPString(IDS_COMPCOPYFAILEDTEXT),
    607                              pci->pszFileName, szNewName);
     603                             pciS->pszFileName, szNewName);
    608604              if (rc == MBID_CANCEL)
    609605                pciNextS = NULL;                // Cause loop to break
    610606            }
    611607            else {
    612               WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
     608              WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS),
    613609                         MPFROM2SHORT(FALSE, CRA_SELECTED));
    614610              if (pciD->rc.flRecordAttr & CRA_SELECTED)
    615611                WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
    616612                           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              }
    617620              FreeCnrItemData(pciD);
    618621              pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
     
    627630                  pciD->pszDisplayName++;
    628631              }
    629               pciD->attrFile = pci->attrFile;
    630               pciD->pszDispAttr = pci->pszDispAttr;
     632              pciD->attrFile = pciS->attrFile;
     633              pciD->pszDispAttr = pciS->pszDispAttr;
    631634              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;
    640643
    641644              // 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;
    645648              }
    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),
    649652                         MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    650653              WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
     
    659662        } // if have name
    660663
    661         pci = pciNextS;
     664        pciS = pciNextS;
    662665        pciD = pciNextD;
    663666
     667        SleepIfNeeded(&itdSleep, 0);
    664668      } // while
    665669    Abort:
     
    674678  free(cmp);
    675679}
     680
     681VOID CompSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset);
    676682
    677683//=== SelectCnrsThread() Update container selection flags thread ===
     
    710716
    711717      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);
    715725        break;
    716726      }
     
    724734  }
    725735  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
     744VOID 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
     785Restart:
     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);
    7261265}
    7271266
     
    8291368}
    8301369
    831 //=== CompNames() Compare names for qsort ===
     1370/**
     1371 * Compare names for qsort
     1372 */
    8321373
    8331374static int CompNames(const void *n1, const void *n2)
     
    12751816                             &pcil->date, &pcil->time);
    12761817            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 :
    12781820                (pcil->date.year < pcir->date.year) ? FALSE :
    12791821                (pcil->date.month > pcir->date.month) ? TRUE :
     
    12861828                (pcil->time.minutes < pcir->time.minutes) ? FALSE :
    12871829                (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            {
    12891833              pcil->flags |= CNRITEM_NEWER;
    12901834              pcir->flags |= CNRITEM_OLDER;
     
    12971841            }
    12981842            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            {
    13121859              pcil->flags |= CNRITEM_OLDER;
    13131860              pcir->flags |= CNRITEM_NEWER;
     
    15152062                       };
    15162063        UINT x;
    1517         for (x = 0; ids[x]; x++)
     2064        for (x = 0; ids[x]; x++) {
    15182065          SetPresParams(WinWindowFromID(hwnd, ids[x]),
    15192066                        &RGBGREY,
    15202067                        &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT));
     2068        }
    15212069      }
    15222070    }
     
    17142262    }
    17152263    else {
    1716 
    1717       // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED enter");
    1718 
    17192264      cmp->filling = FALSE;
    17202265      WinEnableWindow(hwndLeft, TRUE);
     
    17722317      else
    17732318        WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
    1774 
    1775       // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED exit");
    1776 
    17772319    }
    17782320    break;
     
    25493091              TileChildren(cmp->hwndParent, TRUE);
    25503092            }
    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
    25523095            PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
    25533096            break;
     
    26203163#pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
    26213164#pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
    2622 
     3165#pragma alloc_text(COMPSELECT,CompSelect)
     3166
  • trunk/dll/filldir.c

    r917 r924  
    747747      ulFindMax = FilesToGet;           // full-out
    748748  }
    749   else {
     749  else
    750750    ulFindMax = FilesToGet;
    751   }
     751
    752752  if (OS2ver[0] == 20 && OS2ver[1] < 30)
    753753    ulFindMax = min(ulFindMax, (65535 / sizeof(FILEFINDBUF4L)));
     
    780780                       FIL_QUERYEASIZEL);
    781781    priority_normal();
    782     *pchEndPath = 0;
     782    *pchEndPath = 0;                    // Chop off wildcard
    783783    if (!rc) {
    784784      do {
     
    971971    }
    972972
     973    /**
     974     * DosFind for subdirectories of a read-only directory on a FAT volume
     975     * returns path not found if there are no subdirectories
     976     * FAT FS seems to ignore . and .. in this case
     977     * Map to no more files
     978     * We could verify that directory is marked read-only, it's probably not
     979     * worth the extra code since we do verify 2 out of 3 prerequisites
     980     * 15 Jan 08 SHL
     981     */
     982    if (rc == ERROR_PATH_NOT_FOUND && !filestoo) {
     983      ULONG ulDriveType = 0;
     984      CHAR szFSType[CCHMAXPATH];
     985      INT removable = CheckDrive(*pszFileSpec, szFSType, &ulDriveType);
     986      if (removable != -1 && strcmp(szFSType, "FAT") == 0)
     987        rc = ERROR_NO_MORE_FILES;
     988    }
     989
    973990    if (rc && rc != ERROR_NO_MORE_FILES) {
    974991      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     
    10111028VOID FillDirCnr(HWND hwndCnr,
    10121029                CHAR * pszDirectory,
    1013                 DIRCNRDATA * dcd, PULONGLONG pullTotalBytes)
     1030                DIRCNRDATA * dcd,
     1031                PULONGLONG pullTotalBytes)
    10141032{
    10151033  ProcessDirectory(hwndCnr,
    1016                    (PCNRITEM) NULL,
     1034                   (PCNRITEM)NULL,
    10171035                   pszDirectory,
    10181036                   TRUE,                // filestoo
     
    10211039                   dcd ? &dcd->stopflag : NULL,
    10221040                   dcd,
    1023                    NULL,
     1041                   NULL,                // total files
    10241042                   pullTotalBytes);
    10251043  DosPostEventSem(CompactSem);
     
    10391057VOID FillTreeCnr(HWND hwndCnr, HWND hwndParent)
    10401058{
    1041   ULONG ulCurDriveNum, ulDriveMap, numtoinsert = 0, drvtype;
     1059  ULONG ulCurDriveNum, ulDriveMap, numtoinsert = 0;
     1060  ULONG ulDriveType;
    10421061  PCNRITEM pci, pciFirst = NULL, pciNext, pciParent = NULL;
    10431062  INT x, removable;
    10441063  CHAR suggest[32];
    10451064  CHAR szDrive[] = " :\\";
    1046   CHAR szFileSystem[CCHMAXPATH];
     1065  CHAR szFSType[CCHMAXPATH];
    10471066  FILESTATUS4L fsa4;
    10481067  APIRET rc;
     
    11201139        // Hard drive (2..N)
    11211140        if (!(driveflags[x] & DRIVE_NOPRESCAN)) {
    1122           *szFileSystem = 0;
    1123           drvtype = 0;
    1124           removable = CheckDrive(*szDrive, szFileSystem, &drvtype);
     1141          *szFSType = 0;
     1142          ulDriveType = 0;
     1143          removable = CheckDrive(*szDrive, szFSType, &ulDriveType);
    11251144          driveserial[x] = -1;
    11261145          if (removable != -1) {
     
    11431162          driveflags[x] |= removable == -1 || removable == 1 ?
    11441163                            DRIVE_REMOVABLE : 0;
    1145           if (drvtype & DRIVE_REMOTE)
     1164          if (ulDriveType & DRIVE_REMOTE)
    11461165            driveflags[x] |= DRIVE_REMOTE;
    1147           if (!stricmp(szFileSystem,RAMFS)) {
     1166          if (!stricmp(szFSType,RAMFS)) {
    11481167            driveflags[x] |= DRIVE_RAMDISK;
    11491168            driveflags[x] &= ~DRIVE_REMOTE;
    11501169          }
    1151           if (!stricmp(szFileSystem,NDFS32)) {
     1170          if (!stricmp(szFSType,NDFS32)) {
    11521171            driveflags[x] |= DRIVE_VIRTUAL;
    11531172            driveflags[x] &= ~DRIVE_REMOTE;
    11541173          }
    1155           if (!stricmp(szFileSystem,NTFS))
     1174          if (!stricmp(szFSType,NTFS))
    11561175            driveflags[x] |= DRIVE_NOTWRITEABLE;
    1157           if (strcmp(szFileSystem, HPFS) &&
    1158               strcmp(szFileSystem, JFS) &&
    1159               strcmp(szFileSystem, ISOFS) &&
    1160               strcmp(szFileSystem, CDFS) &&
    1161               strcmp(szFileSystem, FAT32) &&
    1162               strcmp(szFileSystem, NDFS32) &&
    1163               strcmp(szFileSystem, RAMFS) &&
    1164               strcmp(szFileSystem, NTFS) &&
    1165               strcmp(szFileSystem, HPFS386)) {
     1176          if (strcmp(szFSType, HPFS) &&
     1177              strcmp(szFSType, JFS) &&
     1178              strcmp(szFSType, ISOFS) &&
     1179              strcmp(szFSType, CDFS) &&
     1180              strcmp(szFSType, FAT32) &&
     1181              strcmp(szFSType, NDFS32) &&
     1182              strcmp(szFSType, RAMFS) &&
     1183              strcmp(szFSType, NTFS) &&
     1184              strcmp(szFSType, HPFS386)) {
    11661185            driveflags[x] |= DRIVE_NOLONGNAMES;
    11671186          }
    11681187
    1169           if (!strcmp(szFileSystem, CDFS) || !strcmp(szFileSystem,ISOFS)) {
     1188          if (!strcmp(szFSType, CDFS) || !strcmp(szFSType,ISOFS)) {
    11701189            removable = 1;
    11711190            driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
    11721191                             DRIVE_CDROM;
    11731192          }
    1174           else if (!stricmp(szFileSystem, CBSIFS)) {
     1193          else if (!stricmp(szFSType, CBSIFS)) {
    11751194            driveflags[x] |= DRIVE_ZIPSTREAM;
    11761195            driveflags[x] &= ~DRIVE_REMOTE;
    1177             if (drvtype & DRIVE_REMOVABLE)
     1196            if (ulDriveType & DRIVE_REMOVABLE)
    11781197              driveflags[x] |= DRIVE_REMOVABLE;
    1179             if (!(drvtype & DRIVE_NOLONGNAMES))
     1198            if (!(ulDriveType & DRIVE_NOLONGNAMES))
    11801199              driveflags[x] &= ~DRIVE_NOLONGNAMES;
    11811200          }
     
    13381357          p++;
    13391358        while (*p) {
    1340           *szFileSystem = 0;
    1341           pp = szFileSystem;
     1359          *szFSType = 0;
     1360          pp = szFSType;
    13421361          while (*p && *p != ' ')
    13431362            *pp++ = *p++;
     
    13451364          while (*p == ' ')
    13461365            p++;
    1347           if (*szFileSystem &&
    1348               (!stricmp(szFileSystem, "LIBPATH") || getenv(szFileSystem))) {
     1366          if (*szFSType &&
     1367              (!stricmp(szFSType, "LIBPATH") || getenv(szFSType))) {
    13491368            pci = WinSendMsg(hwndCnr,
    13501369                             CM_ALLOCRECORD,
     
    13541373              CHAR fname[CCHMAXPATH];
    13551374              pci->flags |= RECFLAGS_ENV;
    1356               sprintf(fname, "%%%s%%", szFileSystem);
     1375              sprintf(fname, "%%%s%%", szFSType);
    13571376              pci->pszFileName = xstrdup(fname, pszSrcFile, __LINE__);
    13581377              pci->rc.hptrIcon = hptrEnv;
     
    14301449    x++;
    14311450    pci = pciNext;
    1432   }
     1451  } // while
    14331452  if (hwndParent)
    14341453    WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent, QW_PARENT),
  • trunk/dll/flesh.c

    r907 r924  
    179179                     TRUE,              // recurse
    180180                     TRUE,              // partial
    181                      NULL,
     181                     NULL,              // stop flag
    182182                     dcd,
    183                      NULL,
    184                      NULL);
     183                     NULL,              // total files
     184                     NULL);             // total bytes
    185185  }
    186186  return TRUE;
  • trunk/dll/fm3dll.h

    r920 r924  
    7676  05 Jan 08 SHL Move string.c definitions to strutil.h
    7777  10 Jan 08 SHL Add UM_FIRSTTIME
     78  12 Jan 08 SHL Localize SpecialSelect to comp.c
    7879
    7980***********************************************************************/
     
    760761VOID ExpandAll(HWND hwndCnr, BOOL expand, PCNRITEM pciParent);
    761762VOID InvertAll(HWND hwndCnr);
    762 VOID SpecialSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset);
    763763VOID SpecialSelect2(HWND hwndParent, INT action);
    764764
  • trunk/dll/fm3res.rc

    r921 r924  
    247247    MENUITEM "Toggle ~drag&drop prompting",IDM_TOGGLEDRAGDIALOG         // 12 Jan 08 SHL
    248248    MENUITEM "",                  -1,           MIS_SEPARATOR
    249     SUBMENU "~Edit",                                                    IDM_EDITCOMMANDS
     249    SUBMENU "~Edit",                                                    -1
    250250         {
    251251           MENUITEM "Edit ~associations...",IDM_EDITASSOC
     
    253253                MENUITEM "Edit an archi~ver...",IDM_EDITANYARCHIVER
    254254         }
    255     SUBMENU "~Palette",                                                 IDM_FONTPALETTE
     255    SUBMENU "~Palette",                                                 -1
    256256         {
    257257            MENUITEM "~Font palette",     IDM_FONTPALETTE
  • trunk/dll/select.c

    r907 r924  
    2828  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
    2929  26 Aug 07 GKY DosSleep(1) in loops changed to (0)
     30  12 Jan 08 SHL Localize SpecialSelect in comp.c
    3031
    3132***********************************************************************/
     
    577578}
    578579
    579 /**
    580  * Do select actions for compare directories containers
    581  *
    582  */
    583 
    584 VOID SpecialSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset)
    585 {
    586   PCNRITEM pciS, pciD, *pciSa = NULL, *pciDa = NULL;
    587   CNRINFO cnri;
    588   BOOL slow = FALSE;
    589   UINT x, numD, numS;
    590   INT ret = 0;
    591 
    592   if (!hwndCnrS || !hwndCnrD) {
    593     Runtime_Error(pszSrcFile, __LINE__, "hwndCnrS %p hwndCnrD %p", hwndCnrS, hwndCnrD);
    594     return;
    595   }
    596 
    597   memset(&cnri, 0, sizeof(CNRINFO));
    598   cnri.cb = sizeof(CNRINFO);
    599   WinSendMsg(hwndCnrD, CM_QUERYCNRINFO, MPFROMP(&cnri),
    600              MPFROMLONG(sizeof(CNRINFO)));
    601   numD = cnri.cRecords;
    602   memset(&cnri, 0, sizeof(CNRINFO));
    603   cnri.cb = sizeof(CNRINFO);
    604   WinSendMsg(hwndCnrS, CM_QUERYCNRINFO, MPFROMP(&cnri),
    605              MPFROMLONG(sizeof(CNRINFO)));
    606   numS = cnri.cRecords;
    607   if (!numD || numS != numD) {
    608     Runtime_Error(pszSrcFile, __LINE__, "numD %u != numS %u", numD, numS);
    609     return;
    610   }
    611   pciDa = xmalloc(sizeof(PCNRITEM) * numD, pszSrcFile, __LINE__);
    612   if (!pciDa)
    613     return;
    614 
    615   pciSa = xmalloc(sizeof(PCNRITEM) * numS, pszSrcFile, __LINE__);
    616   if (!pciSa) {
    617     free(pciDa);
    618     return;
    619   }
    620 
    621 Restart:
    622 
    623   memset(pciDa, 0, sizeof(PCNRITEM) * numD);
    624   memset(pciSa, 0, sizeof(PCNRITEM) * numS);
    625 
    626   pciD = (PCNRITEM)WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
    627                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    628   x = 0;
    629   while (pciD && (INT)pciD != -1 && x < numD) {
    630     if (reset)
    631       pciD->flags = 0;
    632     pciDa[x] = pciD;
    633     x++;
    634     if (!slow)
    635       pciD = (PCNRITEM) pciD->rc.preccNextRecord;
    636     else
    637       pciD = (PCNRITEM) WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
    638                                    MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    639     if (!(x % 500))
    640       DosSleep(0);  //26 Aug 07 GKY 1
    641     // else if (!(x % 50))
    642     //  DosSleep(0);
    643   } // while
    644 
    645   if (numD != x) {
    646     if (!slow) {
    647       slow = TRUE;
    648       goto Restart;
    649     }
    650     free(pciDa);
    651     free(pciSa);
    652     Runtime_Error(pszSrcFile, __LINE__, "numD %u != x %lu", numD, x);
    653     return;
    654   }
    655 
    656   pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
    657                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    658   x = 0;
    659   while (pciS && (INT)pciS != -1 && x < numS) {
    660     if (reset)
    661       pciS->flags = 0;
    662     pciSa[x] = pciS;
    663     x++;
    664     if (!slow)
    665       pciS = (PCNRITEM) pciS->rc.preccNextRecord;
    666     else
    667       pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pciS),
    668                                    MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    669     if (!(x % 500))
    670       DosSleep(0);  //26 Aug 07 GKY 1
    671     // else if (!(x % 50))
    672     //  DosSleep(0);
    673   } // while
    674 
    675   if (numS != x) {
    676     if (!slow) {
    677       slow = TRUE;
    678       goto Restart;
    679     }
    680     free(pciSa);
    681     free(pciDa);
    682     Runtime_Error(pszSrcFile, __LINE__, "numS (%lu) != x (%lu)", numS, x);
    683     return;
    684   }
    685 
    686   // 05 Aug 07 SHL fixme to know what sets reset
    687   if (reset) {
    688     // Update flags for files that exist on both sides
    689     for (x = 0; x < numS; x++) {
    690 
    691       // 05 Aug 07 SHL fixme to know if should clear first
    692       if (!*pciSa[x]->pszFileName || !*pciDa[x]->pszFileName)
    693         continue;
    694 
    695       pciSa[x]->flags |= CNRITEM_EXISTS;        // File exists on both sides
    696       pciDa[x]->flags |= CNRITEM_EXISTS;
    697       if (pciSa[x]->cbFile + pciSa[x]->easize >
    698           pciDa[x]->cbFile + pciDa[x]->easize) {
    699         pciSa[x]->flags |= CNRITEM_LARGER;
    700         pciDa[x]->flags |= CNRITEM_SMALLER;
    701       }
    702       else if (pciSa[x]->cbFile + pciSa[x]->easize <
    703                pciDa[x]->cbFile + pciDa[x]->easize) {
    704         pciSa[x]->flags |= CNRITEM_SMALLER;
    705         pciDa[x]->flags |= CNRITEM_LARGER;
    706       }
    707       ret = TestCDates(&pciDa[x]->date, &pciDa[x]->time,
    708                        &pciSa[x]->date, &pciSa[x]->time);
    709       if (ret == 1)
    710         /*((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE :
    711           (pciSa[x]->date.year < pciDa[x]->date.year) ? FALSE :
    712           (pciSa[x]->date.month > pciDa[x]->date.month) ? TRUE :
    713           (pciSa[x]->date.month < pciDa[x]->date.month) ? FALSE :
    714           (pciSa[x]->date.day > pciDa[x]->date.day) ? TRUE :
    715           (pciSa[x]->date.day < pciDa[x]->date.day) ? FALSE :
    716           (pciSa[x]->time.hours > pciDa[x]->time.hours) ? TRUE :
    717           (pciSa[x]->time.hours < pciDa[x]->time.hours) ? FALSE :
    718           (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? TRUE :
    719           (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? FALSE :
    720           (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? TRUE :
    721           (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? FALSE : FALSE)*/ {
    722         pciSa[x]->flags |= CNRITEM_NEWER;
    723         pciDa[x]->flags |= CNRITEM_OLDER;
    724       }
    725       else if (ret == -1)
    726         /*((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE :
    727                (pciSa[x]->date.year > pciDa[x]->date.year) ? FALSE :
    728                (pciSa[x]->date.month < pciDa[x]->date.month) ? TRUE :
    729                (pciSa[x]->date.month > pciDa[x]->date.month) ? FALSE :
    730                (pciSa[x]->date.day < pciDa[x]->date.day) ? TRUE :
    731                (pciSa[x]->date.day > pciDa[x]->date.day) ? FALSE :
    732                (pciSa[x]->time.hours < pciDa[x]->time.hours) ? TRUE :
    733                (pciSa[x]->time.hours > pciDa[x]->time.hours) ? FALSE :
    734                (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? TRUE :
    735                (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? FALSE :
    736                (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? TRUE :
    737                (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? FALSE :
    738                FALSE)*/ {
    739         pciSa[x]->flags |= CNRITEM_OLDER;
    740         pciDa[x]->flags |= CNRITEM_NEWER;
    741       }
    742       if (!(x % 500))
    743         DosSleep(0); //26 Aug 07 GKY 1
    744       // else if (!(x % 50))
    745       //        DosSleep(0);
    746     } // for
    747   } // if reset
    748 
    749   switch (action) {
    750   case IDM_SELECTIDENTICAL:
    751     for (x = 0; x < numS; x++) {
    752       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
    753           pciSa[x]->flags & CNRITEM_EXISTS &&
    754           ~pciSa[x]->flags & CNRITEM_SMALLER &&
    755           ~pciSa[x]->flags & CNRITEM_LARGER &&
    756           ~pciSa[x]->flags & CNRITEM_NEWER &&
    757           ~pciSa[x]->flags & CNRITEM_OLDER) {
    758         if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    759           WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    760                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    761         if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    762           WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    763                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    764       }
    765       if (!(x % 500))
    766         DosSleep(0); //26 Aug 07 GKY 1
    767       // else if (!(x % 50))
    768       //        DosSleep(0);
    769     } // for
    770     break;
    771 
    772   case IDM_SELECTSAME:
    773     for (x = 0; x < numS; x++) {
    774       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
    775           pciSa[x]->flags & CNRITEM_EXISTS &&
    776           ~pciSa[x]->flags & CNRITEM_SMALLER &&
    777           ~pciSa[x]->flags & CNRITEM_LARGER) {
    778         if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    779           WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    780                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    781         if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    782           WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    783                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    784       }
    785       if (!(x % 500))
    786         DosSleep(0); //26 Aug 07 GKY 1
    787       // else if (!(x % 50))
    788       //        DosSleep(0);
    789     }
    790     break;
    791 
    792   case IDM_SELECTSAMECONTENT:
    793     for (x = 0; x < numS; x++) {
    794       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
    795           pciSa[x]->flags & CNRITEM_EXISTS)
    796       {
    797         FILE *fp1 = NULL;
    798         FILE *fp2 = NULL;
    799         BOOL gotMatch = FALSE;
    800         UINT errLineNo = 0;
    801         UINT compErrno = 0;
    802         CHAR buf1[1024];
    803         CHAR buf2[1024];
    804         HAB hab = WinQueryAnchorBlock(hwndCnrS);
    805 
    806         if (!*pciSa[x]->pszFileName ||
    807             !*pciDa[x]->pszFileName) {
    808           Runtime_Error(pszSrcFile, __LINE__,
    809                         "CNRITEM_EXISTS set with null file name for index %u", x);
    810           break;
    811         }
    812 
    813         fp1 = _fsopen(pciSa[x]->pszFileName, "rb", SH_DENYNO);
    814         if (!fp1) {
    815           errLineNo = __LINE__;
    816           compErrno = errno;
    817         }
    818         else {
    819           fp2 = _fsopen(pciDa[x]->pszFileName, "rb", SH_DENYNO);
    820           if (!fp2) {
    821             errLineNo = __LINE__;
    822             compErrno = errno;
    823           }
    824           else {
    825             size_t len1 = filelength(fileno(fp1));
    826             size_t len2 = filelength(fileno(fp2));
    827 
    828             if (len1 == len2) {
    829               setbuf(fp1, NULL);
    830               setbuf(fp2, NULL);
    831               while (WinIsWindow(hab, hwndCnrS)) {
    832                 size_t numread1 = fread(buf1, 1, 1024, fp1);
    833                 size_t numread2 = fread(buf2, 1, 1024, fp2);
    834 
    835                 if (!numread1 || !numread2 || numread1 != numread2) {
    836                   if (ferror(fp1) || ferror(fp2)) {
    837                     errLineNo = __LINE__;
    838                     compErrno = errno;
    839                   }
    840                   else if (feof(fp1) && feof(fp2))
    841                     gotMatch = TRUE;
    842                   break;
    843                 }
    844                 else if (memcmp(buf1, buf2, numread1))
    845                   break;
    846               } // while
    847             } // same len
    848           }
    849         }
    850 
    851         if (fp1)
    852           fclose(fp1);
    853 
    854         if (fp2)
    855           fclose(fp2);
    856 
    857         if (errLineNo) {
    858           Runtime_Error(pszSrcFile, errLineNo,
    859                         "error %d while comparing", compErrno);
    860         }
    861 
    862         if (gotMatch) {
    863           if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    864             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    865                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    866           if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    867             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    868                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    869         }
    870       }
    871       if (!(x % 500))
    872         DosSleep(0); //26 Aug 07 GKY 1
    873       // else if (!(x % 50))
    874       //        DosSleep(0);
    875     } // for
    876     break;
    877 
    878   case IDM_SELECTBOTH:
    879     for (x = 0; x < numS; x++) {
    880       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
    881           pciSa[x]->flags & CNRITEM_EXISTS) {
    882         if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    883           WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    884                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    885         if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    886           WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    887                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    888       }
    889       if (!(x % 500))
    890         DosSleep(0); //26 Aug 07 GKY 1
    891       // else if (!(x % 50))
    892       //        DosSleep(0);
    893     }
    894     break;
    895 
    896   case IDM_SELECTONE:
    897     for (x = 0; x < numS; x++) {
    898       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
    899           ~pciSa[x]->flags & CNRITEM_EXISTS) {
    900         if (*pciSa[x]->pszFileName) {
    901           if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) {
    902             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    903                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    904           }
    905         }
    906         else if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) {
    907           WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    908                      MPFROM2SHORT(TRUE, CRA_SELECTED));
    909         }
    910       }
    911       if (!(x % 500))
    912         DosSleep(0);  //26 Aug 07 GKY 1
    913       // else if (!(x % 50))
    914       //        DosSleep(0);
    915     }
    916     break;
    917 
    918   case IDM_SELECTBIGGER:
    919     for (x = 0; x < numS; x++) {
    920       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    921         if (pciSa[x]->flags & CNRITEM_LARGER) {
    922           if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    923             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    924                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    925         }
    926         else if (pciDa[x]->flags & CNRITEM_LARGER) {
    927           if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    928             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    929                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    930         }
    931       }
    932       if (!(x % 500))
    933         DosSleep(0); //26 Aug 07 GKY 1
    934       // else if (!(x % 50))
    935       //        DosSleep(0);
    936     }
    937     break;
    938 
    939   case IDM_SELECTSMALLER:
    940     for (x = 0; x < numS; x++) {
    941       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    942         if (pciSa[x]->flags & CNRITEM_SMALLER) {
    943           if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    944             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    945                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    946         }
    947         else if (pciDa[x]->flags & CNRITEM_SMALLER) {
    948           if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    949             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    950                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    951         }
    952       }
    953       if (!(x % 500))
    954         DosSleep(0); //26 Aug 07 GKY 1
    955       // else if (!(x % 50))
    956       //        DosSleep(0);
    957     }
    958     break;
    959 
    960   case IDM_SELECTNEWER:
    961     for (x = 0; x < numS; x++) {
    962       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    963         if (pciSa[x]->flags & CNRITEM_NEWER) {
    964           if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    965             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    966                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    967         }
    968         else if (pciDa[x]->flags & CNRITEM_NEWER) {
    969           if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    970             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    971                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    972         }
    973       }
    974       if (!(x % 500))
    975         DosSleep(0); //26 Aug 07 GKY 1
    976       // else if (!(x % 50))
    977       //        DosSleep(0);
    978     }
    979     break;
    980 
    981   case IDM_SELECTOLDER:
    982     for (x = 0; x < numS; x++) {
    983       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    984         if (pciSa[x]->flags & CNRITEM_OLDER) {
    985           if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    986             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    987                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    988         }
    989         else if (pciDa[x]->flags & CNRITEM_OLDER) {
    990           if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    991             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    992                        MPFROM2SHORT(TRUE, CRA_SELECTED));
    993         }
    994       }
    995       if (!(x % 500))
    996         DosSleep(0); //26 Aug 07 GKY 1
    997       // else if (!(x % 50))
    998       //        DosSleep(0);
    999     }
    1000     break;
    1001 
    1002   case IDM_DESELECTBOTH:
    1003     for (x = 0; x < numS; x++) {
    1004       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
    1005           pciSa[x]->flags & CNRITEM_EXISTS) {
    1006         if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    1007           WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    1008                      MPFROM2SHORT(FALSE, CRA_SELECTED));
    1009         if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1010           WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    1011                      MPFROM2SHORT(FALSE, CRA_SELECTED));
    1012       }
    1013       if (!(x % 500))
    1014         DosSleep(0); //26 Aug 07 GKY 1
    1015       // else if (!(x % 50))
    1016       //        DosSleep(0);
    1017     }
    1018     break;
    1019 
    1020   case IDM_DESELECTONE:
    1021     for (x = 0; x < numS; x++) {
    1022       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    1023         if (~pciSa[x]->flags & CNRITEM_EXISTS) {
    1024         if (*pciSa[x]->pszFileName) {
    1025           if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    1026             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    1027                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1028         }
    1029         else if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1030             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    1031                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1032         }
    1033       }
    1034       if (!(x % 500))
    1035         DosSleep(0); //26 Aug 07 GKY 1
    1036       // else if (!(x % 50))
    1037       //        DosSleep(0);
    1038     }
    1039     break;
    1040 
    1041   case IDM_DESELECTBIGGER:
    1042     for (x = 0; x < numS; x++) {
    1043       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    1044         if (pciSa[x]->flags & CNRITEM_LARGER) {
    1045           if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    1046             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    1047                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1048         }
    1049         else if (pciDa[x]->flags & CNRITEM_LARGER) {
    1050           if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1051             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    1052                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1053         }
    1054       }
    1055       if (!(x % 500))
    1056         DosSleep(0); //26 Aug 07 GKY 1
    1057       // else if (!(x % 50))
    1058       //        DosSleep(0);
    1059     }
    1060     break;
    1061 
    1062   case IDM_DESELECTSMALLER:
    1063     for (x = 0; x < numS; x++) {
    1064       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    1065         if (pciSa[x]->flags & CNRITEM_SMALLER) {
    1066           if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    1067             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    1068                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1069         }
    1070         else if (pciDa[x]->flags & CNRITEM_SMALLER) {
    1071           if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1072             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    1073                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1074         }
    1075       }
    1076       if (!(x % 500))
    1077         DosSleep(0); //26 Aug 07 GKY 1
    1078       // else if (!(x % 50))
    1079       //        DosSleep(0);
    1080     }
    1081     break;
    1082 
    1083   case IDM_DESELECTNEWER:
    1084     for (x = 0; x < numS; x++) {
    1085       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    1086         if (pciSa[x]->flags & CNRITEM_NEWER) {
    1087           if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    1088             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    1089                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1090         }
    1091         else if (pciDa[x]->flags & CNRITEM_NEWER) {
    1092           if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1093             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    1094                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1095         }
    1096       }
    1097       if (!(x % 500))
    1098         DosSleep(0); //26 Aug 07 GKY 1
    1099       // else if (!(x % 50))
    1100       //        DosSleep(0);
    1101     }
    1102     break;
    1103 
    1104   case IDM_DESELECTOLDER:
    1105     for (x = 0; x < numS; x++) {
    1106       if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
    1107         if (pciSa[x]->flags & CNRITEM_OLDER) {
    1108           if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    1109             WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
    1110                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1111         }
    1112         else if (pciDa[x]->flags & CNRITEM_OLDER) {
    1113           if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1114             WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
    1115                        MPFROM2SHORT(FALSE, CRA_SELECTED));
    1116         }
    1117       }
    1118       if (!(x % 500))
    1119         DosSleep(0); //26 Aug 07 GKY 1
    1120       // else if (!(x % 50))
    1121       //        DosSleep(0);
    1122     }
    1123     break;
    1124 
    1125   default:
    1126     break;
    1127   }
    1128 
    1129   if (reset) {
    1130     while (numS) {
    1131       WinSendMsg(hwndCnrS, CM_INVALIDATERECORD,
    1132                  MPFROMP(pciSa), MPFROM2SHORT((min(numS, 65535)), 0));
    1133       DosSleep(0); //26 Aug 07 GKY 1
    1134       WinSendMsg(hwndCnrD, CM_INVALIDATERECORD,
    1135                  MPFROMP(pciDa), MPFROM2SHORT((min(numD, 65535)), 0));
    1136       numS -= min(numS, 65535);
    1137       if (numS)
    1138         DosSleep(0); //26 Aug 07 GKY 1
    1139     }
    1140   }
    1141 
    1142   free(pciSa);
    1143   free(pciDa);
    1144   DosPostEventSem(CompactSem);
    1145 }
    1146 
    1147580struct SS
    1148581{
     
    1286719              Cnrs[z].ss[x].largest = FALSE;
    1287720            cmp = TestCDates(&bsres->pci->date, &bsres->pci->time,
    1288                              &Cnrs[z].ss[x].pci->date, &Cnrs[z].ss[x].pci->time);
     721                             &Cnrs[z].ss[x].pci->date, &Cnrs[z].ss[x].pci->time);
    1289722              /*(Cnrs[z].ss[x].pci->date.year >
    1290723               bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year <
     
    1539972#pragma alloc_text(SELECT,SelectList)
    1540973#pragma alloc_text(SELECT1,Deselect,HideAll,RemoveAll,ExpandAll,InvertAll)
    1541 #pragma alloc_text(SELECT3,SpecialSelect)
    1542974#pragma alloc_text(SELECT4,FreeCnrs,SpecialSelect2,CompSSNames,CompSSNamesB)
Note: See TracChangeset for help on using the changeset viewer.