ZipArchive.h

Go to the documentation of this file.
00001 
00002 // $RCSfile: ZipArchive.h,v $
00003 // $Revision: 1.13 $
00004 // $Date: 2006/04/07 11:47:17 $ $Author: Tadeusz Dracz $
00006 // This source file is part of the ZipArchive library source distribution and
00007 // is Copyrighted 2000 - 2006 by Tadeusz Dracz (http://www.artpol-software.com/)
00008 // 
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 // 
00014 // For the licensing details see the file License.txt
00015 //
00016 // Check the site http://www.artpol-software.com for the updated version of the library.
00018 //   
00019 // The following information files are distributed along with this library:
00020 //  License.txt  - licensing information
00021 //  gpl.txt   - General Public License text
00022 //  Readme.txt  - general information
00023 //  ChangeLog.txt - revision history
00024 //  faq.txt   - frequently asked questions
00025 //  Appnote.txt  - details on the zip format
00026 //       ( also available at ftp://ftp.pkware.com/appnote.zip)
00027 //
00028 // 
00029 
00030 
00031 
00038 #if !defined(AFX_ZIPARCHIVE_H__A7F528A6_1872_4071_BE66_D56CC2DDE0E6__INCLUDED_)
00039 #define AFX_ZIPARCHIVE_H__A7F528A6_1872_4071_BE66_D56CC2DDE0E6__INCLUDED_
00040 
00060 // to ensure that the correct files are copied
00061 // (see "Compatibility" chapter in the documentation).
00062 // Rebuild the project after copying the files.
00063 #ifdef ZIP_ARCHIVE_MFC_PROJ 
00064  #ifndef ZIP_ARCHIVE_MFC
00065   #error You need to copy files from the MFC subdirectory\
00066    to the ZipArchive root directory and rebuild the project
00067  #endif 
00068 #elif defined ZIP_ARCHIVE_STL_PROJ
00069  #ifndef ZIP_ARCHIVE_STL
00070   #error You need to copy files from the STL subdirectory\
00071    to the ZipArchive root directory and rebuild the project
00072  #endif 
00073 #endif //
00074 
00075 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
00076  #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
00077  #pragma warning( disable : 4275 ) // non dll-interface class used as base for dll-interface
00078 #endif
00079 
00080 #ifdef __GNUC__
00081  #include "zlib.h"
00082 #else
00083  #include "zlib/zlib.h"
00084 #endif
00085 
00086 #include "ZipException.h"
00087 #include "ZipAutoBuffer.h"
00088 #include "ZipCentralDir.h" 
00089 #include "ZipStorage.h"
00090 #include "ZipPathComponent.h"
00091 #include "ZipString.h"
00092 #include "ZipExport.h"
00093 
00094 
00100 struct ZIP_API CZipAddNewFileInfo
00101 {
00102  CZipAddNewFileInfo(LPCTSTR lpszFilePath, bool bFullPath = true)
00103   : m_szFilePath(lpszFilePath),m_bFullPath(bFullPath)
00104  {
00105   m_pFile = NULL;
00106   Defaults();
00107  }
00108  CZipAddNewFileInfo(LPCTSTR lpszFilePath, LPCTSTR lpszFileNameInZip)
00109   : m_szFilePath(lpszFilePath), m_szFileNameInZip(lpszFileNameInZip)
00110  {
00111   m_pFile = NULL;
00112   Defaults();
00113  }
00114  CZipAddNewFileInfo(CZipAbstractFile* pFile, LPCTSTR lpszFileNameInZip)
00115   : m_pFile(pFile), m_szFileNameInZip(lpszFileNameInZip)
00116  {
00117   Defaults();
00118  }
00122  CZipString m_szFilePath;  
00123 
00129  CZipString m_szFileNameInZip;
00130  
00143  bool m_bFullPath;
00144 
00148  int m_iComprLevel;    
00149 
00158  int m_iSmartLevel;
00159 
00187  int m_iReplaceIndex;  
00188 
00192  unsigned long m_nBufSize;  
00193 
00203  CZipAbstractFile* m_pFile;
00204 
00208  void Defaults();
00209 };
00210 
00211 
00217 class ZIP_API CZipArchive  
00218 {
00219  
00220 public:
00225  struct ZIP_API CZipInternalInfo  
00226  {
00227  
00228   CZipInternalInfo()
00229   {
00230    m_iBufferSize = 65536;
00231    m_uUncomprLeft = 0;
00232    m_uComprLeft  = 0;
00233    m_uCrc32 = 0;
00234   }
00235   virtual ~CZipInternalInfo(){}
00236 
00240   void Init()
00241   {
00242    m_pBuffer.Allocate(m_iBufferSize);
00243   }
00244   void ReleaseBuf()
00245   {
00246    m_pBuffer.Release();
00247   }
00248   z_stream m_stream;  
00249   DWORD m_uUncomprLeft; 
00250   DWORD m_uComprLeft;  
00251   DWORD m_uCrc32;   
00252 
00260   DWORD m_iBufferSize;
00261 
00265   CZipAutoBuffer m_pBuffer;
00266  };
00267 
00268  CZipArchive();
00269  virtual ~CZipArchive();
00270 
00280  static int SingleToWide(const CZipAutoBuffer &szSingle, CZipString& szWide);
00281 
00291  static int WideToSingle(LPCTSTR lpWide, CZipAutoBuffer &szSingle);
00292 
00293 #ifdef _UNICODE 
00294 
00303  static void WideConversionUseAnsi(bool bUseAnsi)
00304  {
00305   g_bWideConversionUseAnsi = bUseAnsi;
00306  }
00307 #endif
00308 
00319  static void ReadBytes(void* pDestination, const char* pSource, int iCount)
00320  {
00321   if (!m_pReadBytes)
00322    if (ZipCompatibility::IsBigEndian())
00323     m_pReadBytes = ZipCompatibility::ReadBytesBigEndian;
00324    else
00325     m_pReadBytes = ZipCompatibility::ReadBytesLittleEndian;
00326   m_pReadBytes(pDestination, pSource, iCount);
00327  }
00328 
00338  static void WriteBytes(char* pDestination, const void* pSource, int iCount)
00339  {
00340   if (!m_pWriteBytes)
00341    if (ZipCompatibility::IsBigEndian())
00342     m_pWriteBytes = ZipCompatibility::WriteBytesBigEndian;
00343    else
00344     m_pWriteBytes = ZipCompatibility::WriteBytesLittleEndian;
00345   m_pWriteBytes(pDestination, pSource, iCount);
00346  }
00347 
00357  static bool CompareBytes(const char* pBuffer, const void* pBytes, int iCount)
00358  {
00359   if (!m_pCompareBytes)
00360    if (ZipCompatibility::IsBigEndian())
00361     m_pCompareBytes = ZipCompatibility::CompareBytesBigEndian;
00362    else
00363     m_pCompareBytes = ZipCompatibility::CompareBytesLittleEndian;
00364   return m_pCompareBytes(pBuffer, pBytes, iCount);
00365  }
00375  bool SetPassword(LPCTSTR lpszPassword = NULL);
00376 
00380  CZipString GetPassword()const ;
00381 
00398  void SetAdvanced(int iWriteBuffer = 65536, int iGeneralBuffer = 65536, int iSearchBuffer = 32768);
00399 
00403  void GetAdvanced(int* piWriteBuffer = NULL, int* piGeneralBuffer = NULL, int* piSearchBuffer= NULL)
00404  {
00405   if (piWriteBuffer)
00406    *piWriteBuffer =  m_storage.m_iWriteBufferSize;
00407   if (piGeneralBuffer)
00408    *piGeneralBuffer = m_info.m_iBufferSize;
00409   if (piSearchBuffer)
00410    *piSearchBuffer = m_centralDir.m_iBufferSize;
00411  }
00412 
00418  enum CallbackType
00419  {
00420   cbNothing = 0x0000, 
00421   cbAdd  = 0x0001, 
00422   cbAddTmp = 0x0002, 
00423 
00424   cbAddStore = 0x0004, 
00425 
00426 
00427   cbExtract = 0x0008, 
00428 
00429   cbDeleteCnt = 0x0010, 
00430   cbDelete = 0x0020, 
00431 
00432   cbTest  = 0x0040, 
00433   cbSave  = 0x0080, 
00434 
00435   cbGetFromArchive 
00436      = 0x0100, 
00437   cbRename = 0x0200, 
00438   cbReplace = 0x0400,   
00439   cbNextValue = 0x0800, 
00440   
00441 
00442   cbSubActions= cbAddTmp | cbAddStore | cbDeleteCnt | cbReplace,    
00443   cbActions = cbAdd | cbExtract | cbDelete | cbTest | cbSave | cbGetFromArchive | cbRename, 
00444   cbAll  = cbActions | cbSubActions       
00445  };
00446 
00447 
00463  void SetCallback(CZipActionCallback* pCallback = NULL, int iWhich = cbAll);
00464 
00468  CZipActionCallback* GetCallback(CallbackType iWhich)
00469  {
00470   return m_callbacks.Get(iWhich);
00471  }
00472 
00489  void SetSpanCallback(CZipSpanCallback* pCallback = NULL){m_storage.m_pChangeDiskFunc = pCallback;}
00490 
00491 
00492  
00497  enum OpenMode
00498  {
00499   zipOpen,   
00500 
00507   zipOpenReadOnly,
00508   zipCreate,   
00509   zipCreateSpan  
00510  };
00511 
00512 
00513 
00545  void Open(LPCTSTR szPathName, int iMode = zipOpen, int iVolumeSize = 0);
00546 
00547 
00561  void Open(CZipAbstractFile& af, int iMode = zipOpen);
00562 
00581  void SetRootPath(LPCTSTR szPath = NULL);
00582 
00583 
00588  CZipString GetRootPath()const 
00589  {
00590   return m_szRootPath;
00591  }
00592 
00602  enum Smartness
00603  {
00604   zipsmLazy   = 0x0000,  
00605   zipsmCPassDir  = 0x0001,  
00606   zipsmCPFile0  = 0x0002,  
00607   zipsmNotCompSmall = 0x0004,  
00608   zipsmCheckForEff = 0x0008,  
00609 
00610 
00611 
00612 
00613 
00614 
00615   zipsmMemoryFlag  = 0x0010,  
00616 
00617   zipsmCheckForEffInMem = zipsmMemoryFlag | zipsmCheckForEff, 
00618 
00619   zipsmSmartPass = zipsmCPassDir | zipsmCPFile0,   
00620   zipsmSmartAdd = zipsmNotCompSmall | zipsmCheckForEff, 
00621   zipsmSafeSmart = zipsmSmartPass | zipsmNotCompSmall,    
00622   zipsmSmartest = zipsmSmartPass | zipsmSmartAdd,   
00623 
00624   
00625   zipsmInternal01  = 0xf000   
00626 
00627  };
00628 
00629  
00646  bool AddNewFile(CZipAddNewFileInfo& info);
00647 
00648 
00653  bool AddNewFile(LPCTSTR lpszFilePath, int iComprLevel = -1, bool bFullPath = true,
00654   int iSmartLevel = zipsmSafeSmart, unsigned long nBufSize = 65536);
00655 
00656 
00660  bool AddNewFile(LPCTSTR lpszFilePath,
00661         LPCTSTR lpszFileNameInZip,
00662                              int iComprLevel = -1,                             
00663         int iSmartLevel = zipsmSafeSmart,
00664                              unsigned long nBufSize = 65536);
00665 
00669  bool AddNewFile(CZipMemFile& mf,
00670         LPCTSTR lpszFileNameInZip,
00671                              int iComprLevel = -1,                             
00672         int iSmartLevel = zipsmSafeSmart,
00673                              unsigned long nBufSize = 65536);
00674 
00675 
00676 
00728  bool OpenNewFile(CZipFileHeader & header, int iLevel = Z_DEFAULT_COMPRESSION, LPCTSTR lpszFilePath = NULL, DWORD uInternal = 0);
00729 
00740  bool WriteNewFile(const void *pBuf, DWORD iSize);
00741 
00742 
00754  void SetExtraField(const char *pBuf, WORD iSize);
00755 
00766  bool CloseNewFile(bool bAfterException = false);
00767 
00795  bool GetFromArchive(CZipArchive& zip, WORD uIndex, int iReplaceIndex = -1, bool bKeepSystComp = false)
00796  {
00797     
00798   m_info.Init();
00799   bool bRet;
00800   try
00801   {
00802    bRet = GetFromArchive(zip, uIndex, iReplaceIndex, bKeepSystComp, GetCallback(cbGetFromArchive));
00803   }
00804   catch(...)
00805   {
00806    m_info.ReleaseBuf();
00807    throw;
00808   }
00809   m_info.ReleaseBuf();
00810   if (bRet && m_bAutoFlush)
00811    Flush();
00812 
00813   return bRet;
00814  }
00815 
00830  bool GetFromArchive(CZipArchive& zip, CZipWordArray &aIndexes, bool bKeepSystComp = false);
00831  
00850  bool GetFromArchive(CZipArchive& zip, CZipStringArray &aNames, bool bKeepSystComp = false)
00851  {
00852   CZipWordArray indexes;
00853   zip.GetIndexes(aNames, indexes);
00854   return GetFromArchive(zip, indexes, bKeepSystComp);
00855   
00856  }
00857 
00869  void GetIndexes(const CZipStringArray &aNames, CZipWordArray& aIndexes);
00870 
00908  bool ExtractFile(WORD uIndex, LPCTSTR lpszPath, bool bFullPath = true,
00909   LPCTSTR lpszNewName = NULL, DWORD nBufSize = 65536);
00910 
00911  
00928  bool ExtractFile(WORD uIndex, CZipMemFile& mf, bool bRewind = true, DWORD nBufSize = 65536);
00929 
00941  bool OpenFile(WORD uIndex);
00942 
00953  DWORD ReadFile(void *pBuf, DWORD iSize);
00954 
00955 
00971  bool TestFile(WORD uIndex, DWORD uBufSize = 65536);
00972 
00981  void CloseFileWithNoUpdate();
00982 
00993  int GetLocalExtraField(char* pBuf, int iSize)const ;
00994 
01004  int CloseFile(CZipFile &file);
01005 
01006 
01023  int CloseFile(LPCTSTR lpszFilePath = NULL, bool bAfterException = false);
01024 
01038  void DeleteFile(WORD uIndex);
01039 
01054  void DeleteFiles(CZipWordArray &aIndexes);
01055 
01056 
01071  void DeleteFiles(const CZipStringArray &aNames);
01072 
01073 
01081  bool SetGlobalComment(LPCTSTR lpszComment);
01082 
01083 
01087  CZipString GetGlobalComment()const ;
01088 
01089 
01099  bool SetFileComment(WORD uIndex, LPCTSTR lpszComment);
01100 
01104  CZipString GetArchivePath()const;
01105 
01114  int GetCurrentDisk()const ;
01115 
01129  int GetSpanMode()const 
01130  {
01131   return m_storage.m_iSpanMode * m_storage.IsSpanMode();
01132  }
01133 
01137  enum FFCaseSens
01138  {
01139   ffDefault,  
01140 
01141 
01142 
01143   ffCaseSens,  
01144 
01145 
01146 
01147   ffNoCaseSens 
01148 
01149 
01150 
01151 
01152  };
01153 
01177  int FindFile(LPCTSTR lpszFileName, int iCaseSensitive = ffDefault, bool bFileNameOnly = false);
01178 
01187  bool GetFileInfo(CZipFileHeader & fhInfo, WORD uIndex) const;
01188 
01189 
01196  int GetCount(bool bOnlyFiles = false)const 
01197  {
01198   int iTotalCount = m_centralDir.m_headers.GetSize();
01199   if (bOnlyFiles)
01200   {
01201    int iCount = 0;
01202    for (int i = 0; i < iTotalCount; i++)
01203     if (!m_centralDir.m_headers[i]->IsDirectory())
01204      iCount++;
01205    return iCount;
01206   }
01207   else
01208    return iTotalCount;
01209  }
01215  DWORD GetOccupiedSpace() const
01216  {
01217   if (IsClosed(true) || IsClosed(false))
01218   {
01219    TRACE(_T("%s(%i) : ZipArchive or the current volume file is closed.\n"),__FILE__,__LINE__);
01220    return 0;
01221   }
01222   return m_storage.GetOccupiedSpace() + m_centralDir.GetSize(true);
01223  }
01224 
01228  enum CloseAfterException
01229  {
01230   afNoException,  
01231   afAfterException, 
01232   afWriteDir   
01233 
01234  };
01235 
01246  void Close(int iAfterException = afNoException, bool bUpdateTimeStamp = false);
01247 
01248 
01257  bool IsClosed(bool bArchive = true)const
01258  {
01259   return m_storage.IsClosed(bArchive);
01260  }
01261 
01282  void Flush();
01283 
01284 
01296  void SetAutoFlush(bool bAutoFlush = true);
01297  
01298 
01304  bool GetAutoFlush()const {return m_bAutoFlush;}
01305 
01326  int GetSystemCompatibility() const {return m_iArchiveSystCompatib;}
01327 
01340  bool SetSystemCompatibility(int iSystemComp);
01341 
01356  void SetFileHeaderAttr(CZipFileHeader& header, DWORD uAttr)const;
01357 
01358 
01365  static const DWORD* GetCRCTable()
01366  {
01367    return get_crc_table();
01368  }
01369 
01376  CZipStorage* GetStorage(){return &m_storage;}
01377 
01378 
01386  void SetDetectZlibMemoryLeaks(bool bDetect)
01387  {
01388   if (m_iFileOpened != nothing)
01389   {
01390    TRACE(_T("CZipArchive::SetDetectZlibMemoryLeaks: Set it before opening a file in the archive"));
01391    return;
01392   }
01393   m_bDetectZlibMemoryLeaks = bDetect;
01394   
01395  }
01396 
01410  void SetConvertAfterOpen (bool bConvertAfterOpen)
01411  {
01412   if (!IsClosed())
01413   {
01414    TRACE(_T("CZipArchive::SetConvertAfterOpen: Set it before opening the archive"));
01415    return;
01416   }
01417   m_centralDir.m_bConvertAfterOpen = bConvertAfterOpen;
01418 
01419  }
01420 
01421 
01436  void EnableOemConversion(bool enable)
01437  {
01438   if (!IsClosed())
01439   {
01440    TRACE(_T("CZipArchive::EnableOemConversion: Set it before opening the archive"));
01441    return;
01442   }
01443   m_centralDir.m_bOemConversion = enable;
01444  }
01445 
01456  void EnableFindFast(bool bEnable = true);
01457 
01458 
01477  int GetFindFastIndex(int iFindFastIndex) const
01478  {
01479   if (IsClosed())
01480   {
01481    TRACE(_T("CZipArchive::GetFindFastIndex: ZipArchive not yet opened.\n"));
01482    return -1;
01483   }
01484   
01485   return m_centralDir.GetFindFastIndex(iFindFastIndex);
01486  }
01487 
01488 
01502  void SetTempPath(LPCTSTR lpszPath = NULL, bool bForce = true);
01503 
01504 
01505 
01509  enum Predict
01510  {
01511  
01512   prDir,  
01513   prFile, 
01514   prAuto  
01515     
01516  };
01517 
01537  CZipString PredictFileNameInZip(LPCTSTR lpszFilePath, bool bFullPath, int iWhat = prAuto, bool bExactly = false)const ;
01538 
01564  DWORD PredictMaximumFileSizeInArchive(CZipFileHeader& fh) const;
01565 
01576  DWORD PredictMaximumFileSizeInArchive(LPCTSTR lpszFilePath, bool bFullPath) const;
01577  
01578 
01592  int WillBeDuplicated(LPCTSTR lpszFilePath, bool bFullPath, bool bFileNameOnly = false, int iWhat = prAuto);
01593 
01594 
01605  CZipString PredictExtractedFileName(LPCTSTR lpszFileNameInZip, LPCTSTR lpszPath, bool bFullPath, LPCTSTR lpszNewName = NULL)const ;
01606 
01613  CZipString GetTempPath()const 
01614  {
01615   return m_szTempPath;
01616  }
01617 
01624  CZipString TrimRootPath(CZipPathComponent& zpc)const ;
01625 
01637  static bool RemovePathBeginning(LPCTSTR lpszBeginning, CZipString& szPath, ZIPSTRINGCOMPARE pCompareFunction);
01638 
01658  void SetCaseSensitivity(bool bCaseSensitive) 
01659  {
01660   m_bCaseSensitive = bCaseSensitive;
01661   m_pZipCompare = GetCZipStrCompFunc(bCaseSensitive);
01662  }
01663 
01668  void GetCentralDirInfo(CZipCentralDir::Info& info)const;
01669  
01670 
01676  DWORD GetCentralDirSize(bool bWhole = true) const
01677  {
01678   return m_centralDir.GetSize(bWhole);
01679  }
01680 
01685  bool IsReadOnly(){return m_storage.IsReadOnly();}
01686 
01687 
01695  void SetIgnoreCRC(bool bIgnore = true){m_bIgnoreCRC = bIgnore;}
01696 
01701  void SetTreatAsSingleDisk(bool bSingleDisk = true){m_storage.SetTreatAsSingleDisk(bSingleDisk);}
01702 
01708  class ZIP_API CWildcard  
01709  {
01710  public:
01711   
01712   
01713   enum Match
01714   {
01715    matchNone,   
01716    matchValid,   
01717    matchEnd,   
01718    matchAbort,   
01719    matchRange,   
01720    matchLiteral,  
01721    matchPattern  
01722   };
01723   
01724   enum Pattern 
01725   {
01726    patternEmpty = -4, 
01727    patternClose,  
01728    patternRange,  
01729    patternEsc,   
01730    patternValid,  
01731   };
01732   
01733   
01745   bool IsMatch(LPCTSTR lpszText, int* iRetCode = NULL);
01746 
01754   static bool IsPattern(LPCTSTR lpszPattern);
01755 
01766   static bool IsPatternValid(LPCTSTR lpszPattern, int* iErrorType = NULL);
01767   
01780   static int Match(LPCTSTR lpszPattern, LPCTSTR lpszText);
01781   
01782   CWildcard(){}
01787   CWildcard(LPCTSTR lpszPattern, bool bCaseSensitive)
01788   {
01789    SetPattern(lpszPattern, bCaseSensitive);
01790   }
01791   virtual ~CWildcard(){}
01792   
01814   void SetPattern(LPCTSTR lpszPattern, bool bCaseSensitive)
01815   {
01816    m_szPattern = lpszPattern;
01817    m_bCaseSensitive=bCaseSensitive;
01818    if (!bCaseSensitive)
01819     m_szPattern.MakeLower();
01820   }
01821   operator LPCTSTR()
01822   {
01823    return (LPCTSTR)m_szPattern;
01824   }
01825  protected:
01826   bool m_bCaseSensitive;  
01827   static int MatchAfterStar(LPCTSTR p , LPCTSTR t);
01828   CZipString m_szPattern;
01829  };
01830 
01831 
01848  void FindMatches(LPCTSTR lpszPattern, CZipWordArray& ar, bool bFullPath = true)const;
01849 
01850 
01863  bool RenameFile(WORD uIndex, LPCTSTR lpszNewName);
01864 
01872  bool m_bRemoveDriveLetter;
01873 
01874 protected:
01875  
01879  static void (*m_pReadBytes)(void*, const char*, int);
01880 
01884  static void (*m_pWriteBytes)(char*, const void*, int);
01885 
01889  static bool (*m_pCompareBytes)(const char*, const void*, int);
01890 
01896  void MakeSpaceForReplace(int iReplaceIndex, DWORD uTotal, LPCTSTR lpszFileName);
01901  struct ZIP_API CZipSmClrPass
01902  {
01903   void ClearPasswordSmartly(CZipArchive* pZip)
01904   {
01905    m_pZip = pZip;
01906    m_szPass = pZip->GetPassword();
01907    if (!m_szPass.IsEmpty())
01908     pZip->SetPassword();
01909   }
01910   ~CZipSmClrPass()
01911   {
01912    if (!m_szPass.IsEmpty())
01913     m_pZip->SetPassword(m_szPass);
01914   }
01915   CZipString m_szPass;
01916   CZipArchive* m_pZip;
01917  };
01918  
01923  struct ZIP_API CZipDeleteInfo
01924  {
01925   CZipDeleteInfo(){m_pHeader = NULL; m_bDelete = false;}
01926   CZipDeleteInfo(CZipFileHeader* pHeader, bool bDelete)
01927    :m_pHeader(pHeader), m_bDelete (bDelete){}
01928   CZipFileHeader* m_pHeader;
01929   bool m_bDelete;
01930  };
01931 
01932 
01937  struct ZIP_API CZipClbckStrg : public CZipMap<CallbackType, CZipActionCallback*>  
01938  {
01939   void Set(CZipActionCallback* pCallback, CallbackType iType)
01940   {
01941    if (pCallback)
01942    {
01943     SetAt(iType, pCallback);
01944    }
01945    else
01946     RemoveKey(iType);
01947   }
01948   CZipActionCallback* Get(CallbackType iType)
01949   {
01950    CZipActionCallback* pCallback = NULL;
01951    if (Lookup(iType, pCallback))
01952    {
01953     pCallback->m_iType = iType;
01954     return pCallback;
01955    }
01956    else
01957     return NULL;
01958   }
01959  
01960  };
01961  
01962  
01966  CZipClbckStrg m_callbacks;
01967  
01968 
01972  void WriteCentralDirectory(bool bFlush = true);
01973 
01978  bool m_bCaseSensitive;
01979 
01986  ZIPSTRINGCOMPARE m_pZipCompare;
01987 
01992  CZipInternalInfo m_info;
01993 
01994  
01999  CZipStorage m_storage;
02000 
02005  CZipCentralDir m_centralDir;
02006 
02010  enum OpenFileType
02011  {
02012   extract = -1, 
02013   nothing,  
02014   compress  
02015  };
02016  
02020  char m_iFileOpened;
02021 
02028  bool m_bAutoFlush;
02029 
02033  bool m_bIgnoreCRC;
02034 
02035  
02036 
02043  CZipString m_szRootPath;
02044 
02051  CZipString m_szTempPath;
02052 
02053 #ifdef _UNICODE 
02054 
02057  static bool g_bWideConversionUseAnsi;
02058 #endif
02059 
02067  void OpenInternal(int iMode);
02068 
02077  int m_iArchiveSystCompatib;
02078 
02083  void EmptyPtrList();
02084 
02085 
02086 
02092  void MovePackedFiles(DWORD uStartOffset, DWORD uEndOffset, DWORD uMoveBy, CZipActionCallback* pCallback, bool bForward = false);
02093 
02099  bool RemoveLast(bool bRemoveAnyway = false);
02100 
02104  bool GetFromArchive(CZipArchive& zip, WORD uIndex, int iReplaceIndex, bool bKeepSystComp, CZipActionCallback* pCallback);
02105 
02109  bool UpdateReplaceIndex(int& iReplaceIndex, LPCTSTR lpszNewFileName);
02110  
02115  CZipFileHeader* CurrentFile();
02116 
02123  void CheckForError(int iErr);
02124 
02125 
02135  void ThrowError(int err, bool bZlib = false);
02136 
02137 
02138  typedef CZipPtrList<void*>::iterator CZipPtrListIter;
02139  CZipPtrList<void*> m_list; 
02140 
02141 
02142  static void* _zliballoc(void* opaque, UINT items, UINT size); 
02143  static void _zlibfree(void* opaque, void* address); 
02144 
02145  
02154  bool m_bDetectZlibMemoryLeaks;
02155 
02156 
02160  static const TCHAR m_gszCopyright[];
02161  
02168 
02175  void CryptDecodeBuffer(DWORD uCount);
02181  void CryptEncodeBuffer();
02182 
02187  void CryptEncode(char &c);
02199  void CryptCryptHeader(long iCrc, CZipAutoBuffer& buf);
02204  DWORD CryptCRC32(DWORD l, char c);
02208  void CryptDecode(char &c);
02212  char CryptDecryptByte();
02213 
02220  bool CryptCheck();
02224  void CryptUpdateKeys(char c);
02228  void CryptInitKeys();
02232  CZipAutoBuffer m_pszPassword;
02233 
02239  DWORD m_keys[3];
02240   
02242 };
02243 
02244 
02245 
02246 #endif // !defined(AFX_ZIPARCHIVE_H__A7F528A6_1872_4071_BE66_D56CC2DDE0E6__INCLUDED_)

ZipArchive Copyright © 2000 - 2006 Tadeusz Dracz . Generated at Fri Apr 7 13:55:23 2006.