Skip Navigation Links
Skip Navigation LinksHome > ZipArchive > How to Use > API Documentation

CZipArchive Class Reference

Represents a zip archive file. More...

#include <ZipArchive.h>

List of all members.


Public Types

enum  CloseAfterException { afNoException, afAfterException, afWriteDir }
enum  ConsistencyCheck {
  checkNone, checkCRC = 0x0001, checkLocalMethod = 0x0002, checkLocalSizes = 0x0004,
  checkLocalCRC = 0x0008, checkLocalFlag = 0x0010, checkLocalAll = checkLocalMethod | checkLocalSizes | checkLocalCRC | checkLocalFlag, checkDataDescriptor = 0x0100,
  checkAll = checkCRC | checkLocalAll | checkDataDescriptor, checkIgnoredByDefault = checkDataDescriptor
}
enum  FFCaseSens { ffDefault, ffCaseSens, ffNoCaseSens }
enum  OpenMode {
  zipOpen, zipOpenReadOnly, zipCreate, zipCreateSegm,
  zipCreateAppend
}
enum  Predict { prDir, prFile, prAuto }
enum  SegmCallbackType { scSpan = 0x01, scSplit = 0x02, scAll = scSpan | scSplit }
enum  Smartness {
  zipsmLazy = 0x0000, zipsmCPassDir = 0x0001, zipsmCPFile0 = 0x0002, zipsmNotCompSmall = 0x0004,
  zipsmCheckForEff = 0x0008, zipsmMemoryFlag = 0x0010, zipsmCheckForEffInMem = zipsmMemoryFlag | zipsmCheckForEff, zipsmSmartPass = zipsmCPassDir | zipsmCPFile0,
  zipsmSmartAdd = zipsmNotCompSmall | zipsmCheckForEff, zipsmSafeSmart = zipsmSmartPass | zipsmNotCompSmall, zipsmSmartest = zipsmSmartPass | zipsmSmartAdd, zipsmInternal01 = 0xf000
}

Public Member Functions

bool AddNewFile (CZipMemFile &mf, LPCTSTR lpszFileNameInZip, int iComprLevel=-1, int iSmartLevel=zipsmSafeSmart, unsigned long nBufSize=65536)
bool AddNewFile (LPCTSTR lpszFilePath, LPCTSTR lpszFileNameInZip, int iComprLevel=-1, int iSmartLevel=zipsmSafeSmart, unsigned long nBufSize=65536)
bool AddNewFile (LPCTSTR lpszFilePath, int iComprLevel=-1, bool bFullPath=true, int iSmartLevel=zipsmSafeSmart, unsigned long nBufSize=65536)
bool AddNewFile (CZipAddNewFileInfo &info)
bool AddNewFiles (LPCTSTR lpszPath, LPCTSTR lpszFileMask=_T("*.*"), bool bRecursive=true, int iComprLevel=-1, bool bSkipInitialPath=true, int iSmartLevel=zipsmSafeSmart, unsigned long nBufSize=65536)
bool AddNewFiles (LPCTSTR lpszPath, ZipArchiveLib::CFileFilter &filter, bool bRecursive=true, int iComprLevel=-1, bool bSkipInitialPath=true, int iSmartLevel=zipsmSafeSmart, unsigned long nBufSize=65536)
void Close (int iAfterException=afNoException, bool bUpdateTimeStamp=false)
int CloseFile (CZipFile &file)
int CloseFile (LPCTSTR lpszFilePath=NULL, bool bAfterException=false)
bool CloseNewFile (bool bAfterException=false)
void EnableFindFast (bool bEnable=true)
bool EncryptAllFiles ()
bool EncryptFile (ZIP_INDEX_TYPE uIndex)
bool EncryptFiles (CZipIndexesArray &aIndexes)
bool ExtractFile (ZIP_INDEX_TYPE uIndex, CZipMemFile &mf, bool bRewind=true, CZipCompressor::COffsetsPair *pSeekPair=NULL, DWORD nBufSize=65536)
bool ExtractFile (ZIP_INDEX_TYPE uIndex, LPCTSTR lpszPath, bool bFullPath=true, LPCTSTR lpszNewName=NULL, CZipCompressor::COffsetsPair *pSeekPair=NULL, DWORD nBufSize=65536)
ZIP_INDEX_TYPE FindFile (LPCTSTR lpszFileName, int iCaseSensitive=ffDefault, bool bFileNameOnly=false)
void FindMatches (LPCTSTR lpszPattern, CZipIndexesArray &ar, bool bFullPath=true)
void Flush ()
void FlushBuffers ()
void GetAdvanced (int *piWriteBuffer=NULL, int *piGeneralBuffer=NULL, int *piSearchBuffer=NULL)
CZipString GetArchivePath () const
bool GetAutoFlush () const
ZIP_SIZE_TYPE GetBytesBeforeZip () const
CZipActionCallbackGetCallback (CZipActionCallback::CallbackType iWhich)
bool GetCaseSensitivity () const
void GetCentralDirInfo (CZipCentralDir::CInfo &info) const
ZIP_SIZE_TYPE GetCentralDirSize (bool bWhole=true) const
WORD GetCompressionMethod () const
ZIP_INDEX_TYPE GetCount () const
ZIP_INDEX_TYPE GetCount (bool bOnlyFiles)
const CZipCompressorGetCurrentCompressor () const
ZIP_VOLUME_TYPE GetCurrentVolume () const
int GetEncryptionMethod () const
bool GetExhaustiveRead () const
CZipString GetFileComment (ZIP_INDEX_TYPE uIndex) const
const CZipFileHeaderGetFileInfo (ZIP_INDEX_TYPE uIndex) const
CZipFileHeaderGetFileInfo (ZIP_INDEX_TYPE uIndex)
bool GetFileInfo (CZipFileHeader &fhInfo, ZIP_INDEX_TYPE uIndex) const
ZIP_INDEX_TYPE GetFindFastIndex (ZIP_INDEX_TYPE iFindFastIndex) const
bool GetFromArchive (CZipArchive &zip, CZipStringArray &aNames, bool bKeepSystComp=false)
bool GetFromArchive (CZipArchive &zip, CZipIndexesArray &aIndexes, bool bKeepSystComp=false)
bool GetFromArchive (CZipArchive &zip, ZIP_INDEX_TYPE uIndex, LPCTSTR lpszNewFileName=NULL, ZIP_INDEX_TYPE uReplaceIndex=ZIP_FILE_INDEX_UNSPECIFIED, bool bKeepSystComp=false)
CZipString GetGlobalComment () const
int GetIgnoredConsistencyChecks () const
void GetIndexes (const CZipStringArray &aNames, CZipIndexesArray &aIndexes)
ZIP_SIZE_TYPE GetOccupiedSpace () const
CZipString GetPassword () const
CZipString GetRootPath () const
int GetSegmMode () const
CZipStorageGetStorage ()
CZipStringStoreSettingsGetStringStoreSettings ()
int GetSystemCompatibility () const
CZipString GetTempPath () const
bool IsClosed (bool bArchive=true) const
bool IsReadOnly ()
bool Open (CZipAbstractFile &af, int iMode=zipOpen)
bool Open (LPCTSTR szPathName, int iMode=zipOpen, ZIP_SIZE_TYPE uVolumeSize=0)
bool OpenFile (ZIP_INDEX_TYPE uIndex)
bool OpenFrom (CZipArchive &zip)
bool OpenNewFile (CZipFileHeader &header, int iLevel=CZipCompressor::levelDefault, LPCTSTR lpszFilePath=NULL)
const CZipFileHeaderoperator[] (ZIP_INDEX_TYPE uIndex) const
CZipFileHeaderoperator[] (ZIP_INDEX_TYPE uIndex)
bool OverwriteLocalHeader (ZIP_INDEX_TYPE uIndex)
CZipString PredictExtractedFileName (LPCTSTR lpszFileNameInZip, LPCTSTR lpszPath, bool bFullPath, LPCTSTR lpszNewName=NULL) const
CZipString PredictFileNameInZip (LPCTSTR lpszFilePath, bool bFullPath, int iWhat=prAuto) const
ZIP_SIZE_TYPE PredictMaximumFileSizeInArchive (LPCTSTR lpszFilePath, bool bFullPath) const
ZIP_SIZE_TYPE PredictMaximumFileSizeInArchive (CZipFileHeader &fh) const
bool PrependData (CZipAbstractFile &file, LPCTSTR lpszNewExt=NULL)
bool PrependData (LPCTSTR lpszFilePath, LPCTSTR lpszNewExt=)
DWORD ReadFile (void *pBuf, DWORD uSize)
bool ReadLocalHeader (ZIP_INDEX_TYPE uIndex)
bool RemoveCentralDirectoryFromArchive ()
bool RemoveFile (ZIP_INDEX_TYPE uIndex)
bool RemoveFiles (const CZipStringArray &aNames)
bool RemoveFiles (CZipIndexesArray &aIndexes)
bool RenameFile (ZIP_INDEX_TYPE uIndex, LPCTSTR lpszNewName)
void ResetStringStoreSettings ()
bool SeekInFile (CZipCompressor::COffsetsPair *pPair)
void SetAdvanced (int iWriteBuffer=65536, int iGeneralBuffer=65536, int iSearchBuffer=32768)
void SetAutoFlush (bool bAutoFlush=true)
const void SetBytesBeforeZip (ZIP_SIZE_TYPE uCount=0)
void SetCallback (CZipActionCallback *pCallback=NULL, int iWhich=CZipActionCallback::cbAll)
void SetCaseSensitivity (bool bCaseSensitive)
bool SetCompressionMethod (WORD uCompressionMethod=CZipCompressor::methodDeflate)
void SetCompressionOptions (CZipCompressor::COptions *pOptions)
bool SetEncryptionMethod (int iEncryptionMethod=CZipCryptograph::encStandard)
void SetExhaustiveRead (bool bExhaustiveRead)
bool SetFileComment (ZIP_INDEX_TYPE uIndex, LPCTSTR lpszComment)
void SetFileHeaderAttr (CZipFileHeader &header, DWORD uAttr) const
bool SetGlobalComment (LPCTSTR lpszComment)
void SetIgnoredConsistencyChecks (int iLevel=checkIgnoredByDefault)
bool SetPassword (LPCTSTR lpszPassword=NULL)
void SetRootPath (LPCTSTR szPath=NULL)
void SetSegmCallback (CZipSegmCallback *pCallback=NULL, int callbackType=scSpan)
void SetStringStoreSettings (UINT uFileNameCodePage, bool bStoreNameInExtraData=false)
void SetStringStoreSettings (UINT uFileNameCodePage, bool bStoreNameInExtraData, UINT uCommentCodePage)
void SetStringStoreSettings (const CZipStringStoreSettings &settings)
bool SetSystemCompatibility (int iSystemComp)
void SetTempPath (LPCTSTR lpszPath=NULL, bool bForce=true)
bool ShiftData (ZIP_SIZE_TYPE uOffset)
bool TestFile (ZIP_INDEX_TYPE uIndex, DWORD uBufSize=65536)
CZipString TrimRootPath (CZipPathComponent &zpc) const
ZIP_INDEX_TYPE WillBeDuplicated (LPCTSTR lpszFilePath, bool bFullPath, bool bFileNameOnly=false, int iWhat=prAuto)
bool WillEncryptNextFile () const
bool WriteNewFile (const void *pBuf, DWORD uSize)

Static Public Member Functions

static bool RemovePathBeginning (LPCTSTR lpszBeginning, CZipString &szPath, ZIPSTRINGCOMPARE pCompareFunction)

Public Attributes

bool m_bRemoveDriveLetter

Static Public Attributes

static const char m_gszCopyright []
static const char m_gszVersion []

Protected Types

enum  OpenFileType { extract = -1, nothing, compress }

Protected Member Functions

void ClearCompressor ()
void ClearCryptograph ()
virtual void CreateCompressor (WORD uMethod)
virtual void CreateCryptograph (int iEncryptionMethod)
CZipFileHeaderCurrentFile ()
bool EncryptFilesInternal (CZipIndexesArray *pIndexes)
void InitOnOpen (int iArchiveSystCompatib, CZipCentralDir *pSource=NULL)
void OpenInternal (int iMode)
bool OpenNewFile (CZipFileHeader &header, int iLevel, LPCTSTR lpszFilePath, ZIP_INDEX_TYPE uReplaceIndex)
void ReadLocalHeaderInternal (ZIP_INDEX_TYPE uIndex)
void WriteCentralDirectory (bool bFlush=true)

Protected Attributes

bool m_bAutoFlush
bool m_bCaseSensitive
bool m_bExhaustiveRead
ZipArchiveLib::CZipCallbackProvider m_callbacks
CZipCentralDir m_centralDir
int m_iArchiveSystCompatib
DWORD m_iBufferSize
int m_iEncryptionMethod
int m_iFileOpened
CZipAutoBuffer m_pBuffer
CZipCompressorm_pCompressor
CZipCryptographm_pCryptograph
CZipAutoBuffer m_pszPassword
ZIPSTRINGCOMPARE m_pZipCompare
CZipStorage m_storage
CZipStringStoreSettings m_stringSettings
CZipString m_szRootPath
CZipString m_szTempPath
WORD m_uCompressionMethod

Detailed Description

Represents a zip archive file.


Member Enumeration Documentation

The values used in the CZipArchive::Close() method.

Enumerator:
afNoException  Normal closing. Use it, when no exception was thrown while processing the archive.
afAfterException  Use when an exception was thrown. The Close method doesn't write any data but performs necessary cleaning to reuse the CZipArchive object for another archive processing.
afWriteDir  Use when an exception was thrown. The Close method writes the central directory structure to the archive, so that the archive should be usable.

Values describing various archive consistency checks that the library performs. Instruct the library to skip selected checks using the SetIgnoredConsistencyChecks method.

Enumerator:
checkNone  If used in the the SetIgnoredConsistencyChecks method, checks for all inconsistencies in an archive.
checkCRC  Check CRC after decompression. Use it when working with Java TM Archives (jar). The CRC check is performed using CRC written in a central header when closing a file after extraction.
checkLocalMethod  Check if the compression method written in a local header matches the compression method written in a central header.
checkLocalSizes  Check if sizes of compressed and uncompressed data written in a local header match their counterparts in a central header. The compressed size in the local header is always ignored, if it is 0.
checkLocalCRC  Check if the CRC written in a local header matches the CRC written in a central header.
checkLocalFlag  Check if the general purpose flag value written in a local header matches its counterpart written in a central header.
checkLocalAll  Check for inconsistencies between central and local headers at all. These checks are performed when opening a file for extraction.
checkDataDescriptor  Check if values written in extra data descriptor match values written in central header. This check is performed when closing a file after extraction, only if a file has a data descriptor (see CZipFileHeader::IsDataDescriptor()). Ignored by default (it is consistent with behavior of popular archivers).
checkAll  Logical sum of all possible checks.
checkIgnoredByDefault  Checks that are ignored by default by the ZipArchive Library.

Case-sensitivity values used as the iCaseSensitive argument in the FindFile() method.

Enumerator:
ffDefault  Uses the default case-sensitivity as set with the SetCaseSensitivity method. If the Find Fast array was built before with a different case-sensitivity, it is rebuilt again, if it hasn't been built so far, it is built now with the default case-sensitivity.
ffCaseSens  Performs a case-sensitive search. If the CZipArchive is non-case-sensitive, a less effective search is performed. It does not rebuild the Find Fast array, but if the array hasn't been built yet, it is built now as non-case-sensitive (you can use SetCaseSensitivity(true) and then ffDefault to build it as case-sensitive).
ffNoCaseSens  Performs a non-case-sensitive search. If the CZipArchive is case-sensitive, a less effective search is performed. It does not rebuild the Find Fast array, but if the array hasn't been built yet, it is build now as case-sensitive (you can use SetCaseSensitivity(false) and then ffDefault to build it as non-case-sensitive).

enum CZipArchive::OpenFileType [protected]

The open mode of the current file inside archive.

Enumerator:
extract  A file is opened for extraction.
nothing  There is no file inside the archive opened.
compress  A new file is opened for compression.

Archive open modes used in the CZipArchive::Open(LPCTSTR, int, ZIP_SIZE_TYPE) and CZipArchive::Open(CZipAbstractFile&, int ) methods.

Enumerator:
zipOpen  Opens an existing archive.
zipOpenReadOnly  Opens an existing archive as a read only file. This mode is intended to use in a self extract code, when opening an archive on a storage without the write access (e.g. CD-ROMS) or when sharing the central directory (see OpenFrom()). If you try to modify the archive in this mode, an exception will be thrown.
zipCreate  Creates a new archive.
zipCreateSegm  Creates a segmented archive.
zipCreateAppend  Creates a new archive, but allows appending the archive to an existing file (which can be for example a self-extracting stub).

The values used in the PredictFileNameInZip() method.

Enumerator:
prDir  If lpszFilePath is a directory, appends a separator.
prFile  Treats lpszFilePath as a common file.
prAuto  Treats lpszFilePath as a directory only if it has a path separator appended.

The type of the callback object used during changing volumes in a segmented archive.

See also:
CZipArchive::SetSegmCallback
Enumerator:
scSpan  The callback object will be set for operations on spanned archives only.
scSplit  The callback object will be set for operations on split archives only.
scAll  The callback object will be set for operations spanned and split archives.

The levels of smartness of the adding files action (CZipArchive::AddNewFile).

Note:
If you use zipsmCheckForEff, you should use zipsmNotCompSmall as well, because the small file will be surely larger after compression, so that you can add it not compressed straight away. The compression level is always ignored for a directory and set to 0.
Enumerator:
zipsmLazy  All the smartness options turned off.
zipsmCPassDir  Clears the password for directories.
zipsmCPFile0  Clears the password for files of 0 size.
zipsmNotCompSmall  Does not compress files smaller than 5 bytes - they are always stored larger than uncompressed.
zipsmCheckForEff  Checks whether the compressed file is larger than uncompressed and if so, remove it and store without the compression. In a segmented archive, a temporary file is used for that: if the file compression is efficient, the data is not compressed again, but moved from the temporary file to the archive. You can use the SetTempPath method to set the path where the file will be created or you can let the library figure it out (see SetTempPath). If the the library could not find enough free space for the temporary file, the compression goes the usual way.
zipsmMemoryFlag  Combine it with zipsmCheckForEff or use zipsmCheckForEffInMem, the temporary file will be created in memory then. This flag is effective also when replacing files (see the note at CZipAddNewFileInfo::m_uReplaceIndex).
zipsmCheckForEffInMem  The same as zipsmCheckForEff, but the temporary file is created created in memory instead. It has the meaning only in a segmented archive, not segmented archives don't need a temporary file.
zipsmSmartPass  The password policy (a combination of zipsmCPassDir and zipsmCPFile0).
zipsmSmartAdd  Smart adding (a combination of zipsmNotCompSmall and zipsmCheckForEff).
zipsmSafeSmart  Safe smart (smartest without checking for efficiency).
zipsmSmartest  Smartness at its best.
zipsmInternal01  Intended for the internal use only.


Member Function Documentation

bool CZipArchive::AddNewFile ( CZipMemFile &  mf,
LPCTSTR  lpszFileNameInZip,
int  iComprLevel = -1,
int  iSmartLevel = zipsmSafeSmart,
unsigned long  nBufSize = 65536 
)

Adds a new file to the opened archive. See the AddNewFile(CZipAddNewFileInfo& ) method. The parameters are equivalent to CZipAddNewFileInfo member variables.

bool CZipArchive::AddNewFile ( LPCTSTR  lpszFilePath,
LPCTSTR  lpszFileNameInZip,
int  iComprLevel = -1,
int  iSmartLevel = zipsmSafeSmart,
unsigned long  nBufSize = 65536 
)

Adds a new file to the opened archive. See the AddNewFile(CZipAddNewFileInfo& ) method. The parameters are equivalent to CZipAddNewFileInfo member variables.

bool CZipArchive::AddNewFile ( LPCTSTR  lpszFilePath,
int  iComprLevel = -1,
bool  bFullPath = true,
int  iSmartLevel = zipsmSafeSmart,
unsigned long  nBufSize = 65536 
)

Adds a new file to the opened archive. See the AddNewFile(CZipAddNewFileInfo& ) method. The parameters are equivalent to CZipAddNewFileInfo member variables.

bool CZipArchive::AddNewFile ( CZipAddNewFileInfo info  ) 

Adds a new file to the opened archive.

Parameters:
info See CZipAddNewFileInfo for more information.
Returns:
If false then the file was not added (in this case, you can still try to add other files); true otherwise.
Note:
  • If you abort the operation from a callback object, while adding a file in a not segmented archive, the added data will be removed from the archive.
  • Throws exceptions. When an exception is thrown, you may need to call CloseNewFile with bAfterException set to true, to make the archive reusable.
See also:
Compressing Data

Progress Notifications: Using Callback Objects

In-Memory Archive Processing

AddNewFile(LPCTSTR, LPCTSTR, int, int, unsigned long)

AddNewFile(LPCTSTR, int, bool, int, unsigned long)

AddNewFile(CZipMemFile&, LPCTSTR, int, int, unsigned long)

AddNewFiles(LPCTSTR, ZipArchiveLib::CFileFilter&, bool, int, bool, int, unsigned long)

AddNewFiles(LPCTSTR, LPCTSTR, bool, int, bool, int, unsigned long)

SetCallback

bool CZipArchive::AddNewFiles ( LPCTSTR  lpszPath,
LPCTSTR  lpszFileMask = _T("*.*"),
bool  bRecursive = true,
int  iComprLevel = -1,
bool  bSkipInitialPath = true,
int  iSmartLevel = zipsmSafeSmart,
unsigned long  nBufSize = 65536 
) [inline]

Adds new files to the opened archive from the specified directory using a filename mask.

Parameters:
lpszPath The root directory containing the files to add.
lpszFileMask The filename mask to filter the files. Only files that has a filename matching this mask will be added to the archive. This method internally uses ZipArchiveLib::CNameFileFilter.
bRecursive true, if the files from the subfolders of lpszPath should also be added; false otherwise.
iComprLevel The level of compression. You can use values from 0 to 9 and -1 (meaning the default compression) or one of the CZipCompressor::CompressionLevel values.
bSkipInitialPath true, if the lpszPath directory should be trimmed out of the paths stored in the archive; false otherwise.
iSmartLevel The smartness level of the file adding process. Can be one or combined Smartness values (you can use the logical OR).
nBufSize The size of the buffer used while file operations.
Returns:
If false then some files were probably not added (in this case, you can still try to add other files); true otherwise.
Note:
Throws exceptions.
See also:
name: Searching in an Archive

AddNewFiles(LPCTSTR, ZipArchiveLib::CFileFilter&, bool, int, bool, int, unsigned long)

AddNewFile(CZipAddNewFileInfo&)

AddNewFile(LPCTSTR, LPCTSTR, int, int, unsigned long)

AddNewFile(LPCTSTR, int, bool, int, unsigned long)

AddNewFile(CZipMemFile&, LPCTSTR, int, int, unsigned long)

bool CZipArchive::AddNewFiles ( LPCTSTR  lpszPath,
ZipArchiveLib::CFileFilter filter,
bool  bRecursive = true,
int  iComprLevel = -1,
bool  bSkipInitialPath = true,
int  iSmartLevel = zipsmSafeSmart,
unsigned long  nBufSize = 65536 
)

Adds new files to the opened archive from the specified directory using a filter.

Parameters:
lpszPath The root directory containing the files to add.
filter A filter that determines which files should be added.
bRecursive true, if the files from the subfolders of lpszPath should also be added; false otherwise.
iComprLevel The level of compression. You can use values from 0 to 9 and -1 (meaning the default compression) or one of the CZipCompressor::CompressionLevel values.
bSkipInitialPath true, if the lpszPath directory should be trimmed out of the paths stored in the archive; false otherwise.
iSmartLevel The smartness level of the file adding process. Can be one or combined Smartness values (you can use the logical OR).
nBufSize The size of the buffer used while file operations.
Returns:
If false then some files were probably not added (in this case, you can still try to add other files); true otherwise.
Note:
Throws exceptions.
See also:
Compressing Data

ZipArchiveLib::CFileFilter

ZipArchiveLib::CNameFileFilter

ZipArchiveLib::CGroupFileFilter

AddNewFiles(LPCTSTR, LPCTSTR, bool, int, bool, int, unsigned long)

AddNewFile(CZipAddNewFileInfo&)

AddNewFile(LPCTSTR, LPCTSTR, int, int, unsigned long)

AddNewFile(LPCTSTR, int, bool, int, unsigned long)

AddNewFile(CZipMemFile&, LPCTSTR, int, int, unsigned long)

void CZipArchive::ClearCompressor (  )  [inline, protected]

Releases the current compressor.

void CZipArchive::ClearCryptograph (  )  [inline, protected]

Releases the current cryptograph.

void CZipArchive::Close ( int  iAfterException = afNoException,
bool  bUpdateTimeStamp = false 
)

Closes the archive.

Parameters:
iAfterException One of the CloseAfterException values.
bUpdateTimeStamp If true, the method sets the modification date of the zip file to the date of the newest file in the archive. In a segmented archive, only the last segment file will have the time stamp updated. You can use this option even without performing any additional processing on the archive, just open and close the archive.
Note:
Throws exceptions. Does not throw any exceptions, if iAfterException is set to the afAfterException value.
See also:
Exceptions Handling

IsClosed

int CZipArchive::CloseFile ( CZipFile &  file  ) 

Closes file and then calls the CloseFile(LPCTSTR, bool) method using the path of file as an argument. Don't call this method, if an exception was thrown before, call the CloseFile(LPCTSTR, bool) method instead.

Parameters:
file A CZipFile object of the extracted file. It must be opened.
Returns:
The same values as the CloseFile(LPCTSTR, bool) method.
Note:
Throws exceptions.
See also:
Extracting Data and Testing Archives

OpenFile

ReadFile

CloseFile(LPCTSTR, bool)

int CZipArchive::CloseFile ( LPCTSTR  lpszFilePath = NULL,
bool  bAfterException = false 
)

Closes the file opened for extraction in the archive and copy its date and attributes to the file pointed by lpszFilePath.

Parameters:
lpszFilePath The path of the file to have the date and attributes information updated. Make sure you have the read access to this file.
bAfterException Set it to true, when you call this method after an exception was thrown, to allow further operations on the archive.
Returns:
One of the following values:
  • 1 : The operation was successful.
  • 0 : There is no file opened.
  • -1 : Some bytes were left to uncompress - probably due to a bad password or a corrupted archive.
  • -2 : Setting extracted file date and attributes was not successful.
See also:
Extracting Data and Testing Archives

OpenFile

ReadFile

CloseFile(CZipFile&)

Note:
Throws exceptions.

bool CZipArchive::CloseNewFile ( bool  bAfterException = false  ) 

Closes the new file in the archive.

Returns:
false, if there is no new file opened; true otherwise.
Parameters:
bAfterException If true, the new file will be closed without writing anything. Set it to true after an exception was thrown. Use it also this way if an exception other than CZipException::abortedSafely was thrown from one of the AddNewFile methods.
Note:
Throws exceptions.
See also:
Compressing Data

OpenNewFile

WriteNewFile

virtual void CZipArchive::CreateCompressor ( WORD  uMethod  )  [inline, protected, virtual]

Creates a new compressor. You can override this method and implement your own compressor.

Parameters:
uMethod The requested data compression method.
See also:
CZipCompressor::CompressionMethod

virtual void CZipArchive::CreateCryptograph ( int  iEncryptionMethod  )  [inline, protected, virtual]

Creates a new cryptograph. You can override this method and implement your own cryptograph.

Parameters:
iEncryptionMethod The requested encryption method.
See also:
CZipCryptograph::EncryptionMethod

CZipFileHeader* CZipArchive::CurrentFile (  )  [protected]

Gets the file currently opened for compression or decompression.

Returns:
The currently opened file or NULL, if there is no file opened.

void CZipArchive::EnableFindFast ( bool  bEnable = true  ) 

Enables or disables fast searching for files inside the archive using filenames.

See also:
Searching in an Archive

FindFile

GetIndexes

GetFindFastIndex

bool CZipArchive::EncryptAllFiles (  )  [inline]

Encrypts all existing files in the archive using the current encryption method.

Returns:
false, if the files could not be encrypted; true otherwise.
Note:
See also:
Encryption Methods: How to Best Protect Your Data

SetEncryptionMethod

SetPassword

WillEncryptNextFile

EncryptFile

EncryptFiles

bool CZipArchive::EncryptFile ( ZIP_INDEX_TYPE  uIndex  )  [inline]

Encrypts an existing file with a given index using the current encryption method.

Parameters:
uIndex The index of the file to encrypt.
Returns:
false, if the file could not be encrypted; true otherwise.
Note:
See also:
Encryption Methods: How to Best Protect Your Data

SetEncryptionMethod

SetPassword

WillEncryptNextFile

EncryptFiles

EncryptAllFiles

bool CZipArchive::EncryptFiles ( CZipIndexesArray &  aIndexes  )  [inline]

Encrypts existing files with given indexes using the current encryption method.

Parameters:
aIndexes The indexes of files to encrypt.
Returns:
false, if the files could not be encrypted; true otherwise.
Note:
See also:
Encryption Methods: How to Best Protect Your Data

SetEncryptionMethod

SetPassword

WillEncryptNextFile

EncryptFile

EncryptAllFiles

bool CZipArchive::EncryptFilesInternal ( CZipIndexesArray *  pIndexes  )  [protected]

See the description of EncryptFiles.

Parameters:
pIndexes 
Returns:
false, if the files could not be encrypted; true otherwise.
Note:
Throws exceptions.
See also:
EncryptFiles

bool CZipArchive::ExtractFile ( ZIP_INDEX_TYPE  uIndex,
CZipMemFile &  mf,
bool  bRewind = true,
CZipCompressor::COffsetsPair pSeekPair = NULL,
DWORD  nBufSize = 65536 
)

The same as ExtractFile(ZIP_INDEX_TYPE, LPCTSTR, bool, LPCTSTR, CZipCompressor::COffsetsPair*, DWORD ) but instead to a physical file, this method extracts data into a CZipMemFile object.

Parameters:
uIndex The index of the file to extract.
mf The memory file to receive the decompressed data.
bRewind If true, the memory file pointer is positioned at the beginning of the compressed data after compression. The rewind operation is performed even if extraction was aborted, but rewinding will not take place, if other exception than CZipException::abortedAction or CZipException::abortedSafely was thrown in the meantime.
pSeekPair If not NULL, the file will be extracted starting from the seek position describ