Changeset 1354 for trunk/dll/comp.c


Ignore:
Timestamp:
Dec 25, 2008, 11:43:34 PM (17 years ago)
Author:
Gregg Young
Message:

Added driveflags to over ride write verify for USB removable drives that fail when it is on (Ticket 323); A flag to prevent directory name from being broadcast to drives in the tree cnr prior to a recursive scan of the drive (causes dbl directory names Ticket 321) Add option for multithreaded recursive scan of user selected drives at startup (Ticket 322).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r1335 r1354  
    6666#include <share.h>
    6767#include <io.h>
     68#include <ctype.h>
    6869// #include <process.h>                 // _endthread
    6970
     
    115116#include "fortify.h"                    // 06 May 08 SHL added
    116117#include "excputil.h"                   // xbeginthread
     118#include "info.h"                       // driveflags
    117119
    118120typedef struct
     
    549551            break;
    550552
    551           case IDM_MOVE:
    552             if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
    553               BldFullPathName(szNewName, cmp->leftdir, pciS->pszDisplayName);
    554             else
    555               BldFullPathName(szNewName, cmp->rightdir, pciS->pszDisplayName);
    556             // Make directory if required
    557             strcpy(szDirName, szNewName);
    558             p = strrchr(szDirName, '\\');
    559             if (p) {
    560               if (p > szDirName + 2)
    561                 p++;
    562               *p = 0;
    563               if (IsFile(szDirName) == -1)
    564                 MassMkdir(hwndMain, szDirName);
    565             }
    566             rc = docopyf(MOVE, pciS->pszFileName, "%s", szNewName);
    567             if (!rc && stricmp(pciS->pszFileName, szNewName)) {
    568               WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS),
    569                          MPFROM2SHORT(FALSE, CRA_SELECTED));
    570               if (pciD->rc.flRecordAttr & CRA_SELECTED)
    571                 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
    572                            MPFROM2SHORT(FALSE, CRA_SELECTED));
    573               FreeCnrItemData(pciD);
    574               pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
    575               if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
    576                 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
    577                 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
    578                   pciD->pszDisplayName++;
    579               }
    580               else {
    581                 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
    582                 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
    583                   pciD->pszDisplayName++;
    584               }
    585               pciD->pszLongName = pciS->pszLongName;
    586               pciS->pszLongName = NullStr;      // 07 Sep 08 SHL avoid aliased pointer
    587               if (pciD->pszSubject != NullStr) {
    588                 xfree(pciD->pszSubject, pszSrcFile, __LINE__);
    589                 pciD->pszSubject = NullStr;
    590               }
    591               pciD->attrFile = pciS->attrFile;
    592               pciD->pszDispAttr = pciS->pszDispAttr;
    593               pciD->flags = 0;          // Just on one side
    594               pciD->date = pciS->date;
    595               pciD->time = pciS->time;
    596               pciD->ladate = pciS->ladate;
    597               pciD->latime = pciS->latime;
    598               pciD->crdate = pciS->crdate;
    599               pciD->crtime = pciS->crtime;
    600               pciD->cbFile = pciS->cbFile;
    601               pciD->easize = pciS->easize;
    602 
    603               if (pciS->pszFileName != NullStr) {
    604                 xfree(pciS->pszFileName, pszSrcFile, __LINE__);
    605                 pciS->pszFileName = NullStr;
    606                 pciS->pszDisplayName = pciS->pszFileName;
    607                 pciS->rc.pszIcon = pciS->pszFileName;
    608               }
    609               if (pciS->pszSubject != NullStr) {
    610                 xfree(pciS->pszSubject, pszSrcFile, __LINE__);
    611                 pciS->pszSubject = NullStr;
    612               }
    613               pciS->flags = 0;          // Just on one side
    614 
    615               WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
    616                          MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    617 
    618               WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
    619                          MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    620 
    621               if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
    622                 cmp->cmp->totalleft--;
    623               else
    624                 cmp->cmp->totalright--;
    625             }
    626             else if (rc) {
    627               rc = Dos_Error(MB_ENTERCANCEL,
    628                              rc,
    629                              HWND_DESKTOP,
    630                              pszSrcFile,
    631                              __LINE__,
    632                              GetPString(IDS_COMPMOVEFAILEDTEXT),
    633                              pciS->pszFileName, szNewName);
    634               if (rc == MBID_CANCEL)    // Cause loop to break
    635                 pciNextS = NULL;
    636             }
    637             break;
    638 
    639           case IDM_COPY:
    640             if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
    641               BldFullPathName(szNewName, cmp->leftdir, pciS->pszDisplayName);
    642             else
    643               BldFullPathName(szNewName, cmp->rightdir, pciS->pszDisplayName);
    644             // Make directory if required
    645             strcpy(szDirName, szNewName);
    646             p = strrchr(szDirName, '\\');
    647             if (p) {
    648               if (p > szDirName + 2)
    649                 p++;
    650               *p = 0;
    651               if (IsFile(szDirName) == -1)
    652                 MassMkdir(hwndMain, szDirName);
    653             }
    654             rc = docopyf(COPY, pciS->pszFileName, "%s", szNewName);
    655             if (rc) {
    656               rc = Dos_Error(MB_ENTERCANCEL,
    657                              rc,
    658                              HWND_DESKTOP,
    659                              pszSrcFile,
    660                              __LINE__,
    661                              GetPString(IDS_COMPCOPYFAILEDTEXT),
    662                              pciS->pszFileName, szNewName);
    663               if (rc == MBID_CANCEL)
    664                 pciNextS = NULL;        // Cause loop to break
    665             }
    666             else {
    667               WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS),
    668                          MPFROM2SHORT(FALSE, CRA_SELECTED));
    669               if (pciD->rc.flRecordAttr & CRA_SELECTED)
    670                 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
    671                            MPFROM2SHORT(FALSE, CRA_SELECTED));
    672               // 12 Jan 08 SHL
    673               if (pciD->pszFileName == NullStr) {
    674                 if (hwndCnrD == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
    675                   cmp->totalleft++;
    676                 else
    677                   cmp->totalright++;
    678               }
    679               FreeCnrItemData(pciD);
    680               pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
    681               if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
    682                 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
    683                 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
    684                   pciD->pszDisplayName++;
    685               }
    686               else {
    687                 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
    688                 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
    689                   pciD->pszDisplayName++;
    690               }
    691               pciD->attrFile = pciS->attrFile;
    692               pciD->pszDispAttr = pciS->pszDispAttr;
    693               pciD->flags = CNRITEM_EXISTS;     // Now on both sides
    694               pciD->date = pciS->date;
    695               pciD->time = pciS->time;
    696               pciD->ladate = pciS->ladate;
    697               pciD->latime = pciS->latime;
    698               pciD->crdate = pciS->crdate;
    699               pciD->crtime = pciS->crtime;
    700               pciD->cbFile = pciS->cbFile;
    701               pciD->easize = pciS->easize;
    702 
    703               // Forget status until we regenerate it
    704               if (pciS->pszSubject != NullStr) {
    705                 xfree(pciS->pszSubject, pszSrcFile, __LINE__);
    706                 pciS->pszSubject = NullStr;
    707               }
    708               pciS->flags = CNRITEM_EXISTS;     // Now on both sides
    709 
    710               WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
    711                          MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    712               WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
    713                          MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    714             }
    715             break;
     553          case IDM_MOVE:
     554            {
     555              BOOL fResetVerify = FALSE;
     556
     557              if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
     558                BldFullPathName(szNewName, cmp->leftdir, pciS->pszDisplayName);
     559              else
     560                BldFullPathName(szNewName, cmp->rightdir, pciS->pszDisplayName);
     561              // Make directory if required
     562              strcpy(szDirName, szNewName);
     563              p = strrchr(szDirName, '\\');
     564              if (fVerify && (driveflags[toupper(*szNewName) - 'A'] & DRIVE_WRITEVERIFYOFF ||
     565                              driveflags[toupper(*pciS->pszFileName) - 'A'] & DRIVE_WRITEVERIFYOFF)) {
     566                DosSetVerify(FALSE);
     567                fResetVerify = TRUE;
     568              }
     569              if (p) {
     570                if (p > szDirName + 2)
     571                  p++;
     572                *p = 0;
     573                if (IsFile(szDirName) == -1)
     574                  MassMkdir(hwndMain, szDirName);
     575              }
     576              rc = docopyf(MOVE, pciS->pszFileName, "%s", szNewName);
     577              if (fResetVerify) {
     578                DosSetVerify(fVerify);
     579                fResetVerify = FALSE;
     580              }
     581              if (!rc && stricmp(pciS->pszFileName, szNewName)) {
     582                WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS),
     583                           MPFROM2SHORT(FALSE, CRA_SELECTED));
     584                if (pciD->rc.flRecordAttr & CRA_SELECTED)
     585                  WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
     586                             MPFROM2SHORT(FALSE, CRA_SELECTED));
     587                FreeCnrItemData(pciD);
     588                pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
     589                if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
     590                  pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
     591                  if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
     592                    pciD->pszDisplayName++;
     593                }
     594                else {
     595                  pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
     596                  if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
     597                    pciD->pszDisplayName++;
     598                }
     599                pciD->pszLongName = pciS->pszLongName;
     600                pciS->pszLongName = NullStr;    // 07 Sep 08 SHL avoid aliased pointer
     601                if (pciD->pszSubject != NullStr) {
     602                  xfree(pciD->pszSubject, pszSrcFile, __LINE__);
     603                  pciD->pszSubject = NullStr;
     604                }
     605                pciD->attrFile = pciS->attrFile;
     606                pciD->pszDispAttr = pciS->pszDispAttr;
     607                pciD->flags = 0;                // Just on one side
     608                pciD->date = pciS->date;
     609                pciD->time = pciS->time;
     610                pciD->ladate = pciS->ladate;
     611                pciD->latime = pciS->latime;
     612                pciD->crdate = pciS->crdate;
     613                pciD->crtime = pciS->crtime;
     614                pciD->cbFile = pciS->cbFile;
     615                pciD->easize = pciS->easize;
     616
     617                if (pciS->pszFileName != NullStr) {
     618                  xfree(pciS->pszFileName, pszSrcFile, __LINE__);
     619                  pciS->pszFileName = NullStr;
     620                  pciS->pszDisplayName = pciS->pszFileName;
     621                  pciS->rc.pszIcon = pciS->pszFileName;
     622                }
     623                if (pciS->pszSubject != NullStr) {
     624                  xfree(pciS->pszSubject, pszSrcFile, __LINE__);
     625                  pciS->pszSubject = NullStr;
     626                }
     627                pciS->flags = 0;                // Just on one side
     628
     629                WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
     630                           MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
     631
     632                WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
     633                           MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
     634
     635                if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
     636                  cmp->cmp->totalleft--;
     637                else
     638                  cmp->cmp->totalright--;
     639              }
     640              else if (rc) {
     641                rc = Dos_Error(MB_ENTERCANCEL,
     642                               rc,
     643                               HWND_DESKTOP,
     644                               pszSrcFile,
     645                               __LINE__,
     646                               GetPString(IDS_COMPMOVEFAILEDTEXT),
     647                               pciS->pszFileName, szNewName);
     648                if (rc == MBID_CANCEL)  // Cause loop to break
     649                  pciNextS = NULL;
     650              }
     651              break;
     652            }
     653
     654          case IDM_COPY:
     655            {
     656              BOOL fResetVerify = FALSE;
     657
     658              if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
     659                BldFullPathName(szNewName, cmp->leftdir, pciS->pszDisplayName);
     660              else
     661                BldFullPathName(szNewName, cmp->rightdir, pciS->pszDisplayName);
     662              // Make directory if required
     663              strcpy(szDirName, szNewName);
     664              p = strrchr(szDirName, '\\');
     665              if (fVerify && (driveflags[toupper(*szNewName) - 'A'] & DRIVE_WRITEVERIFYOFF ||
     666                                driveflags[toupper(*pciS->pszFileName) - 'A'] & DRIVE_WRITEVERIFYOFF)) {
     667                DosSetVerify(FALSE);
     668                fResetVerify = TRUE;
     669              }
     670              if (p) {
     671                if (p > szDirName + 2)
     672                  p++;
     673                *p = 0;
     674                if (IsFile(szDirName) == -1)
     675                  MassMkdir(hwndMain, szDirName);
     676              }
     677              rc = docopyf(COPY, pciS->pszFileName, "%s", szNewName);
     678              if (fResetVerify) {
     679                DosSetVerify(fVerify);
     680                fResetVerify = FALSE;
     681              }
     682              if (rc) {
     683                rc = Dos_Error(MB_ENTERCANCEL,
     684                               rc,
     685                               HWND_DESKTOP,
     686                               pszSrcFile,
     687                               __LINE__,
     688                               GetPString(IDS_COMPCOPYFAILEDTEXT),
     689                               pciS->pszFileName, szNewName);
     690                if (rc == MBID_CANCEL)
     691                  pciNextS = NULL;      // Cause loop to break
     692              }
     693              else {
     694                WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS),
     695                           MPFROM2SHORT(FALSE, CRA_SELECTED));
     696                if (pciD->rc.flRecordAttr & CRA_SELECTED)
     697                  WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
     698                             MPFROM2SHORT(FALSE, CRA_SELECTED));
     699                // 12 Jan 08 SHL
     700                if (pciD->pszFileName == NullStr) {
     701                  if (hwndCnrD == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
     702                    cmp->totalleft++;
     703                  else
     704                    cmp->totalright++;
     705                }
     706                FreeCnrItemData(pciD);
     707                pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
     708                if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
     709                  pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
     710                  if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
     711                    pciD->pszDisplayName++;
     712                }
     713                else {
     714                  pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
     715                  if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
     716                    pciD->pszDisplayName++;
     717                }
     718                pciD->attrFile = pciS->attrFile;
     719                pciD->pszDispAttr = pciS->pszDispAttr;
     720                pciD->flags = CNRITEM_EXISTS;   // Now on both sides
     721                pciD->date = pciS->date;
     722                pciD->time = pciS->time;
     723                pciD->ladate = pciS->ladate;
     724                pciD->latime = pciS->latime;
     725                pciD->crdate = pciS->crdate;
     726                pciD->crtime = pciS->crtime;
     727                pciD->cbFile = pciS->cbFile;
     728                pciD->easize = pciS->easize;
     729
     730                // Forget status until we regenerate it
     731                if (pciS->pszSubject != NullStr) {
     732                  xfree(pciS->pszSubject, pszSrcFile, __LINE__);
     733                  pciS->pszSubject = NullStr;
     734                }
     735                pciS->flags = CNRITEM_EXISTS;   // Now on both sides
     736
     737                WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
     738                           MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
     739                WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
     740                           MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
     741              }
     742              break;
     743            }
    716744
    717745          default:
Note: See TracChangeset for help on using the changeset viewer.