Changeset 1681 for trunk/dll/comp.c


Ignore:
Timestamp:
Jan 6, 2013, 1:25:09 AM (13 years ago)
Author:
Gregg Young
Message:

Fix snapshot file to actually load and save (with/without subdirectories) properly. Toggle of include subdirectories leaves snapshot file loaded. Added an indicator (textbox) that a list (snapshot) file is loaded. Ticket 490

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r1673 r1681  
    8181  12 Aug 12 GKY Fix loading of a list file in the right compare container
    8282  12 Aug 12 GKY Allow for selection of include subdirectories or a list file on initial startup of compare dirs
     83  05 Jan 13 GKY Fix snapshot file to actually load and save (with/without subdirectories) properly.
     84  05 Jan 13 GKY Toggle of include subdirectories leaves snapshot file loaded.
     85  05 Jan 13 GKY Added an indicator (textbox) that a list (snapshot) file is loaded.
    8386
    8487***********************************************************************/
     
    185188          strcpy(enddir, pffb->achName);
    186189          if (!(pffb->attrFile & FILE_DIRECTORY)) {
    187             CommaFmtULL(szCmmaFmtFileSize,
    188                         sizeof(szCmmaFmtFileSize), pffb->cbFile, ' ');
     190            ulltoa(pffb->cbFile, szCmmaFmtFileSize, 10);
    189191            FDateFormat(szDate, pffb->fdateLastWrite);
    190192            fprintf(fp,
     
    237239      fp = xfopen(sf->filename, modew, pszSrcFile, __LINE__, FALSE);
    238240      if (fp) {
    239         fprintf(fp, "\"%s\"\n", sf->dirname);
     241        fprintf(fp, "\"%s\"\n", sf->dirname);
     242        //DbgMsg(pszSrcFile, __LINE__, "recurse %i", sf->recurse);
    240243        SnapShot(sf->dirname, fp, sf->recurse);
    241244        fclose(fp);
     
    15521555
    15531556      // Build list of all files in right directory
     1557      //DbgMsg(pszSrcFile, __LINE__, "list file %s", cmp->rightlist);
    15541558      if (!*cmp->rightlist) {
    15551559        if (fForceLower)
     
    15581562          strupr(cmp->rightdir);
    15591563        FillDirList(cmp->rightdir, lenr, cmp->includesubdirs,
    1560                     &filesr, &cmp->cmp->totalright, &numallocr);
     1564                    &filesr, &cmp->cmp->totalright, &numallocr);
    15611565      }
    15621566      else {
     
    15651569        FILEFINDBUF4L fb4;
    15661570        CHAR str[CCHMAXPATH * 2], *p;
    1567         CHAR *moder = "r";
     1571        CHAR *moder = "r";
    15681572
    15691573        memset(&fb4, 0, sizeof(fb4));
    15701574        fp = xfopen(cmp->rightlist, moder, pszSrcFile, __LINE__, FALSE);
    1571         if (fp) {
     1575        if (fp) {
    15721576          while (!feof(fp)) {
    15731577            // First get name of directory
     
    15991603
    16001604          memset(&cnri, 0, sizeof(cnri));
    1601           cnri.cb = sizeof(cnri);
     1605          cnri.cb = sizeof(cnri);
     1606          WinSetDlgItemText(cmp->hwnd, COMP_LISTLOADED, "List File Loaded");
    16021607          cnri.pszCnrTitle = cmp->rightdir;
    16031608          if (!WinSendMsg(hwndRight, CM_SETCNRINFO,
    16041609                     MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE))) {
    1605             Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_SETCNRINFO");
     1610            Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_SETCNRINFO");
     1611            WinSetDlgItemText(cmp->hwnd, COMP_LISTLOADED, "");
    16061612          }
    16071613
     
    16091615            lenr = strlen(cmp->rightdir);
    16101616            if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
    1611               lenr++;
    1612             while (!feof(fp)) {
     1617              lenr++;
     1618            //DbgMsg(pszSrcFile, __LINE__, "end of file %i", feof(fp));
     1619            while (!feof(fp)) {
    16131620              if (!xfgets_bstripcr
    1614                   (str, sizeof(str), fp, pszSrcFile, __LINE__))
    1615                 break;
     1621                  (str, sizeof(str), fp, pszSrcFile, __LINE__)) {
     1622                break;
     1623              }
    16161624              p = str;
    16171625              if (*p == '\"') {
     
    16191627                if (*p && *p != '\"') {
    16201628                  p = strchr(p, '\"');
    1621                   if (p) {
     1629                  if (p) {
    16221630                    *p = 0;
    16231631                    p++;
    1624                     if (*p == ',') {
     1632                    if (*p == ',') {
    16251633                      p++;
    16261634                      if (!cmp->includesubdirs && atol(p) > lenr)
    16271635                        continue;
    16281636                      p = strchr(p, ',');
    1629                       if (p) {
     1637                      if (p) {
    16301638                        p++;
    1631                         // 27 Sep 07 SHL fixme to do ULONGLONG conversion
    1632                         fb4.cbFile = atol(p);
     1639                        fb4.cbFile = atoll(p);
    16331640                        p = strchr(p, ',');
    1634                         if (p) {
    1635                           p++;
    1636                           fb4.fdateLastWrite.year = atol(p) - 1980;
    1637                           p = strchr(p, '/');
    1638                           if (p) {
    1639                             p++;
    1640                             fb4.fdateLastWrite.month = atol(p);
    1641                             p = strchr(p, '/');
    1642                             if (p) {
    1643                               p++;
    1644                               fb4.fdateLastWrite.day = atol(p);
     1641                        if (p) {
     1642                          p++;
     1643                          if (ulDateFmt == 2 || ulDateFmt == 3)
     1644                            fb4.fdateLastWrite.year = atol(p) - 1980;
     1645                          if (ulDateFmt == 1)
     1646                            fb4.fdateLastWrite.day = atol(p);
     1647                          else
     1648                            fb4.fdateLastWrite.month = atol(p);
     1649                          p = strchr(p, DateSeparator[0]);
     1650                          if (p) {
     1651                            p++;
     1652                            if (ulDateFmt == 2 || ulDateFmt == 3)
     1653                              fb4.fdateLastWrite.month = atol(p);
     1654                            else
     1655                              fb4.fdateLastWrite.day = atol(p);
     1656                            p = strchr(p, DateSeparator[0]);
     1657                            if (p) {
     1658                              p++;
     1659                              if (ulDateFmt == 2)
     1660                                fb4.fdateLastWrite.day = atol(p);
     1661                              if (ulDateFmt == 3)
     1662                                fb4.fdateLastWrite.month = atol(p);
     1663                              else
     1664                                fb4.fdateLastWrite.year = atol(p) - 1980;
    16451665                              p = strchr(p, ',');
    1646                               if (p) {
     1666                              if (p) {
    16471667                                p++;
    16481668                                fb4.ftimeLastWrite.hours = atol(p);
    1649                                 p = strchr(p, ':');
    1650                                 if (p) {
     1669                                p = strchr(p, TimeSeparator[0]);
     1670                                if (p) {
    16511671                                  p++;
    16521672                                  fb4.ftimeLastWrite.minutes = atol(p);
    1653                                   p = strchr(p, ':');
    1654                                   if (p) {
     1673                                  p = strchr(p, TimeSeparator[0]);
     1674                                  if (p) {
    16551675                                    p++;
    16561676                                    fb4.ftimeLastWrite.twosecs = atol(p);
    16571677                                    p = strchr(p, ',');
    1658                                     if (p) {
     1678                                    if (p) {
    16591679                                      p++;
    16601680                                      fb4.attrFile = atol(p);
    16611681                                      p = strchr(p, ',');
    1662                                       if (p) {
     1682                                      if (p) {
    16631683                                        p++;
    16641684                                        fb4.cbList = atol(p) * 2;
     
    16661686                                          strupr(str + 1);
    16671687                                        else if (fForceLower)
    1668                                           strlwr(str + 1);
     1688                                          strlwr(str + 1);
    16691689                                        if (AddToFileList((str + 1) + lenr,
    16701690                                                          &fb4,
     
    16881708            } // while
    16891709          } // if have rightdir
    1690           fclose(fp);
     1710          fclose(fp);
    16911711        }
    1692         FillDirList(cmp->rightdir, lenr, cmp->includesubdirs,
    1693                     &filesr, &cmp->cmp->totalright, &numallocr);
    16941712      } // if snapshot file
    16951713
    16961714      if (filesr)
    1697         qsort(filesr, cmp->cmp->totalright, sizeof(CHAR *), CompNames);
     1715        qsort(filesr, cmp->cmp->totalright, sizeof(CHAR *), CompNames);
    16981716
    16991717      // We now have two lists of files, both sorted.
     
    24992517      case BN_CLICKED:
    25002518        cmp = INSTDATA(hwnd);
    2501         if (cmp)
    2502           *cmp->rightlist = 0;
     2519        //if (cmp)
     2520        //  *cmp->rightlist = 0;
    25032521        PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
    25042522        PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
     
    27032721                          CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
    27042722      WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
    2705                         MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
     2723                        MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
     2724      WinSetDlgItemText(hwnd, COMP_LISTLOADED, "");
    27062725      cnri.pszCnrTitle = cmp->rightdir;
    27072726      WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
     
    30463065              strcpy(sf->dirname, cmp->leftdir);
    30473066            else
    3048               strcpy(sf->dirname, cmp->rightdir);
    3049             sf->recurse = cmp->includesubdirs;
     3067              strcpy(sf->dirname, cmp->rightdir);
     3068            cmp->includesubdirs = WinQueryButtonCheckstate(hwnd,
     3069                                                           COMP_INCLUDESUBDIRS);
     3070            sf->recurse = cmp->includesubdirs;
     3071            //DbgMsg(pszSrcFile, __LINE__, "recurse %i %i", sf->recurse, cmp->includesubdirs);
    30503072            if (xbeginthread(StartSnapThread,
    30513073                             65536,
Note: See TracChangeset for help on using the changeset viewer.