Changeset 907 for trunk/dll/arccnrs.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/arccnrs.c

    r906 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  11 Jun 02 SHL Ensure archive name not garbage
     
    5252***********************************************************************/
    5353
     54#include <stdlib.h>                     // free..
     55#include <string.h>
     56#include <ctype.h>
     57#include <direct.h>                     // rmdir
     58#include <share.h>                      // SH_DENYWR
     59#include <limits.h>                     // ULONG_MAX
     60#include <process.h>                    // _beginthread
     61
     62#if 0
     63#include <malloc.h>                     // _heapchk
     64#endif
     65
    5466#define INCL_DOS
    5567#define INCL_DOSERRORS
    5668#define INCL_WIN
    57 #define INCL_GPI
    5869#define INCL_LONGLONG
    59 #include <os2.h>
    60 
    61 #include <stdarg.h>
    62 #include <stdio.h>
    63 #include <stdlib.h>
    64 #include <string.h>
    65 #include <ctype.h>
    66 #include <time.h>
    67 #include <direct.h>
    68 #include <share.h>
    69 #include <limits.h>
    70 #include <process.h>                    // _beginthread
    71 
    72 #if 0
    73 #include <malloc.h>                     // _heapchk
    74 #endif
    75 
    76 #include "fm3dll.h"
     70
     71#include "arccnrs.h"                    // StartArcCnr
    7772#include "fm3dlg.h"
    7873#include "fm3str.h"
    7974#include "mle.h"
     75#include "pathutil.h"                   // BldFullPathName
     76#include "filldir.h"                    // EmptyCnr...
     77#include "errutil.h"                    // Dos_Error...
     78#include "strutil.h"                    // GetPString
     79#include "fm3dll.h"
    8080
    8181#pragma data_seg(DATA1)
     
    8383static INT DefArcSortFlags;
    8484static PSZ pszSrcFile = __FILE__;
    85 
    86 /**
    87  * Build quoted full path name in callers buffer given
    88  * directory name and filename
    89  * @param pszPathName points to drive/directory if not NULL
    90  * @returns pointer to quoted path name in caller's buffer
    91  */
    92 
    93 PSZ BldQuotedFullPathName(PSZ pszFullPathName, PSZ pszPathName, PSZ pszFileName)
    94 {
    95   UINT c = pszPathName ? strlen(pszPathName) : 0;
    96   BOOL q = needs_quoting(pszPathName) ||
    97            needs_quoting(pszFileName);
    98   PSZ psz = pszFullPathName;
    99 
    100   if (q)
    101     *psz++ = '"';
    102   if (c > 0) {
    103     memcpy(psz, pszPathName, c);
    104     psz += c;
    105     if (*(psz - 1) != '\\')
    106       *psz++ = '\\';
    107   }
    108   strcpy(psz, pszFileName);
    109   if (q) {
    110     psz += strlen(psz);
    111     *psz++ = '"';
    112     *psz = 0;
    113   }
    114   return pszFullPathName;
    115 }
    116 
    117 /**
    118  * Build quoted full path name in callers buffer given a filename
    119  * @returns pointer to quoted file name in caller's buffer
    120  */
    121 
    122 PSZ BldQuotedFileName(PSZ pszQuotedFileName, PSZ pszFileName)
    123 {
    124   BOOL q = needs_quoting(pszFileName);
    125   PSZ psz = pszQuotedFileName;
    126 
    127   if (q)
    128     *psz++ = '"';
    129   strcpy(psz, pszFileName);
    130   if (q) {
    131     psz += strlen(psz);
    132     *psz++ = '"';
    133     *psz = 0;
    134   }
    135   return pszQuotedFileName;
    136 }
    13785
    13886static MRESULT EXPENTRY ArcErrProc(HWND hwnd, ULONG msg, MPARAM mp1,
     
    202150          if (*viewer) {
    203151            ExecOnList((HWND) 0, viewer, WINDOWED | SEPARATE |
    204                             (fViewChild ? CHILD : 0),
    205                              NULL, list, NULL, pszSrcFile, __LINE__);
     152                            (fViewChild ? CHILD : 0),
     153                             NULL, list, NULL, pszSrcFile, __LINE__);
    206154          }
    207155          else
     
    271219    case SORT_LWDATE:
    272220      ret = TestCDates(&pai1->date, &pai1->time,
    273                        &pai2->date, &pai2->time);
    274         /*(pai1->date.year < pai2->date.year) ? 1 :
     221                       &pai2->date, &pai2->time);
     222        /*(pai1->date.year < pai2->date.year) ? 1 :
    275223        (pai1->date.year > pai2->date.year) ? -1 :
    276224        (pai1->date.month < pai2->date.month) ? 1 :
     
    15181466        free(s);
    15191467        if (IsFile(filename) == 1) {
     1468#if 1 // 06 Oct 07 SHL fixme to be gone - set to 0 for ticket #58  testing
    15201469          if (fViewChild && fArcStuffVisible)
    15211470            DosSleep(100);  // Allow unzip session to finish closing 14 Mar 07 SHL
     1471#endif
    15221472          WinSendMsg(dcd->hwndCnr, UM_ENTER, MPFROMP(filename), MPVOID);
    15231473        }
     
    15781528
    15791529              if (IsFile(li->list[x]))
    1580                 BldQuotedFileName(szBuffer + strlen(szBuffer), li->list[x]);
     1530                BldQuotedFileName(szBuffer + strlen(szBuffer), li->list[x]);
    15811531              else
    1582                 BldQuotedFullPathName(szBuffer + strlen(szBuffer), li->list[x], "*");
     1532                BldQuotedFullPathName(szBuffer + strlen(szBuffer), li->list[x], "*");
    15831533
    15841534              x++;
     
    15861536                  strlen(li->list[x]) + 5 > 1024) {
    15871537                runemf2(SEPARATE | WINDOWED |
    1588                         (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
    1589                         WAIT, hwnd, pszSrcFile, __LINE__,
    1590                         NULL, NULL, "%s", szBuffer);
     1538                        (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
     1539                        WAIT, hwnd, pszSrcFile, __LINE__,
     1540                        NULL, NULL, "%s", szBuffer);
    15911541                *p = 0;
    15921542              }
     
    16961646              CHAR fullname[CCHMAXPATH * 2];
    16971647              CHAR **exfiles = NULL;
    1698               INT numfiles = 0, numalloc = 0;
     1648              UINT numfiles = 0, numalloc = 0;
    16991649
    17001650              for (x = 0; li->list[x]; x++) {
     
    17671717              runemf2(SEPARATE | WINDOWED |
    17681718                      (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
    1769                       WAIT, hwnd, pszSrcFile, __LINE__,
    1770                       li->targetpath, NULL, "%s", cl);
     1719                      WAIT, hwnd, pszSrcFile, __LINE__,
     1720                      li->targetpath, NULL, "%s", cl);
    17711721              *endofit = 0;
    17721722            } while (li->list[x]);
     
    18261776                         WINDOWED | SEPARATEKEEP | PROMPT,
    18271777                         li->targetpath,
    1828                         NULL, GetPString(IDS_EXECARCFILETITLETEXT),
    1829                         pszSrcFile, __LINE__);
     1778                        NULL, GetPString(IDS_EXECARCFILETITLETEXT),
     1779                        pszSrcFile, __LINE__);
    18301780            else if (li->type == IDM_VIRUSSCAN)
    18311781              ExecOnList(hwnd, virus, PROMPT | WINDOWED | SEPARATEKEEP,
    18321782                         li->targetpath, NULL,
    1833                         GetPString(IDS_VIRUSSCANARCHIVETITLETEXT),
    1834                         pszSrcFile, __LINE__);
     1783                        GetPString(IDS_VIRUSSCANARCHIVETITLETEXT),
     1784                        pszSrcFile, __LINE__);
    18351785            else if (li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
    18361786                     li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
     
    19661916        case IDM_FIND:
    19671917          {
    1968             INT numfiles = 0, numalloced = 0;
     1918            UINT numfiles = 0, numalloced = 0;
    19691919            CHAR **list2 = NULL, fullname[CCHMAXPATH * 2], *p;
    19701920
     
    28312781          runemf2(SEPARATE | WINDOWED |
    28322782                  (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
    2833                   hwnd, pszSrcFile, __LINE__,
    2834                   dcd->directory, NULL, "%s %s", dcd->info->extract,
     2783                  hwnd, pszSrcFile, __LINE__,
     2784                  dcd->directory, NULL, "%s %s", dcd->info->extract,
    28352785                  BldQuotedFileName(szQuotedArcName, dcd->arcname));
    28362786        if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTEXIT)
     
    28432793          runemf2(SEPARATE | WINDOWED |
    28442794                  (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
    2845                   hwnd, pszSrcFile, __LINE__,
    2846                   dcd->directory, NULL, "%s %s",
     2795                  hwnd, pszSrcFile, __LINE__,
     2796                  dcd->directory, NULL, "%s %s",
    28472797                  dcd->info->exwdirs,
    28482798                  BldQuotedFileName(szQuotedArcName, dcd->arcname));
Note: See TracChangeset for help on using the changeset viewer.