Changeset 751 for trunk/dll/arccnrs.c


Ignore:
Timestamp:
Aug 2, 2007, 11:05:48 PM (13 years ago)
Author:
Steven Levine
Message:

Sync rest of code with CNRITEM mods
Sync code with ARCITEM mods
Get compare dialog working
Still some issues with status display
Still some issues with directory sizes tree display
Heap check diagnostic code mostly enabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r740 r751  
    4040  10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
    4141  16 Jun 07 SHL Use DosQueryAppType not DosQAppType
     42  02 Aug 07 SHL Sync with ARCITEM mods
    4243
    4344***********************************************************************/
     
    6061#include <limits.h>
    6162#include <process.h>                    // _beginthread
     63#include <malloc.h>                     // _heapchk
    6264
    6365#include "fm3dll.h"
     
    307309}
    308310
     311/**
     312 * Free storage associated with archive container item
     313 * Caller is responsible for correcting pointers
     314 */
     315
     316static VOID FreeArcItemData(PARCITEM pai)
     317{
     318  // DbgMsg(pszSrcFile, __LINE__, "FreeArcItemData %p", pai);
     319
     320  if (pai->pszFileName && pai->pszFileName != NullStr)
     321    xfree(pai->pszFileName);
     322}
     323
     324/**
     325 * Remove item from archive container and free associated storage if requested
     326 */
     327
     328static VOID RemoveArcItems(HWND hwnd, PARCITEM pai, USHORT usCnt, USHORT usFlags)
     329{
     330  if (usCnt == 0) {
     331    if (pai != NULL)
     332      Runtime_Error(pszSrcFile, __LINE__, "pai not NULL");
     333    else {
     334      for (;;) {
     335        pai = (PARCITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
     336                                   MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     337        if (!pai)
     338          break;
     339        else if ((INT)pai == -1) {
     340          Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD");
     341          break;
     342        }
     343        else
     344          RemoveArcItems(hwnd, pai, 1, usFlags);
     345      }
     346    }
     347  }
     348  else if (usCnt != 1)
     349    Runtime_Error(pszSrcFile, __LINE__, "count not 1");
     350  else {
     351    // DbgMsg(pszSrcFile, __LINE__, "RemoveArcItems %p %u %s", pai, usCnt, pai->pszFileName);
     352
     353    if (usFlags & CMA_FREE)
     354      FreeArcItemData(pai);
     355
     356    if ((INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&pai), MPFROM2SHORT(usCnt, usFlags)) == -1) {
     357      // Win_Error2(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,IDS_CMREMOVEERRTEXT);
     358      Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pai %p", hwnd, pai);
     359    }
     360  }
     361}
     362
     363/**
     364 * Empty all records from an archive container and free associated storage and
     365 * Free up field infos
     366 */
     367
     368static VOID EmptyArcCnr(HWND hwnd)
     369{
     370#if 1 // fixme to disable or to be configurable
     371  {
     372    int state = _heapchk();
     373    if (state != _HEAPOK)
     374      Runtime_Error(pszSrcFile, __LINE__, "heap corrupted %d", state);
     375  }
     376#endif
     377
     378  // Remove all ARCITEM records
     379  RemoveArcItems(hwnd, NULL, 0, CMA_FREE);
     380
     381  // Use common code to remove rest
     382  EmptyCnr(hwnd);
     383}
     384
    309385//== FillArcCnr() generate archive content list and fill container window ==
    310386
     
    359435    Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    360436  else {
    361     WinSendMsg(hwndCnr,
    362                CM_REMOVERECORD,
    363                MPVOID,
    364                MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE));
     437    RemoveArcItems(hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
    365438    *arcinfo = info;
    366439    highest = info->osizepos;
     
    32153288      WinDestroyWindow(ArcCnrMenu);
    32163289    ArcMenu = ArcCnrMenu = (HWND) 0;
    3217     EmptyCnr(hwnd);
     3290    EmptyArcCnr(hwnd);
    32183291    break;
    32193292  }
Note: See TracChangeset for help on using the changeset viewer.