Changeset 7a75401 in tol


Ignore:
Timestamp:
Jun 24, 2010, 1:52:18 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
c92c7d9
Parents:
4e559163
Message:

Refs #922
Fixes syntax an logical errors

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2320 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/PackArchive
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol/PackArchive/PackArchive.cpp

    r4e559163 r7a75401  
    4848HashStoreByHandle Store::_instances;
    4949bool Store::_isInitialized = false;
    50 int Store::_uniqueId = 0;
    51 
     50int Store::_uniqueId = 1;
     51
     52bool _Store_initialize_ = Store::Initialize();
    5253
    5354
    … …  
    164165//--------------------------------------------------------------------
    165166  DeclareContensClass(BDat, BDatTemporary, BDatPackArchiveOpen);
    166   DefExtOpr(1, BDatPackArchiveOpen, "PackArchive.Open", 1, 1, "Text",
     167  DefExtOpr(1, BDatPackArchiveOpen, "PackArchive.Open",
     168  3, 3, "Text Text Text",
    167169  "(Text engine, Text path, Text openMode)",
    168170  I2("Open a packed archive for reading if openMode=='r' or writing "
    … …  
    197199  if(store)
    198200  {
     201    store->Close();
    199202    delete store;
    200203    contens_ = true;
  • tol/PackArchive/StoreZipArchive.cpp

    r4e559163 r7a75401  
    4747//--------------------------------------------------------------------
    4848{
     49  _errMsg[0]='\0';
    4950  _path = path;
    5051  _openMode = openMode;
    … …  
    5556    {
    5657      remove(_path);
    57       _zip.Open(_path, CZipArchive::zipCreate);
     58      _zip.Open(_path.String(), CZipArchive::zipCreate);
    5859    }
    5960    else if(openMode=='r')
    6061    {
    61       _zip.Open(_path, CZipArchive::zipOpenReadOnly, false);
     62      _zip.Open(_path.String(), CZipArchive::zipOpenReadOnly, false);
    6263    }
    6364  }
    … …  
    8182//--------------------------------------------------------------------
    8283{
     84  _errMsg[0]='\0';
    8385  if(_openMode == ' ') { return(true); }
    8486  bool ok = true;
    … …  
    107109//--------------------------------------------------------------------
    108110{
    109   bool ok = true;
    110   try
    111   {
    112     _zip.AddNewFile(originalFilePath);
     111  _errMsg[0]='\0';
     112  bool ok = true;
     113  try
     114  {
     115    _zip.AddNewFile(originalFilePath.String());
    113116  }
    114117  catch(CZipException ex)
    … …  
    120123      (LPCTSTR)ex.GetErrorDescription());
    121124  }
     125  if(!ok) { Error(_errMsg); }
    122126  return(ok);
    123127}
    … …  
    129133//--------------------------------------------------------------------
    130134{
    131   bool ok = true;
    132   try
    133   {
    134     int index = _zip.FindFile(originalFilePath);
     135  _errMsg[0]='\0';
     136  bool ok = true;
     137  try
     138  {
     139    int index = _zip.FindFile(originalFilePath.String());
    135140    if((index>=0) && (index!=ZIP_FILE_INDEX_NOT_FOUND))
    136141    {
    137       _zip.ExtractFile(index, destinationDirPath);
     142      _zip.ExtractFile(index, destinationDirPath.String());
    138143    }
    139144    else
    … …  
    151156      (LPCTSTR)ex.GetErrorDescription());
    152157  }
     158  if(!ok) { Error(_errMsg); }
    153159  return(ok);
    154160}
    … …  
    160166//--------------------------------------------------------------------
    161167{
     168  _errMsg[0]='\0';
    162169  int index = -1;
    163170  bool ok = false;
    164171  try
    165172  {
    166     index = _zip.FindFile(originalFilePath);
     173    index = _zip.FindFile(originalFilePath.String());
    167174    ok = ((index>=0) && (index!=ZIP_FILE_INDEX_NOT_FOUND));
    168175  }
    … …  
    175182      (LPCTSTR)ex.GetErrorDescription());
    176183  }
     184  if(!ok) { Error(_errMsg); }
    177185  return(ok);
    178186}
    … …  
    184192//--------------------------------------------------------------------
    185193{
     194  _errMsg[0]='\0';
    186195  bool ok = true;
    187196  try
    … …  
    193202      ZipArchiveLib::CNameFileFilter::toAll);
    194203    // This will include empty directories
    195     _zip.AddNewFiles(originalDirPath, filter);
     204    _zip.AddNewFiles(originalDirPath.String(), filter);
    196205  }
    197206  catch(CZipException ex)
    … …  
    203212      (LPCTSTR)ex.GetErrorDescription());
    204213  }
     214  if(!ok) { Error(_errMsg); }
    205215  return(ok);
    206216}
    … …  
    212222//--------------------------------------------------------------------
    213223{
     224  _errMsg[0]='\0';
    214225  bool ok = true;
    215226  try
    … …  
    218229    // find files using wildcards
    219230    //zip.FindMatches(_T("file?.*"), indexes);   
    220     _zip.FindMatches(_T(originalDirPath+"/*"), indexes);   
    221     _tprintf(_T("Matches found at positions:\r\n"));
     231    BText match = originalDirPath;
     232    _zip.FindMatches(match.String(), indexes);   
    222233    ok = indexes.GetCount()>0;
     234    if(!ok)
     235    {
     236      sprintf(_errMsg, "[ZipArchive] Cannot find files to extract from archive "
     237        "%s matching pattern '%s'",
     238        _path.String(), 
     239        match.String());
     240    }
    223241    for (ZIP_ARRAY_SIZE_TYPE i = 0; i < indexes.GetCount(); i++)
    224242    {
    … …  
    229247  {
    230248    ok = false;
    231     sprintf(_errMsg, "[ZipArchive] Error while extracting from archive %s file %s to %s: %s",
     249    sprintf(_errMsg, "[ZipArchive] Error while extracting from archive %s file "
     250      "%s to %s: %s",
    232251      _path.String(), 
    233252      originalDirPath.String(),
    … …  
    235254      (LPCTSTR)ex.GetErrorDescription());
    236255  }
     256  if(!ok) { Error(_errMsg); }
    237257  return(ok);
    238258};
    … …  
    244264//--------------------------------------------------------------------
    245265{
     266  _errMsg[0]='\0';
    246267  bool ok = true;
    247268  try
    … …  
    250271    // find files using wildcards
    251272    //zip.FindMatches(_T("file?.*"), indexes);   
    252     _zip.FindMatches(_T(originalDirPath+"/*"), indexes);   
    253     _tprintf(_T("Matches found at positions:\r\n"));
     273    BText match = originalDirPath+"/*";
     274    _zip.FindMatches(match.String(), indexes);   
    254275    ok = indexes.GetCount()>0;
    255276  }
    … …  
    262283      (LPCTSTR)ex.GetErrorDescription());
    263284  }
     285  if(!ok) { Error(_errMsg); }
    264286  return(ok);
    265287};
Note: See TracChangeset for help on using the changeset viewer.