Changeset 907 for trunk/dll/dircnrs.c


Ignore:
Timestamp:
Jan 6, 2008, 8:26:17 AM (18 years ago)
Author:
Steven Levine
Message:

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r888 r907  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2007 Steven H. Levine
     9  Copyright (c) 2001, 2008 Steven H. Levine
    1010
    1111  16 Oct 02 SHL Handle large partitions
     
    3535***********************************************************************/
    3636
    37 #define INCL_DOS
    38 #define INCL_WIN
    39 #define INCL_GPI
    40 #define INCL_DOSERRORS
    41 #define INCL_LONGLONG
    42 
    43 #include <os2.h>
    44 #include <stdarg.h>
    45 #include <stdio.h>
    4637#include <stdlib.h>
    4738#include <string.h>
    4839#include <ctype.h>
    4940#include <limits.h>
    50 #include "fm3dll.h"
     41#include <process.h>                    // _beginthread
     42
     43#define INCL_DOS
     44#define INCL_WIN
     45#define INCL_DOSERRORS
     46#define INCL_LONGLONG
     47
    5148#include "fm3dlg.h"
    5249#include "fm3str.h"
    5350#include "mle.h"
    54 #include <process.h>                    // _beginthread
     51#include "arccnrs.h"                    // StartArcCnr
     52#include "comp.h"                       // COMPARE
     53#include "filldir.h"                    // EmptyCnr...
     54#include "errutil.h"                    // Dos_Error...
     55#include "strutil.h"                    // GetPString
     56#include "fm3dll.h"
    5557
    5658#pragma data_seg(DATA1)
     
    132134            }
    133135          }
    134           hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
    135           CopyPresParams(hwndButtonPopup, hwnd);
     136          hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
     137          CopyPresParams(hwndButtonPopup, hwnd);
    136138          if (hwndButtonPopup) {
    137139            WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
     
    596598      li =
    597599        DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID,
    598                    MPFROMP(&cni));
     600                   MPFROMP(&cni));
    599601      CheckPmDrgLimit(cni.pDragInfo);
    600602      if (li) {
     
    800802            !strnicmp(dcd->directory, dcd->previous,
    801803                      strlen(dcd->directory)))
    802         {
     804        {
    803805          PCNRITEM pci = FindCnrRecord(dcd->hwndCnr,
    804                                        dcd->previous,
     806                                       dcd->previous,
    805807                                       NULL, TRUE, FALSE, TRUE);
    806808          if (pci && (INT) pci != -1) {
     
    15541556      switch (SHORT1FROMMP(mp1)) {
    15551557      case IDM_FILESMENU:
    1556         CopyPresParams((HWND) mp2, hwndMainMenu);
    1557         if (isalpha(*dcd->directory)) {
     1558        CopyPresParams((HWND) mp2, hwndMainMenu);
     1559        if (isalpha(*dcd->directory)) {
    15581560          if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
    15591561            WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
     
    15781580            WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
    15791581            WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
    1580             WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
     1582            WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
    15811583          }
    15821584        }
     
    15841586
    15851587      case IDM_VIEWSMENU:
    1586         SetViewMenu((HWND) mp2, dcd->flWindowAttr);
     1588        SetViewMenu((HWND) mp2, dcd->flWindowAttr);
    15871589        CopyPresParams((HWND) mp2, hwndMainMenu);
    1588         WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
    1589                           (dcd->lastselection != NULL));
    1590         if (isalpha(*dcd->directory)) {
     1590        WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
     1591                          (dcd->lastselection != NULL));
     1592        if (isalpha(*dcd->directory)) {
    15911593          if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
    15921594            WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
     
    17271729                  dummy[1] = NULL;
    17281730                  ExecOnList(hwnd,
    1729                              editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
    1730                              pszSrcFile, __LINE__);
     1731                             editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
     1732                             pszSrcFile, __LINE__);
    17311733                }
    17321734                else
     
    22342236      case IDM_MKDIR:
    22352237        {
    2236          // PCNRITEM pci;
    2237 
    2238          // pci = (PCNRITEM) CurrentRecord(hwnd);
     2238          PCNRITEM pci;
     2239          BOOL saved;
     2240
     2241          saved = fSelectedAlways;
     2242          fSelectedAlways = FALSE;
     2243          pci = (PCNRITEM)CurrentRecord(hwnd);
     2244          // 01 Oct 07 SHL Make below selected directory or in current directory
    22392245          PMMkDir(dcd->hwndParent,
    2240                   (dcd->directory), FALSE);
     2246                  pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
     2247                  FALSE);
     2248          fSelectedAlways = saved;
    22412249        }
    22422250        break;
     
    25942602              memset(&volser, 0, sizeof(volser));
    25952603              DosError(FERR_DISABLEHARDERR);
    2596               // fixme
     2604              // fixme?
    25972605              rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
    25982606                                  FSIL_VOLSER, &volser, sizeof(volser));
     
    26092617                if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
    26102618                    !volser.serial ||
    2611                     driveserial[toupper(*pci->pszFileName) - 'A'] !=
     2619                    driveserial[toupper(*pci->pszFileName) - 'A'] !=
    26122620                    volser.serial)
    26132621                  UnFlesh(hwnd, pci);
     
    26472655                       CM_SETRECORDEMPHASIS,
    26482656                       MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
    2649             MarkAll(hwnd, FALSE, FALSE, TRUE);
    2650             if (pci->attrFile & FILE_DIRECTORY)
     2657            MarkAll(hwnd, FALSE, FALSE, TRUE);
     2658            if (pci->attrFile & FILE_DIRECTORY)
    26512659              dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
    26522660            else
     
    27322740          pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
    27332741          pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
    2734           if (!DrgAccessDraginfo(pDInfo)) {
    2735             Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    2736                       "DrgAccessDraginfo");
     2742          if (!DrgAccessDraginfo(pDInfo)) {
     2743            Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     2744                      "DrgAccessDraginfo");
    27372745              return (MRFROM2SHORT(DOR_NEVERDROP, 0));
    2738           }
    2739           if (*dcd->directory &&
     2746          }
     2747          if (*dcd->directory &&
    27402748             (driveflags[toupper(*dcd->directory) - 'A'] &
    27412749              DRIVE_NOTWRITEABLE)) {
     
    28522860          ULONG action = UM_ACTION;
    28532861
    2854           // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
    2855           li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
    2856           CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
     2862          // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
     2863          li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
     2864          CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
    28572865          if (li) {
    28582866            if (li->list && li->list[0] && IsRoot(li->list[0]))
     
    28882896              strcat(li->targetpath, " %a");
    28892897              ExecOnList(dcd->hwndParent, li->targetpath,
    2890                         PROMPT | WINDOWED, NULL, li->list, NULL,
    2891                         pszSrcFile, __LINE__);
     2898                        PROMPT | WINDOWED, NULL, li->list, NULL,
     2899                        pszSrcFile, __LINE__);
    28922900              FreeList(li->list);
    28932901              li->list = NULL;
     
    32633271
    32643272      HWND ret = StartMLEEditor(dcd->hwndParent,
    3265                                 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
     3273                                (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    32663274      if (mp2)
    32673275        free((CHAR *)mp2);
Note: See TracChangeset for help on using the changeset viewer.