Changeset 773 for trunk/dll/comp.c


Ignore:
Timestamp:
Aug 7, 2007, 11:23:27 PM (18 years ago)
Author:
Steven Levine
Message:

Correct some compare directories collector nits
Use BldQuoted... functions
Move BldQuoted... functions near primary callers
Add RUNTYPE_MASK
Use Runtime_Error2 more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r771 r773  
    2828  01 Aug 07 SHL Rework to remove vast amount of duplicate code
    2929  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
     30  06 Aug 07 SHL Move BldFullPathName here to be near primary caller
     31  07 Aug 07 SHL COMP_COLLECT: Avoid collecting empty entries when nothing selected
    3032
    3133***********************************************************************/
     
    4951#include "fm3str.h"
    5052
    51 #pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames)
     53#pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames,BldFullPathName)
    5254#pragma alloc_text(COMPAREDIR1,CompareDlgProc)
    5355#pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
     
    6466
    6567static PSZ pszSrcFile = __FILE__;
     68
     69/**
     70 * Build full path name in callers buffer given directory
     71 * name and filename
     72 * @param pszPathName points to drive/directory if not NULL
     73 * @returns pointer to full path name in caller's buffer
     74 * @note OK for pszFullPathName and pszPathName to point to same buffer
     75 *
     76 */
     77
     78PSZ BldFullPathName(PSZ pszFullPathName, PSZ pszPathName, PSZ pszFileName)
     79{
     80  UINT c = pszPathName ? strlen(pszPathName) : 0;
     81  if (c > 0) {
     82    memcpy(pszFullPathName, pszPathName, c);
     83    if (pszFullPathName[c - 1] != '\\')
     84      pszFullPathName[c++] = '\\';
     85  }
     86  strcpy(pszFullPathName + c, pszFileName);
     87  return pszFullPathName;
     88}
    6689
    6790//=== SnapShot() Write directory tree to file and recurse if requested ===
     
    361384
    362385  if (!cmp) {
    363     Runtime_Error(pszSrcFile, __LINE__, "no data");
     386    Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    364387    return;
    365388  }
     
    458481          case IDM_MOVE:
    459482            if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
    460               // 02 Aug 07 SHL fixme to replace this kind of stuff with _makepath or equivalent
    461483              BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName);
    462484              //sprintf(szNewName, "%s%s%s",
     
    716738
    717739  if (!str || !*str) {
    718     Runtime_Error(pszSrcFile, __LINE__, "no data");
     740    Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    719741    return;
    720742  }
     
    818840
    819841  if (!cmp) {
    820     Runtime_Error(pszSrcFile, __LINE__, "no data");
     842    Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    821843    _endthread();
    822844  }
     
    11361158          if (x >= 0) {
    11371159            // File appears on right side
    1138             BldFullPathName(szBuf, cmp->rightdir, filesl[r]->fname);
     1160            BldFullPathName(szBuf, cmp->rightdir, filesr[r]->fname);
    11391161            //sprintf(szBuf, "%s%s%s", cmp->rightdir,
    11401162            //        (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
     
    13601382}
    13611383
    1362 #define hwndLeft  (WinWindowFromID(hwnd,COMP_LEFTDIR))
    1363 #define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
     1384// fixme to be gone - use variable
     1385#define hwndLeft        (WinWindowFromID(hwnd,COMP_LEFTDIR))
     1386#define hwndRight       (WinWindowFromID(hwnd,COMP_RIGHTDIR))
    13641387
    13651388//=== CompareDlgProc() Compare directories dialog procedure ===
     
    13681391{
    13691392  COMPARE *cmp;
    1370 
    1371   static HPOINTER hptr = (HPOINTER) 0;
     1393  BOOL temp;
     1394
     1395  static HPOINTER hptr;
    13721396
    13731397  switch (msg) {
     
    23762400    case COMP_COLLECT:
    23772401      cmp = INSTDATA(hwnd);
    2378       if (cmp) {
    2379 
    2380         CHAR **listl, **listr = NULL;
    2381 
     2402      if (!cmp)
     2403        Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     2404      else {
     2405        CHAR **listl;
     2406        CHAR **listr = NULL;
    23822407        if (!Collector) {
    2383 
    23842408          SWP swp;
    23852409          HWND hwndC;
    2386 
    2387           if (!fAutoTile && !ParentIsDesktop(hwnd, cmp->hwndParent) &&
    2388               (!fExternalCollector && !strcmp(realappname, FM3Str)))
     2410          if (!fAutoTile &&
     2411               !ParentIsDesktop(hwnd, cmp->hwndParent) &&
     2412               !fExternalCollector &&
     2413               !strcmp(realappname, FM3Str)) {
    23892414            GetNextWindowPos(cmp->hwndParent, &swp, NULL, NULL);
    2390           hwndC = StartCollector((fExternalCollector ||
    2391                                   strcmp(realappname, FM3Str)) ?
    2392                                  HWND_DESKTOP : cmp->hwndParent, 4);
     2415          }
     2416          hwndC = StartCollector(fExternalCollector ||
     2417                                 strcmp(realappname, FM3Str) ?
     2418                                   HWND_DESKTOP :
     2419                                   cmp->hwndParent,
     2420                                 4);
    23932421          if (hwndC) {
    2394             if (!fAutoTile && !ParentIsDesktop(hwnd, cmp->hwndParent) &&
    2395                 (!fExternalCollector && !strcmp(realappname, FM3Str)))
    2396               WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
    2397                               swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
    2398                               SWP_SHOW | SWP_ZORDER);
    2399             else if (!ParentIsDesktop(hwnd, cmp->hwndParent) && fAutoTile &&
    2400                      !strcmp(realappname, FM3Str))
     2422            if (!fAutoTile &&
     2423                !ParentIsDesktop(hwnd, cmp->hwndParent) &&
     2424                !fExternalCollector &&
     2425                !strcmp(realappname, FM3Str)) {
     2426              WinSetWindowPos(hwndC, HWND_TOP,
     2427                              swp.x, swp.y, swp.cx, swp.cy,
     2428                              SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     2429            }
     2430            else if (!ParentIsDesktop(hwnd, cmp->hwndParent) &&
     2431                     fAutoTile &&
     2432                     !strcmp(realappname, FM3Str)) {
    24012433              TileChildren(cmp->hwndParent, TRUE);
    2402             DosSleep(32); //05 Aug 07 GKY 64
     2434            }
     2435            DosSleep(32); // 05 Aug 07 GKY 64
    24032436            PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
    24042437            break;
     
    24072440        else
    24082441          StartCollector(cmp->hwndParent, 4);
    2409         {
    2410           BOOL temp;
    2411 
    2412           temp = fSelectedAlways;
    2413           fSelectedAlways = TRUE;
    2414           listl = BuildList(hwndLeft);
    2415           if (!*cmp->rightlist)
    2416             listr = BuildList(hwndRight);
    2417           fSelectedAlways = temp;
    2418         }
     2442
     2443        temp = fSelectedAlways;
     2444        fSelectedAlways = TRUE;
     2445        listl = BuildList(hwndLeft);
     2446        if (!*cmp->rightlist)
     2447          listr = BuildList(hwndRight);
     2448        fSelectedAlways = temp;
     2449
    24192450        if (listl || listr) {
    24202451          if (Collector) {
    2421             if (listl) {
    2422               if (!PostMsg(Collector, WM_COMMAND,
    2423                            MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listl)))
    2424                 FreeList(listl);
    2425             }
    2426             if (listr) {
    2427               if (!PostMsg(Collector, WM_COMMAND,
    2428                            MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listr)))
    2429                 FreeList(listr);
     2452            // 07 Aug 07 SHL Avoid collected from empty list
     2453            if (listl && listl[0] && *listl[0]) {
     2454              if (PostMsg(Collector, WM_COMMAND,
     2455                          MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listl)))
     2456                listl = NULL;           // Collector will free
     2457            }
     2458            if (listr && listr[0] && *listr[0]) {
     2459              if (PostMsg(Collector, WM_COMMAND,
     2460                          MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listr)))
     2461                listr = NULL;           // Collector will free
    24302462            }
    24312463            WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
    24322464                                                          QW_PARENT),
    2433                                            QW_PARENT), HWND_TOP, 0, 0, 0, 0,
     2465                                           QW_PARENT),
     2466                            HWND_TOP, 0, 0, 0, 0,
    24342467                            SWP_ACTIVATE);
    24352468          }
    2436           else {
    2437             FreeList(listl);
    2438             FreeList(listr);
    2439           }
     2469          FreeList(listl);
     2470          FreeList(listr);
    24402471        }
    24412472      }
Note: See TracChangeset for help on using the changeset viewer.