Represents a zip archive file. More...
#include <ZipArchive.h>
Public Types | |
enum | CloseAfterException { afNoException, afAfterException, afWriteDir } |
enum | CommitMode { cmManual, cmOnChange } |
enum | ConsistencyCheck { checkNone, checkCRC = 0x0001, checkLocalMethod = 0x0002, checkLocalSizes = 0x0004, checkLocalCRC = 0x0008, checkLocalFlag = 0x0010, checkLocalAll = checkLocalMethod | checkLocalSizes | checkLocalCRC | checkLocalFlag, checkDataDescriptor = 0x0100, checkVolumeEntries = 0x0200, checkDecryptionVerifier = 0x0400, checkTrimmedCentralDir = 0x0800, checkInvalidExtraData = 0x1000, checkAll = checkCRC | checkLocalAll | checkDataDescriptor | checkVolumeEntries | checkDecryptionVerifier | checkTrimmedCentralDir | checkInvalidExtraData, checkIgnoredByDefault = checkDataDescriptor | checkVolumeEntries } |
enum | FFCaseSens { ffDefault, ffCaseSens, ffNoCaseSens } |
enum | OpenMode { zipOpen = 0x0001, zipOpenReadOnly = zipOpen | 0x0002, zipCreate = 0x0004, zipCreateAppend = zipCreate | 0x0008, zipModeSplit = 0x0100, zipModeBinSplit = 0x0200, zipModeSpan = 0x0400, zipModeSegmented = zipModeSplit | zipModeBinSplit | zipModeSpan, zipCreateSplit = zipCreate | zipModeSplit, zipCreateBinSplit = zipCreate | zipModeBinSplit, zipCreateSpan = zipCreate | zipModeSpan, zipOpenSplit = zipOpenReadOnly | zipModeSplit, zipOpenBinSplit = zipOpenReadOnly | zipModeBinSplit } |
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, zipsmIgnoreDirectories = 0x0020, zipsmInternal01 = 0xf000 } |
enum | SpecialFlags { sfNone, sfExhaustiveRead = 0x0001 } |
enum | UnicodeMode { umNone = 0x00, umCustom = 0x04 } |
Public Member Functions | |
bool | AddNewFile (CZipAddNewFileInfo &info) |
bool | AddNewFile (LPCTSTR lpszFilePath, int iComprLevel=-1, bool bFullPath=true, 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 (CZipAbstractFile &af, LPCTSTR lpszFileNameInZip, int iComprLevel=-1, 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) |
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 (CZipAddFilesEnumerator &addFilesEnumerator, ZipArchiveLib::CFileFilter &filter, bool bSkipInitialPath=true) |
bool | CanModify (bool bAllowNewSegmented=false, bool bNeedsClosed=true) |
CZipString | Close (int iAfterException=afNoException, bool bUpdateTimeStamp=false) |
int | CloseFile (LPCTSTR lpszFilePath=NULL, bool bAfterException=false) |
int | CloseFile (CZipFile &file) |
bool | CloseNewFile (bool bAfterException=false) |
bool | CommitChanges () |
void | EnableFindFast (bool bEnable=true) |
bool | EncryptAllFiles () |
bool | EncryptFile (ZIP_INDEX_TYPE uIndex) |
bool | EncryptFiles (CZipIndexesArray &aIndexes) |
bool | ExtractFile (ZIP_INDEX_TYPE uIndex, LPCTSTR lpszPath, bool bFullPath=true, LPCTSTR lpszNewName=NULL, ZipPlatform::FileOverwriteMode iOverwriteMode=ZipPlatform::fomRegular, DWORD nBufSize=65536) |
bool | ExtractFile (ZIP_INDEX_TYPE uIndex, CZipAbstractFile &af, bool bRewind=true, DWORD nBufSize=65536) |
bool | Finalize (bool bOnlyIfAuto=false) |
ZIP_INDEX_TYPE | FindFile (LPCTSTR lpszFileName, int iCaseSensitive=ffDefault, bool bFileNameOnly=false) |
void | FindMatches (LPCTSTR lpszPattern, CZipIndexesArray &ar, bool bFullPath=true) |
void | FlushBuffers () |
void | GetAdvanced (int *piWriteBuffer=NULL, int *piGeneralBuffer=NULL, int *piSearchBuffer=NULL) |
CZipString | GetArchivePath () const |
bool | GetAutoFinalize () const |
ZIP_SIZE_TYPE | GetBytesBeforeZip () const |
CZipActionCallback * | GetCallback (CZipActionCallback::CallbackType iWhich) |
bool | GetCaseSensitivity () const |
void | GetCentralDirInfo (CZipCentralDir::CInfo &info) const |
ZIP_SIZE_TYPE | GetCentralDirSize (bool bWhole=true) const |
int | GetCommitMode () const |
WORD | GetCompressionMethod () const |
ZIP_INDEX_TYPE | GetCount (bool bOnlyFiles) |
ZIP_INDEX_TYPE | GetCount () const |
const CZipCompressor * | GetCurrentCompressor () const |
ZIP_VOLUME_TYPE | GetCurrentVolume () const |
int | GetEncryptionMethod () const |
bool | GetFileInfo (CZipFileHeader &fhInfo, ZIP_INDEX_TYPE uIndex) const |
CZipFileHeader * | GetFileInfo (ZIP_INDEX_TYPE uIndex) |
const CZipFileHeader * | GetFileInfo (ZIP_INDEX_TYPE uIndex) const |
ZIP_INDEX_TYPE | GetFindFastIndex (ZIP_INDEX_TYPE iFindFastIndex) const |
bool | GetFromArchive (CZipArchive &zip, ZIP_INDEX_TYPE uIndex, LPCTSTR lpszNewFileName=NULL, ZIP_INDEX_TYPE uReplaceIndex=ZIP_FILE_INDEX_UNSPECIFIED, bool bKeepSystComp=false) |
bool | GetFromArchive (CZipArchive &zip, CZipIndexesArray &aIndexes, bool bKeepSystComp=false, bool bReplaceMode=false) |
bool | GetFromArchive (CZipArchive &zip, CZipStringArray &aNames, bool bKeepSystComp=false) |
CZipString | GetGlobalComment () const |
int | GetIgnoredConsistencyChecks () const |
void | GetIndexes (const CZipStringArray &aNames, CZipIndexesArray &aIndexes) |
ZIP_INDEX_TYPE | GetLastIndexAdded () const |
ZIP_SIZE_TYPE | GetOccupiedSpace () const |
CZipString | GetPassword () const |
CZipString | GetRootPath () const |
int | GetSpecialFlags () const |
CZipStorage * | GetStorage () |
CZipStringStoreSettings & | GetStringStoreSettings () |
int | GetSystemCompatibility () const |
CZipString | GetTempPath () const |
int | GetUnicodeMode () const |
bool | IsClosed (bool bArchive=true) const |
bool | IsFullFileTimes () const |
bool | IsModified () const |
bool | IsPasswordSet () const |
bool | IsReadOnly () |
bool | IsUseUtcFileTimes () const |
bool | Open (LPCTSTR szPathName, int iMode=zipOpen, ZIP_SIZE_TYPE uVolumeSize=0) |
bool | Open (CZipAbstractFile &af, int iMode=zipOpen, bool bAutoClose=false) |
bool | OpenFile (ZIP_INDEX_TYPE uIndex) |
bool | OpenFrom (CZipArchive &zip, CZipAbstractFile *pArchiveFile=NULL, bool bAllowNonReadOnly=false) |
bool | OpenNewFile (CZipFileHeader &header, int iLevel=CZipCompressor::levelDefault, LPCTSTR lpszFilePath=NULL) |
CZipFileHeader * | operator[] (ZIP_INDEX_TYPE uIndex) |
const CZipFileHeader * | operator[] (ZIP_INDEX_TYPE uIndex) const |
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 (CZipFileHeader &fh) |
ZIP_SIZE_TYPE | PredictMaximumFileSizeInArchive (LPCTSTR lpszFilePath, bool bFullPath) |
bool | PrependData (LPCTSTR lpszFilePath, LPCTSTR lpszNewExt=) |
bool | PrependData (CZipAbstractFile &file, LPCTSTR lpszNewExt=NULL) |
DWORD | ReadFile (void *pBuf, DWORD uSize) |
bool | ReadLocalHeader (ZIP_INDEX_TYPE uIndex) |
bool | RemoveCentralDirectoryFromArchive () |
bool | RemoveFile (ZIP_INDEX_TYPE uIndex, bool bRemoveData=true) |
bool | RemoveFiles (CZipIndexesArray &aIndexes) |
bool | RemoveFiles (const CZipStringArray &aNames) |
bool | ResetCurrentVolume () |
void | ResetStringStoreSettings () |
void | SetAdvanced (int iWriteBuffer=65536, int iGeneralBuffer=65536, int iSearchBuffer=32768) |
bool | SetAutoFinalize (bool bAutoFinalize=true) |
const void | SetBytesBeforeZip (ZIP_SIZE_TYPE uCount=0) |
void | SetCallback (CZipActionCallback *pCallback=NULL, int iWhich=CZipActionCallback::cbAll) |
void | SetCaseSensitivity (bool bCaseSensitive) |
void | SetCommitMode (int iCommitMode=cmOnChange) |
bool | SetCompressionMethod (WORD uCompressionMethod=CZipCompressor::methodDeflate) |
void | SetCompressionOptions (CZipCompressor::COptions *pOptions) |
bool | SetEncryptionMethod (int iEncryptionMethod=CZipCryptograph::encStandard) |
void | SetFullFileTimes (bool bFullFileTimes=true) |
bool | SetGlobalComment (LPCTSTR lpszComment, UINT codePage=ZIP_DEFAULT_CODE_PAGE) |
void | SetIgnoredConsistencyChecks (int iLevel=checkIgnoredByDefault) |
bool | SetPassword (LPCTSTR lpszPassword=NULL, UINT codePage=ZIP_DEFAULT_CODE_PAGE) |
void | SetRootPath (LPCTSTR szPath=NULL) |
void | SetSegmCallback (CZipSegmCallback *pCallback=NULL, int callbackType=scSpan) |
void | SetSpecialFlags (int iSpecialFlags) |
bool | SetSplitNamesHandler (CZipSplitNamesHandler &names) |
bool | SetSplitNamesHandler (CZipSplitNamesHandler *pNames, bool bAutoDelete=true) |
void | SetStringStoreSettings (const CZipStringStoreSettings &settings) |
void | SetStringStoreSettings (UINT uFileNameCodePage, bool bStoreNameInExtraData, UINT uCommentCodePage) |
void | SetStringStoreSettings (UINT uFileNameCodePage, bool bStoreNameInExtraData=false) |
bool | SetSystemCompatibility (int iSystemComp) |
void | SetTempPath (LPCTSTR lpszPath=NULL, bool bForce=true) |
void | SetUnicodeMode (int iMode) |
void | SetUseUtcFileTimes (bool bUseUtcFileTimes=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 | IsZipArchive (LPCTSTR lpszPathName) |
static bool | IsZipArchive (CZipAbstractFile &af, bool bAutoClose=false) |
static bool | RemovePathBeginning (LPCTSTR lpszBeginning, CZipString &szPath, ZIPSTRINGCOMPARE pCompareFunction) |
Public Attributes | |
bool | m_bSafePaths |
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) |
CZipFileHeader * | CurrentFile () |
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_bAutoFinalize |
bool | m_bCaseSensitive |
bool | m_bStoreFullFileTimes |
bool | m_bUseUtcFileTimes |
ZipArchiveLib::CZipCallbackProvider | m_callbacks |
CZipCentralDir | m_centralDir |
int | m_iArchiveSystCompatib |
DWORD | m_iBufferSize |
int | m_iCommitMode |
int | m_iEncryptionMethod |
int | m_iFileOpened |
CZipAutoBuffer | m_pBuffer |
CZipCompressor * | m_pCompressor |
CZipCryptograph * | m_pCryptograph |
CZipAutoBuffer | m_pszPassword |
ZIPSTRINGCOMPARE | m_pZipCompare |
CZipStorage | m_storage |
CZipStringStoreSettings | m_stringSettings |
CZipString | m_szRootPath |
CZipString | m_szTempPath |
WORD | m_uCompressionMethod |
Represents a zip archive file.
Definition at line 202 of file ZipArchive.h.
The values used in the CZipArchive::Close() method.
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. |
Definition at line 2147 of file ZipArchive.h.
The mode of committing changes.
cmManual |
Changes will be committed when the CommitChanges method is called or when closing the archive. |
cmOnChange |
Changes will be committed immediately after they occur. |
Definition at line 3008 of file ZipArchive.h.
The values describing various archive consistency checks that the library performs. Instruct the library to skip selected checks using the SetIgnoredConsistencyChecks method.
checkNone |
If used in the SetIgnoredConsistencyChecks method, examines all possible inconsistencies in an archive. |
checkCRC |
Verifies 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 |
Verifies that the compression method written in a local header matches the compression method written in a central header. |
checkLocalSizes |
Verifies that 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 |
checkLocalCRC |
Verifies that the CRC written in a local header matches the CRC written in a central header. |
checkLocalFlag |
Verifies that the general purpose flag value written in a local header matches its counterpart written in a central header. |
checkLocalAll |
Examines all possible inconsistencies between central and local headers. These verifications are performed when opening a file for extraction. |
checkDataDescriptor |
Verifies that values written in extra data descriptor match values written in central header. This verification is performed when closing a file after extraction, but only if a file has a data descriptor (see CZipFileHeader::IsDataDescriptor()). Ignored by default (it is consistent with behavior of popular archivers). |
checkVolumeEntries |
Verifies that the number of volumes and entries are correctly reported. |
checkDecryptionVerifier |
Verifies control bytes during CRC32 and AES decryption initialization. |
checkTrimmedCentralDir |
Verifies that the central directory is written in its entirety. |
checkInvalidExtraData |
Verifies that the extra data is valid. |
checkAll |
Logical sum of all possible verifications. |
checkIgnoredByDefault |
Checks that are ignored by default by the ZipArchive Library. |
Definition at line 2876 of file ZipArchive.h.
Case-sensitivity values used as the iCaseSensitive argument in the FindFile() method. The purpose of ffCaseSens and ffNoCaseSens is to temporarily change the default case-sensitivity for a single search. This is the reason, why these values cause the Find Fast array (which is a more permanent solution) to be built with the opposite meaning. In these cases the array is not rebuilt if it was built already.
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 |
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 |
Definition at line 1883 of file ZipArchive.h.
|
protected |
The open mode of the current file inside the archive.
extract |
A file is opened for extraction. |
nothing |
There is no file inside the archive opened. |
compress |
A new file is opened for compression. |
Definition at line 3407 of file ZipArchive.h.
The archive open modes used in the CZipArchive::Open(LPCTSTR, int, ZIP_SIZE_TYPE) and CZipArchive::Open(CZipAbstractFile&, int, bool) methods.
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. |
zipCreateAppend |
Creates a new archive, but allows appending the archive to an existing file (which can be for example a self-extracting stub). |
zipCreateSplit |
Creates a split archive. |
zipCreateBinSplit |
Creates a binary split archive. |
zipCreateSpan |
Creates a span archive. |
zipOpenSplit |
Opens an existing split archive. Use when opening split archives on removable devices or under Linux/OS X. |
zipOpenBinSplit |
Opens an existing binary split archive. |
Definition at line 659 of file ZipArchive.h.
enum CZipArchive::Predict |
The values used in the PredictFileNameInZip() method.
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. |
Definition at line 2602 of file ZipArchive.h.
The type of the callback object used during changing volumes in a segmented archive.
Definition at line 580 of file ZipArchive.h.
The levels of smartness of the ZipArchive Library while adding files with the CZipArchive::AddNewFile methods.
zipsmLazy |
All the smartness options are 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 |
If the compressed file is larger than uncompressed after compression, removes the file and stores it 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 library could not find enough free space for the temporary file, the compression is performed the usual way. |
zipsmMemoryFlag |
When combined with zipsmCheckForEff or zipsmCheckForEffInMem, it creates the temporary file in memory. 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 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 (all smartness levels but checking for the compression efficiency). |
zipsmSmartest |
Smartness at its best. |
zipsmIgnoreDirectories |
Ignores empty directories when using directory filter with the AddNewFiles method.
|
Definition at line 822 of file ZipArchive.h.
Flags for workarounding various problems in archives.
Definition at line 2900 of file ZipArchive.h.
The Unicode mode of the archive.
Definition at line 2481 of file ZipArchive.h.
bool CZipArchive::AddNewFile | ( | CZipAddNewFileInfo & | info | ) |
Adds a new file to the opened archive.
info | See CZipAddNewFileInfo for more information. |
false
then the file was not added (in this case, you can still try to add other files); true
otherwise.true
, to continue working with the archive.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 | ( | 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 | ( | CZipAbstractFile & | af, |
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::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.
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 removed from paths stored in the archive; false otherwise. |
iSmartLevel | The smartness level of the file adding process. It can be one or more of the Smartness values. |
nBufSize | The size of the buffer used during file operations. |
false
then some files were probably not added (in this case, you can still try to add other files); true
otherwise.
|
inline |
Adds new files to the opened archive from the specified directory using a filename mask.
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 removed from paths stored in the archive; false otherwise. |
iSmartLevel | The smartness level of the file adding process. It can be one or more of the Smartness values. |
nBufSize | The size of the buffer used during file operations. |
false
then some files were probably not added (in this case, you can still try to add other files); true
otherwise.Definition at line 1049 of file ZipArchive.h.
bool CZipArchive::AddNewFiles | ( | CZipAddFilesEnumerator & | addFilesEnumerator, |
ZipArchiveLib::CFileFilter & | filter, | ||
bool | bSkipInitialPath = true |
||
) |
Adds new files to the opened archive using the given directory enumerator using a filter. To replace files in the archive while adding, use the CReplacingAddFilesEnumerator class.
addFilesEnumerator | The enumerator responsible for adding of files. |
filter | A filter that determines which files should be added. |
bSkipInitialPath | true , if the lpszPath directory should be removed from paths stored in the archive; false otherwise. |
false
then some files were probably not added (in this case, you can still try to add other files); true
otherwise.
|
inline |
Returns the value indicating whether the archive can be modified.
bAllowNewSegmented | If true , new segmented archives can be modified; false otherwise. |
bNeedsClosed | If true , the archive that has a file opened cannot be modified; false otherwise. |
true
, if the archive can be modified; false
otherwise. Definition at line 3153 of file ZipArchive.h.
|
inlineprotected |
Releases the current compressor.
Definition at line 3516 of file ZipArchive.h.
|
inlineprotected |
Releases the current cryptograph.
Definition at line 3480 of file ZipArchive.h.
CZipString CZipArchive::Close | ( | int | iAfterException = afNoException , |
bool | bUpdateTimeStamp = false |
||
) |
Closes the archive.
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. |
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.
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. |
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.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.
file | A CZipFile object of the extracted file. It must be opened. |
bool CZipArchive::CloseNewFile | ( | bool | bAfterException = false | ) |
Closes the new file in the archive.
false
, if there is no new file opened; true
otherwise.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. |
bool CZipArchive::CommitChanges | ( | ) |
Writes pending changes to the archive.
true
, if changes were written successfully; false
, if the current state of the archive is invalid for this method to be called.
|
inlineprotectedvirtual |
Creates a new compressor. You can override this method and implement your own compressor.
uMethod | The requested data compression method. |
Definition at line 3534 of file ZipArchive.h.
|
inlineprotectedvirtual |
Creates a new cryptograph. You can override this method and implement your own cryptograph.
iEncryptionMethod | The requested encryption method. |
Definition at line 3498 of file ZipArchive.h.
|
protected |
Returns the file currently opened for compression or decompression.
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.
|
inline |
Encrypts all existing files in the archive using the current encryption method.
false
, if the files could not be encrypted; true
otherwise.Definition at line 407 of file ZipArchive.h.
|
inline |
Encrypts an existing file with a given index using the current encryption method.
uIndex | The index of the file to encrypt. |
false
, if the file could not be encrypted; true
otherwise.Definition at line 342 of file ZipArchive.h.
|
inline |
Encrypts existing files with given indexes using the current encryption method.
aIndexes | The indexes of files to encrypt. |
false
, if the files could not be encrypted; true
otherwise.Definition at line 377 of file ZipArchive.h.
|
protected |
See the description of EncryptFiles.
pIndexes |
false
, if the files could not be encrypted; true
otherwise.bool CZipArchive::ExtractFile | ( | ZIP_INDEX_TYPE | uIndex, |
LPCTSTR | lpszPath, | ||
bool | bFullPath = true , |
||
LPCTSTR | lpszNewName = NULL , |
||
ZipPlatform::FileOverwriteMode | iOverwriteMode = ZipPlatform::fomRegular , |
||
DWORD | nBufSize = 65536 |
||
) |
Extracts a file from the archive. The argument lpszNewName may point to a full path and is influenced by bFullPath. If lpszNewName contains a drive specification then the drive part is removed unless m_bSafePaths is set to false
.
uIndex | The index of the file to extract. |
lpszPath | The directory to extract the file to. May not be NULL . |
bFullPath | In this paragraph the source path means:
|
lpszNewName | The new name of the file after extraction. If NULL , the original filename stored in the archive is used. May include a path information, but if bFullPath is false , only the filename is extracted from this value. |
iOverwriteMode | The mode used when overwriting a file during extraction. Can be one or more of ZipPlatform::DeleteMode values. |
pSeekPair | If not NULL, the file will be extracted starting from the seek position described by this value. |
nBufSize | The size of the buffer used while file operations. |
true
if successful; false
otherwise.bool CZipArchive::ExtractFile | ( | ZIP_INDEX_TYPE | uIndex, |
CZipAbstractFile & | af, | ||
bool | bRewind = true , |
||
DWORD | nBufSize = 65536 |
||
) |
The same as #ExtractFile(ZIP_INDEX_TYPE, LPCTSTR, bool, LPCTSTR, ZipPlatform::FileOverwriteMode, CZipCompressor::COffsetsPair*, DWORD) but instead to a physical file, this method extracts data into a CZipAbstractFile
object.
uIndex | The index of the file to extract. |
af | An abstract 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 described by this value. |
nBufSize | The size of the buffer used while file operations. |
CZipMemFile
object that already contains data (or has a buffer attached) - its contents may be overwritten.false
.bool CZipArchive::Finalize | ( | bool | bOnlyIfAuto = false | ) |
Writes the central directory to the archive and flushes the internal buffers to the disk. After that the archive is finalized on the disk, but you can still modify it, if it is not a segmented archive.
bOnlyIfAuto | If true , the archive will be finalized only when it is in the auto-finalize mode; false otherwise (default). This parameter is used mostly for internal purposes. |
true
, if the archive was finalized; false
otherwise.ZIP_INDEX_TYPE CZipArchive::FindFile | ( | LPCTSTR | lpszFileName, |
int | iCaseSensitive = ffDefault , |
||
bool | bFileNameOnly = false |
||
) |
Finds a file in the archive. This method enables the Find Fast feature, if it is not enabled already.
lpszFileName | The name of the file to be found in the archive. If the file in the archive is stored with the path information, you must specify it here or set bFileNameOnly to true . Use the same path separators as they are defined for your system as default ("\" for Windows and "/" for Linux and OS X). |
iCaseSensitive | It can be one of the FFCaseSens values. |
bFileNameOnly | If true , the method tries to find a filename without a path (a less effective search is performed). If you wish to find a directory name, do not end it with a path separator. The path separator is required, if you set bFileNameOnly to false . |
ZIP_FILE_INDEX_NOT_FOUND
if the file was not found.void CZipArchive::FindMatches | ( | LPCTSTR | lpszPattern, |
CZipIndexesArray & | ar, | ||
bool | bFullPath = true |
||
) |
Finds indexes of the files, which filenames match the specified pattern. The indexes are stored in the ar array. The indexes can be used then e.g. in deleting or extracting files.
lpszPattern | The pattern to match. The case-sensitivity of the pattern is set to the global archive case-sensitivity (set with the SetCaseSensitivity method). |
ar | The array which will contain the resulting indexes. The contents of ar are not cleared, but the indexes are appended to it. |
bFullPath |
|
|
inline |
Writes internal buffers to the storage file and flushes the file buffers to the disk.
Definition at line 2247 of file ZipArchive.h.
|
inline |
Retrieves buffer sizes as set with the SetAdvanced() method.
piWriteBuffer | |
piGeneralBuffer | |
piSearchBuffer |
Definition at line 517 of file ZipArchive.h.
CZipString CZipArchive::GetArchivePath | ( | ) | const |
Returns the path of the currently opened archive segment.
|
inline |
Returns the current auto-finalize value.
Definition at line 2292 of file ZipArchive.h.
|
inline |
Returns the number of extra bytes that are present before the actual archive in the archive file.
Definition at line 2867 of file ZipArchive.h.
|
inline |
Returns the callback object registered for the given notification.
iWhich | The callback type. It can be one or more of the CZipActionCallback::CallbackType values. |
Definition at line 569 of file ZipArchive.h.
|
inline |
Returns the current case sensitivity.
true
, if the archive is case-sensitive; false
otherwise.Definition at line 2790 of file ZipArchive.h.
void CZipArchive::GetCentralDirInfo | ( | CZipCentralDir::CInfo & | info | ) | const |
Returns the central directory information.
info | The object to retrieve information data. |
|
inline |
Returns the central directory size.
bWhole | If true , the return value includes the size of file headers. |
Definition at line 2818 of file ZipArchive.h.
|
inline |
Returns the current commit mode.
Definition at line 3045 of file ZipArchive.h.
|
inline |
Returns the current compression method used when adding files to the archive.
Definition at line 448 of file ZipArchive.h.
|
inline |
Returns the number of files in the archive.
bOnlyFiles | If true , directories are not included in the total count; otherwise all entries are included. |
Definition at line 2091 of file ZipArchive.h.
|
inline |
Returns the number of files in the archive.
Definition at line 2118 of file ZipArchive.h.
|
inline |
Retrieves the current compressor. The type of the compressor depends on the compression method used for compressing or decompressing data.
Definition at line 3136 of file ZipArchive.h.
ZIP_VOLUME_TYPE CZipArchive::GetCurrentVolume | ( | ) | const |
Returns the archive volume number currently being processed. The first volume has the number 1.
This method is useful while working with a segmented archive in creation to find out how many parts were already created. To find out how many parts are in an existing segmented archive, use the GetCentralDirInfo method.
|
inline |
Returns the current encryption method.
Definition at line 309 of file ZipArchive.h.
bool CZipArchive::GetFileInfo | ( | CZipFileHeader & | fhInfo, |
ZIP_INDEX_TYPE | uIndex | ||
) | const |
Returns the information about the file with the given index. The data is copied to fhInfo. This may not be optimal for querying large number of file. To avoid copying data, see the GetFileInfo(ZIP_INDEX_TYPE) method.
fhInfo | The object to receive data. |
uIndex | A zero-based index of the file to get the information about. |
true
if successful; false
otherwise. CZipFileHeader* CZipArchive::GetFileInfo | ( | ZIP_INDEX_TYPE | uIndex | ) |
Returns the information about the file with the given index. This method provides a direct access to the file data. Apart from the situations described in Requesting Information, Predicting Names and Sizes, you should avoid modifications of the returned object.
uIndex | A zero-based index of the file to get the information about. |
NULL
if the archive is closed or there is no such index in the archive.const CZipFileHeader* CZipArchive::GetFileInfo | ( | ZIP_INDEX_TYPE | uIndex | ) | const |
Returns the information about the file with the given index. This method provides a direct access to the file data. This method does not allow modification of the returned object.
uIndex | A zero-based index of the file to get the information about. |
NULL
if the archive is closed or there is no such index in the archive.
|
inline |
Allows to retrieve the order of sorted files after you enabled the Find Fast feature with the EnableFindFast() method.
iFindFastIndex | The index of the file in the sorted array. |
-1
, if you have not called EnableFindFast before or the archive is closed or the iFindFastIndex is out of range.Definition at line 2544 of file ZipArchive.h.
|
inline |
Acquires a file with the given index from another archive. The compressed data of the file from another archive is copied to the current archive without decompression.
zip | The opened archive to get the file from. |
uIndex | A zero-based index of the file to get from the zip archive. |
lpszNewFileName | The new filename to replace the old one from the zip archive. It can be NULL to leave the filename the same. |
uReplaceIndex | The same as CZipAddNewFileInfo::m_uReplaceIndex. It can be ZIP_FILE_INDEX_UNSPECIFIED . |
bKeepSystComp | If false , then the system compatibility of the file from the zip archive is converted to the current archive system compatibility, if they differ. Otherwise the source system compatibility is copied. |
false
, if the operation could not be performed (either of archives is closed, a file inside either of archives is opened, zip archive is segmented or the current archive is an existing segmented archive.true
, to continue working with the archive.false
from the CZipActionCallback::Callback) in a not segmented archive and when no replacing is taking place. The file that is not entirely added is removed from the archive then.Definition at line 1272 of file ZipArchive.h.
bool CZipArchive::GetFromArchive | ( | CZipArchive & | zip, |
CZipIndexesArray & | aIndexes, | ||
bool | bKeepSystComp = false , |
||
bool | bReplaceMode = false |
||
) |
Acquires files with the given indexes from another archive. The compressed data of the file from another archive is copied to the current archive without decompression.
zip | The opened archive to get the file from. |
aIndexes | An array of zero-based indexes of the files to acquire from the zip archive. |
bKeepSystComp | If false , then the system compatibility of the file from the zip archive is converted to the current archive system compatibility, if they differ. Otherwise the source system compatibility is copied. |
bReplaceMode | If true , then the files are checked for existence in the current archive by names. If a file with the same name exists, it is replaced, otherwise it is added. |
false
, if the operation could not be performed (either of archives is closed, a file inside either of archives is opened, zip archive is segmented or the current archive is an existing segmented archive.true
, to continue working with the archive.false
from the CZipActionCallback::Callback) in a not segmented archive and when no replacing is taking place. The file that is not entirely added is removed from the archive then.
|
inline |
Acquires files with the given names from another archive. The compressed data of the file from another archive is copied to the current archive without decompression.
zip | The opened archive to get the file from. |
aNames | An array of filenames to acquire from the zip archive. |
bKeepSystComp | If false , then the system compatibility of the file from the zip archive is converted to the current archive system compatibility, if they differ. Otherwise the source system compatibility is copied. |
false
, if the operation could not be performed (either of archives is closed, a file inside either of archives is opened, zip archive is segmented or the current archive is an existing segmented archive.true
, to continue working with the archive.false
from the CZipActionCallback::Callback) in a not segmented archive and when no replacing is taking place. The file that is not entirely added is removed from the archive then.Definition at line 1392 of file ZipArchive.h.
CZipString CZipArchive::GetGlobalComment | ( | ) | const |
Returns the global comment for the archive.
|
inline |
Returns the currently ignored consistency checks. It can be one or more of the ConsistencyCheck values.
Definition at line 2942 of file ZipArchive.h.
void CZipArchive::GetIndexes | ( | const CZipStringArray & | aNames, |
CZipIndexesArray & | aIndexes | ||
) |
Returns indexes of the files with names stored in aNames and puts them into aIndexes. If a filename was not found, ZIP_FILE_INDEX_NOT_FOUND
is inserted at the appropriate position in aIndexes.
aNames | An array of filenames inside the archive. |
aIndexes | An array of indexes to be found. |
|
inline |
Returns the index of the recently added file (if any).
ZIP_FILE_INDEX_UNSPECIFIED
if the index is unknown. Definition at line 1110 of file ZipArchive.h.
|
inline |
Calculates the actual size (in bytes) currently occupied by the archive.
0
.Definition at line 2134 of file ZipArchive.h.
CZipString CZipArchive::GetPassword | ( | ) | const |
Returns the current archive password or an empty string if there is no password set.
|
inline |
Returns the value set previously with the SetRootPath() method.
Definition at line 810 of file ZipArchive.h.
|
inline |
Returns the currently set special flags. It can be one or more of the SpecialFlags values.
Definition at line 2969 of file ZipArchive.h.
|
inline |
Returns the underlying archive storage object.
Definition at line 2351 of file ZipArchive.h.
|
inline |
Returns the current settings that control storing of filenames and comments in the archive.
Definition at line 2469 of file ZipArchive.h.
|
inline |
Returns the system compatibility of the current archive.
Definition at line 2340 of file ZipArchive.h.
|
inline |
Returns the current temporary path used when compressing files.
Definition at line 2594 of file ZipArchive.h.
|
inline |
Returns the current Unicode mode.
Definition at line 2509 of file ZipArchive.h.
|
protected |
Initializes the archive during opening.
iArchiveSystCompatib | The system's compatibility of the archive. |
pSource | If not NULL , then it specifies the central directory for sharing. |
|
inline |
Tests if the whole archive or the current volume is closed.
bArchive | If true , test for the whole archive. If false , test for the current volume only. |
true
if a file closed; false
otherwise.Definition at line 2207 of file ZipArchive.h.
|
inline |
Returns the value indicating whether using of full file time resolution is set for the archive.
true
, if full file times resolution is set for the archive; false
otherwise.Definition at line 3203 of file ZipArchive.h.
|
inline |
Returns the value indicating whether there are any pending changes in the archive to be committed.
true
, if there are changes left to be committed; false
otherwise.Definition at line 3081 of file ZipArchive.h.
|
inline |
Returns the value indicating whether a password is set for the archive.
true
, if a password is set for the archive; false
otherwise. Definition at line 3187 of file ZipArchive.h.
|
inline |
Returns the value indicating whether the archive can be modified. An archive is read-only when it is an existing segmented archive or it was opened with the zipOpenReadOnly flag.
true
if the archive is read-only; false
otherwise. Definition at line 2836 of file ZipArchive.h.
|
inline |
Returns the value indicating whether using of UTC file times is currently set for the archive.
true
, if file times are stored in UTC in the archive; false
otherwise.Definition at line 3237 of file ZipArchive.h.
|
static |
Returns the value indicating whether the given file is a zip archive. To execute quickly, this method does not read a whole central directory, but also does not guarantee that the archive is not corrupted.
lpszPathName | The path of the file to examine. |
true
, if the archive is a zip archive; false
otherwise.
|
static |
Returns the value indicating whether the given file is a zip archive. To execute quickly, this method does not read a whole central directory, but also does not guarantee that the archive is not corrupted.
af | The archive file to examine. |
bAutoClose | If true , the af file will be closed by this method; false otherwise. |
true
, if the archive is a zip archive; false
otherwise. bool CZipArchive::Open | ( | LPCTSTR | szPathName, |
int | iMode = zipOpen , |
||
ZIP_SIZE_TYPE | uVolumeSize = 0 |
||
) |
Opens or creates a zip archive.
szPathName | The path to the archive. |
iMode | It can be one of the OpenMode values. |
uVolumeSize | The volume size in a split archive (relevant only for zipCreateSplit and zipCreateBinSplit modes). The size of the volume may be from 1 to 4,294,967,295. The bigger this value is - the faster is creation and extraction of segmented archives, because there are no volume changes. |
true
, if the archive was opened successfully; false
, if the archive was already opened before.bool CZipArchive::Open | ( | CZipAbstractFile & | af, |
int | iMode = zipOpen , |
||
bool | bAutoClose = false |
||
) |
Opens or creates an archive in memory. The CZipAbstractFile
object is not closed after closing the archive, so that it is possible to work with it afterwards.
af | CZipAbstractFile object to store the archive data. |
iMode | The open mode. The following values are valid: zipOpen, zipOpenReadOnly, zipCreate, zipCreateAppend. If you use zipCreate, the contents of the memory file are cleared. Use zipCreateAppend, if you want to append the archive at the end of the data contained in the memory file. |
bAutoClose | If true , the file will be closed when no longer used; false otherwise. Use false value (default) when operating on memory files. |
true
, if the archive was opened successfully; false
, if the archive was already opened before or an invalid open mode was specified.bool CZipArchive::OpenFile | ( | ZIP_INDEX_TYPE | uIndex | ) |
Opens the file with the given index in the archive for extracting. Not successful opening of the file doesn't lock the whole archive, so you can try to open another one (after catching an exception, if it was thrown)
uIndex | The index of the file to open. |
true
, if successful; false
otherwise. This method will also return false
, if the compression method of the file is not supported by the ZipArchive Library.CZipException | with the CZipException::badPassword code, if the file is encrypted and the password was not set. |
bool CZipArchive::OpenFrom | ( | CZipArchive & | zip, |
CZipAbstractFile * | pArchiveFile = NULL , |
||
bool | bAllowNonReadOnly = false |
||
) |
Opens the archive from the already opened archive. Both archives will share the same central directory. The zip archive must be opened in read-only mode (unless allowNonReadOnly is set to true
) and the newly opened archive will open as read-only as well.
zip | The archive that provides the reference to the central directory. It must be a read-only archive. If the archive has no physical representation, the storage file of that archive has to return false from the CZipAbstractFile::HasFilePath() method. Alternatively, pArchiveFile can be used. When pArchiveFile is used, the zip archive cannot be segmented. |
pArchiveFile | When used, the current CZipArchive instance will use this file as the storage. This file must be opened in advance and the library will not attempt to close it at any time. |
bAllowNonReadOnly | When set to true , the method will allow opening from a non-read only archive. However it is up to the user to ensure that the modifications to the zip archive won't corrupt the state of the CZipArchive object opened from it. Such a situation can happen when the zip archive is being modified and the current archive is reading at the same time. |
true
, if the new archive was successfully opened; false
otherwise._ZIP_USE_LOCKING
is defined in the _features.h file. Also make sure, that zip stays open until this method returns.
|
protected |
Opens the archive in the given mode. Called by Open(LPCTSTR, int, ZIP_SIZE_TYPE) and Open(CZipAbstractFile&, int, bool).
iMode | The mode. |
|
inline |
Adds a new file to the opened archive. The archive cannot be an existing (at the moment of opening the archive) segmented archive, because modifying such an archive is not possible with this version.
header | The structure that provides additional information about the added file and serves as a template for the properties of the new file. The following values can be set:
true , system compatibility for this object is set to the correct value. Additionally if lpszFilePath was not NULL , the attributes and the time fields are filled with information retrieved from the file pointed by lpszFilePath. |
iLevel | 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. The level value has no effect, if the compression method set with the SetCompressionMethod is CZipCompressor::methodStore. |
lpszFilePath | The path to the file to retrieve the date stamp and attributes from. These values are stored inside the archive. |
false
in the following cases: NULL
and the file attributes and data was not correctly retrieved. 0xFFFFFFFFFFFFFFFF
for an archive in the Zip64 format).true
otherwise.Definition at line 1173 of file ZipArchive.h.
|
protected |
See the description of OpenNewFile(CZipFileHeader&, int, LPCTSTR)
header | |
iLevel | |
lpszFilePath | |
uReplaceIndex | For the internal use only. |
|
inline |
Returns the information about the file with the given index. This method provides a direct access to the file data. Apart from the situations described in Requesting Information, Predicting Names and Sizes, you should avoid modifications of the returned object.
uIndex | A zero-based index of the file to get the information about. |
NULL
if the archive is closed or there is no such index in the archive.Definition at line 2045 of file ZipArchive.h.
|
inline |
Returns the information about the file with the given index. This method provides a direct access to the file data. This method does not allow modification of the returned object.
uIndex | A zero-based index of the file to get the information about. |
NULL
if the archive is closed or there is no such index in the archive.Definition at line 2073 of file ZipArchive.h.
bool CZipArchive::OverwriteLocalHeader | ( | ZIP_INDEX_TYPE | uIndex | ) |
Writes the local header information of the file with the given index back to the archive.
uIndex | The index of the file for which to write the local information. |
true
, if the information was successfully written; false
otherwise.CZipString CZipArchive::PredictExtractedFileName | ( | LPCTSTR | lpszFileNameInZip, |
LPCTSTR | lpszPath, | ||
bool | bFullPath, | ||
LPCTSTR | lpszNewName = NULL |
||
) | const |
Predicts the full resulting filename with path after extraction.
The parameters (except for the first) are in the form you would pass to the #ExtractFile(ZIP_INDEX_TYPE, CZipAbstractFile&, bool, CZipCompressor::COffsetsPair*, DWORD) method. The method takes into account the root path set with the SetRootPath method.
lpszFileNameInZip | The filename of the file inside the archive (may be NULL if lpszNewName is not NULL ). |
lpszPath | The same as in the ExtractFile method. |
bFullPath | The same as in the ExtractFile method. |
lpszNewName | The same as in the ExtractFile method. |
CZipString CZipArchive::PredictFileNameInZip | ( | LPCTSTR | lpszFilePath, |
bool | bFullPath, | ||
int | iWhat = prAuto |
||
) | const |
Predicts the filename as it would be stored in the archive, when given parameters would be used with
one of the AddNewFile() methods. The method takes into account the root path set with the SetRootPath method. You can use this method to eliminate duplicates before adding a list of files.
lpszFilePath | The file path, the same as CZipAddNewFileInfo::m_szFilePath. |
bFullPath | The same as CZipAddNewFileInfo::m_bFullPath. |
iWhat | One of the Predict values to interpret lpszFilePath correctly. |
ZIP_SIZE_TYPE CZipArchive::PredictMaximumFileSizeInArchive | ( | CZipFileHeader & | fh | ) |
Calculates the maximum number of bytes that the file represented by CZipFileHeader would occupy in the current archive.
You need to set the following members in the structure:
Additionally you may set:
fh | A template object pre-filled with data. |
ZIP_SIZE_TYPE CZipArchive::PredictMaximumFileSizeInArchive | ( | LPCTSTR | lpszFilePath, |
bool | bFullPath | ||
) |
Calls the PredictMaximumFileSizeInArchive(CZipFileHeader&) method. Before calling, fills the CZipFileHeader structure with the filename as it would appear in the archive and sets the proper file size (unless lpszFilePath is a directory).
lpszFilePath | The path to the file for which you want to predict the maximum size it would occupy. |
bFullPath | The same as CZipAddNewFileInfo::m_bFullPath. |
bool CZipArchive::PrependData | ( | LPCTSTR | lpszFilePath, |
LPCTSTR | lpszNewExt | ||
) |
Inserts data contained in the file pointed by the lpszFilePath path before the archive data. You can use this method for example to convert the archive into a self-extracting archive (store a self-extracting stub inside lpszFilePath file). To perform prepending, the archive must be opened and no file must be opened for compression or extraction. This method will not work with segmented archives or archives, for which GetBytesBeforeZip method returns value different from 0
.
lpszFilePath | The path of the file to prepend to the archive. |
lpszNewExt | If it is not NULL , then the extension of the archive is changed to this value after prepending data. Under Linux/Max OS X, this method sets executable permission for the owner after prepending. If renaming is performed, then the archive is closed before it. If this value is NULL , the no renaming is performed and the archive stays opened. |
true
, if data from lpszFilePath file was prepended (and optionally renamed) successfully; false
otherwise.bool CZipArchive::PrependData | ( | CZipAbstractFile & | file, |
LPCTSTR | lpszNewExt = NULL |
||
) |
Inserts data contained in the file before the archive data. You can use this method for example to convert the archive into a self-extracting archive (store a self-extracting stub inside file). To perform prepending, the archive must be opened and no file must be opened for compression or extraction. This method will not work with segmented archives or archives, for which GetBytesBeforeZip method returns value different from 0
.
file | The file containing data to insert before the archive data. The file should be opened. |
lpszNewExt | If it is not NULL , then the extension of the archive is changed to this value after prepending data. Under Linux/Max OS X, this method sets executable permission for the owner after prepending. If renaming is performed, then the archive is closed before it. If this value is NULL , the no renaming is performed and the archive stays opened |
true
, if data from file was prepended successfully; false
otherwise.DWORD CZipArchive::ReadFile | ( | void * | pBuf, |
DWORD | uSize | ||
) |
Reads data from the currently opened file and decompresses it to pBuf.
pBuf | The buffer to receive the decompressed data. |
uSize | The size of pBuf. |
bool CZipArchive::ReadLocalHeader | ( | ZIP_INDEX_TYPE | uIndex | ) |
Reads the local header information of the file with the given index.
uIndex | The index of the file for which to update the local information. |
true
, if the information was successfully updated; false
otherwise.
|
inlineprotected |
Reads the local header information of the file with the given index.
uIndex | The index of the file for which to update the local information. |
Definition at line 3321 of file ZipArchive.h.
bool CZipArchive::RemoveCentralDirectoryFromArchive | ( | ) |
Removes the central directory from the archive. You may then modify central extra fields and write the central directory back to the archive afterwards (use the Close method).
true
, if the central directory was successfully removed; false
otherwise.bool CZipArchive::RemoveFile | ( | ZIP_INDEX_TYPE | uIndex, |
bool | bRemoveData = true |
||
) |
Deletes the file with the given index from the archive. If you plan to delete more than one file, use the RemoveFiles(CZipIndexesArray&) or RemoveFiles(const CZipStringArray&) method. These methods are optimized for deleting multiple files.
uIndex | A zero-based index of the file to delete. |
bRemoveData | If true (default), removes the file data from the archive. If false , removes the file only from the central directory. |
false
, if the file could not be removed; true
otherwise.bool CZipArchive::RemoveFiles | ( | CZipIndexesArray & | aIndexes | ) |
Deletes files from the archive. Sorts aIndexes in the ascending order.
aIndexes | An array of zero-based indexes of the files to delete. |
false
, if files could not be removed; true
otherwise.bool CZipArchive::RemoveFiles | ( | const CZipStringArray & | aNames | ) |
Delete files from the archive.
aNames | An array of filenames to delete; |
false
, if files could not be removed; true
otherwise.
|
static |
Removes lpszBeginning from the beginning of szPath. Both argument are considered to be paths - they must match up to the path separator.
lpszBeginning | The beginning to remove. |
szPath | The path to have the beginning removed. |
pCompareFunction | The compare function used (see m_pZipCompare). |
true
, if the path beginning was removed; false
otherwise. bool CZipArchive::ResetCurrentVolume | ( | ) |
Resets the current volume while extracting a span archive when an invalid disk was inserted.
true
, if the method succeeded; false
, if the current state of the archive is invalid for this method to be called.
|
inline |
Sets the current settings that control storing of filenames and comments in the archive to their default values considering the current system compatibility of the archive (see GetSystemCompatibility()).
Definition at line 2445 of file ZipArchive.h.
void CZipArchive::SetAdvanced | ( | int | iWriteBuffer = 65536 , |
int | iGeneralBuffer = 65536 , |
||
int | iSearchBuffer = 32768 |
||
) |
Sets the internal buffer sizes. No buffer size can be set smaller than 1024. Use this method before opening the archive. The optimal size for the write buffer for a segmented archive is the size of the volume.
iWriteBuffer | The write buffer size. See also CZipStorage::m_iWriteBufferSize. |
iGeneralBuffer | A helper buffer used in moving data, deleting, getting (GetFromArchive) files, renaming and replacing. This buffer is not used for compression and decompression. For these purposes, use the CZipCompressor::COptions::m_iBufferSize option. |
iSearchBuffer | A buffer used in searching for the central directory. See also CZipStorage::m_iLocateBufferSize. |
bool CZipArchive::SetAutoFinalize | ( | bool | bAutoFinalize = true | ) |
Sets the CZipArchive object to call the Finalize() method after each operation that modifies the archive (apart from changing central extra fields). It is useful when you want to prevent the loss of data in case of the program crash - the zip file will then be finalized on the disk. Use it after opening the archive.
|
inline |
Sets the number of extra bytes that are present before the actual archive in the archive file. The library usually tries to automatically calculate this value, but this may not be possible under some conditions.
uCount | The number of bytes before the actual archive. |
Definition at line 2849 of file ZipArchive.h.
|
inline |
Registers the callback object to receive specified notifications.
pCallback | The callback object to receive notifications. Set it to NULL to stop receiving the selected notifications. |
iWhich | The callback type to register for (or unregister from). It can be one or more of the CZipActionCallback::CallbackType values. |
Definition at line 548 of file ZipArchive.h.
|
inline |
Sets the default archive case-sensitivity. The default CZipArchive case-sensitivity depends on the system and is set as follows:
false
true
Calling this method affects the following methods:
bCaseSensitive | The case-sensitivity to be used. |
Definition at line 2775 of file ZipArchive.h.
|
inline |
Sets the commit mode.
iCommitMode | The mode to set. It can be one of the CommitMode values. |
Definition at line 3027 of file ZipArchive.h.
bool CZipArchive::SetCompressionMethod | ( | WORD | uCompressionMethod = CZipCompressor::methodDeflate | ) |
Sets the compression method used when compressing file. If affects the files that are added to the archive after calling this method.
uCompressionMethod | The compression method to use. Valid values are CZipCompressor::methodStore, CZipCompressor::methodDeflate and CZipCompressor::methodBzip2. |
true
, if the compression method is supported by the ZipArchive Library and was successfully set; false
otherwise.
|
inline |
Sets the compression options for an appropriate compressor. The library automatically detects to which compressor the options apply by examining the return value from the CZipCompressor::COptions::GetType() method. If a file is currently opened for compression or decompression, the options will have no effect on the current file processing. A sample that illustrates setting options can be found at Compressing Data.
pOptions | The options to set. The NULL value has no effect. The object is no longer needed and can be safely released after this method returns. |
Definition at line 472 of file ZipArchive.h.
bool CZipArchive::SetEncryptionMethod | ( | int | iEncryptionMethod = CZipCryptograph::encStandard | ) |
Sets the encryption method when encrypting files. You can encrypt different files using different methods. You need to set the password with the SetPassword method for the encryption to work. It is necessary to set the encryption method only when compressing. When decompressing, the encryption method will be detected automatically.
iEncryptionMethod | One of the CZipCryptograph::EncryptionMethod values. |
false
if selected encryption method is not supported or a file is opened for compression; true
otherwise.
|
inline |
Enables using of full times resolution when creating files in the archive. Note, the information whether the times are stored in UTC or local times is not stored in the archive.
Definition at line 3216 of file ZipArchive.h.
bool CZipArchive::SetGlobalComment | ( | LPCTSTR | lpszComment, |
UINT | codePage = ZIP_DEFAULT_CODE_PAGE |
||
) |
Sets the global comment in the archive.
lpszComment | The comment to set. |
codePage | The code page to use. |
false
, if the archive is closed or it is an existing segmented archive or any file is opened in the archive for extraction or compression; true
otherwise.
|
inline |
Sets the consistency checks to ignore while processing the archive. Allows opening archives which are not entirely consistent, but nevertheless the compressed data is correct. Set it before or after opening an archive.
iLevel | The consistency check. It can be one or more of the ConsistencyCheck values. |
Definition at line 2931 of file ZipArchive.h.
bool CZipArchive::SetPassword | ( | LPCTSTR | lpszPassword = NULL , |
UINT | codePage = ZIP_DEFAULT_CODE_PAGE |
||
) |
Sets a password for the file to be opened or created. Use this method before opening or adding a file, but after opening the archive. For security reasons, the password is cleared during opening and closing of the archive. For the encryption to work, encryption method must be set to other value than CZipCryptograph::encNone.
lpszPassword | The password. Set it to NULL or an empty string to clear the password. |
codePage | The code page to use. |
false
if the password cannot be changed at this time; true
otherwise.void CZipArchive::SetRootPath | ( | LPCTSTR | szPath = NULL | ) |
Sets the path fragment to be removed from the beginning of the full path when adding or extracting a file.
Use it, if you don't want to use the full path (by setting the bFullPath parameter in AddNewFile or ExtractFile to true
) and you don't want to remove the whole path either (be setting the same parameter to false
), but you want to remove only a specific beginning. Use it after opening the archive and before calling the AddNewFile or ExtractFile methods.
szPath | The string that you want to be removed from the beginning of the path of the file in the archive. Set it to NULL to stop removing the path beginning. |
void CZipArchive::SetSegmCallback | ( | CZipSegmCallback * | pCallback = NULL , |
int | callbackType = scSpan |
||
) |
Sets the callback object used during operations on a segmented archive to change volumes in spanned and split archives. Set it before opening the archive. If you open a spanned archive and don't set the callback object, the exception CZipException::noCallback will be thrown. Setting the callback object is not required for a split archive.
Callback object's method CZipSegmCallback::Callback is called when the next volume is processed in a segmented archive. Calling CZipArchive methods from inside this method may result in an unexpected behavior.
pCallback | The address of the callback object. Set it to NULL to clear the callback. |
callbackType | The type of the callback to set. It can be one of the SegmCallbackType values. |
|
inline |
Sets special flags. It can be one or more of the SpecialFlags values. Call this method before opening an archive.
Definition at line 2953 of file ZipArchive.h.
|
inline |
Sets the current split names handler.
names | The handler to set. |
Definition at line 625 of file ZipArchive.h.
|
inline |
Sets the current split names handler.
pNames | The names to set. |
bAutoDelete | If true , the handler will be automatically deleted when it is no longer needed; false otherwise. |
Definition at line 649 of file ZipArchive.h.
|
inline |
Sets the current settings that control storing of filenames and comments in the archive.
settings | The settings to set. |
Definition at line 2371 of file ZipArchive.h.
|
inline |
Sets the current settings that control storing of filenames and comments in the archive.
uFileNameCodePage | The code page for filenames. |
bStoreNameInExtraData | If true , the encoded filenames are stored in central extra fields. |
uCommentCodePage | The code page for comments. |
Definition at line 2399 of file ZipArchive.h.
|
inline |
Sets the current settings that control storing of filenames and comments in the archive. The code page for comments stays the same when calling this method.
uFileNameCodePage | The code page for filenames. |
bStoreNameInExtraData | If true , the encoded filenames are stored in central extra fields. |
Definition at line 2425 of file ZipArchive.h.
bool CZipArchive::SetSystemCompatibility | ( | int | iSystemComp | ) |
Sets the system compatibility of the archive. Use it after opening the archive, but before adding a new file.
iSystemComp | The new system compatibility to use. It can be one of the ZipCompatibility::ZipPlatforms values. |
false
, if the value iSystemComp is not supported or it is not possible to set the value at this moment; true
otherwise.void CZipArchive::SetTempPath | ( | LPCTSTR | lpszPath = NULL , |
bool | bForce = true |
||
) |
Sets the temporary path used when compressing files and there is a need for a temporary archive. Temporary files are used when replacing or when compressing a segmented archive with the zipsmCheckForEff flag. If the path is not set or it does not exists or there is not enough free space in it, then the ZipArchive Library first tries the following folders in the given order for sufficient free space:
If all above fails, no temporary file is created and the compression is performed the usual way.
lpszPath | The path used for storing temporary files. Set it to NULL , to clear the temporary path and let the ZipArchive Library figure it out (see above). |
bForce | If lpszPath is not NULL and this parameter set to true the directory is created, if it doesn't exist. Otherwise the ZipArchive Library tries to figure out the location for temporary files by itself (see above). |
|
inline |
Sets the current Unicode mode.
iMode | The Unicode mode to set. It can be one or more of the UnicodeMode values. |
Definition at line 2498 of file ZipArchive.h.
|
inline |
Enables using of UTC file times when creating files in the archive.
Definition at line 3250 of file ZipArchive.h.
bool CZipArchive::ShiftData | ( | ZIP_SIZE_TYPE | uOffset | ) |
Shifts data inside the archive to make an empty space at the beginning of the archive. Into this empty space, you can copy for example a self-extracting stub. To perform shifting, the archive must be opened and no file must be opened for compression or extraction. This method will not work with segmented archives or archives, for which GetBytesBeforeZip method returns value different from 0
.
uOffset | The number of bytes to shift the archive data by. |
true
, if data was shifted successfully; false
otherwise.bool CZipArchive::TestFile | ( | ZIP_INDEX_TYPE | uIndex, |
DWORD | uBufSize = 65536 |
||
) |
Tests the file with the given index for the integrity. The method throws exceptions but performs all the necessary cleanup before, so that the next file can be tested after catching the exception.
uIndex | The index of the file to test. |
uBufSize | The size of the buffer used during extraction. |
false
, if the incorrect action has been taken (when OpenFile or GetFileInfo returned false
or uBufSize is 0); true
otherwise. If the file didn't passed the test or there was a disk I/O error or the supplied password was incorrect, an exception is thrown.CZipString CZipArchive::TrimRootPath | ( | CZipPathComponent & | zpc | ) | const |
Removes the root path from zpc.
zpc | The path to have the common beginning removed from. |
ZIP_INDEX_TYPE CZipArchive::WillBeDuplicated | ( | LPCTSTR | lpszFilePath, |
bool | bFullPath, | ||
bool | bFileNameOnly = false , |
||
int | iWhat = prAuto |
||
) |
Checks if the filename of the given file will be duplicated in the archive, if added to the archive with the given parameters.
lpszFilePath | The file path. You normally use it in one of the AddNewFile methods. |
bFullPath | The same as CZipAddNewFileInfo::m_bFullPath. |
bFileNameOnly | If true , the method assumes that the filename is duplicated if only the name part (no path) is the same (bFullPath is ignored), otherwise the whole filename with a path is taken into account. |
iWhat | One of the Predict values to interpret lpszFilePath correctly. |
ZIP_FILE_INDEX_NOT_FOUND
, if the filename would be unique.
|
inline |
Returns the value indicating whether the next file will be encrypted. To encrypt a file, a password must be set with the SetPassword method and an encryption method must be set to a value different from CZipCryptograph::encNone.
true
, if the next file added to the archive will be encrypted; false
otherwise. Definition at line 266 of file ZipArchive.h.
|
protected |
Writes the central directory notifying a callback object if available.
bool CZipArchive::WriteNewFile | ( | const void * | pBuf, |
DWORD | uSize | ||
) |
Compresses the contents of the buffer and writes it to a new file.
pBuf | The buffer containing the data to be compressed and written. |
uSize | The number of bytes to be written from pBuf. |
false
, if the new file hasn't been opened yet; true
otherwise.
|
protected |
The value set with SetAutoFinalize().
Definition at line 3422 of file ZipArchive.h.
|
protected |
The value set with SetCaseSensitivity.
Definition at line 3369 of file ZipArchive.h.
bool CZipArchive::m_bSafePaths |
If true
, the drive letter (or an initial path separator indicating rooted paths) is removed from the filename stored inside the archive when adding a new file to the archive or extracting an existing one. It affects AddNewFile, ExtractFile, PredictFileNameInZip, PredictExtractedFileName, WillBeDuplicated methods. Also directory traversal paths are removed from files names to prevent Zip Slip on extraction. The default value is true
.
Definition at line 3310 of file ZipArchive.h.
|
protected |
The value set with SetFullFileTimes
Definition at line 3374 of file ZipArchive.h.
|
protected |
The value set with SetUseUtcFileTimes
Definition at line 3380 of file ZipArchive.h.
|
protected |
Holds currently set callback objects.
Definition at line 3358 of file ZipArchive.h.
|
protected |
|
protected |
The value set with SetSystemCompatibility.
Definition at line 3463 of file ZipArchive.h.
|
protected |
The size of the m_pBuffer buffer. Set it before opening the archive. It is usually set with the SetAdvanced method (specify this value as the second argument).
Definition at line 3578 of file ZipArchive.h.
|
protected |
The value set with SetCommitMode().
Definition at line 3427 of file ZipArchive.h.
|
protected |
The value set with SetEncryptionMethod.
Definition at line 3552 of file ZipArchive.h.
|
protected |
Takes one of the CZipArchive::OpenFileType enum values.
Definition at line 3417 of file ZipArchive.h.
|
protected |
A helper buffer used during various IO operations.
Definition at line 3568 of file ZipArchive.h.
|
protected |
The current compressor.
Definition at line 3547 of file ZipArchive.h.
|
protected |
The current cryptograph.
Definition at line 3511 of file ZipArchive.h.
|
protected |
The value set with SetPassword.
Definition at line 3468 of file ZipArchive.h.
|
protected |
A pointer to a method used to compare strings. Can point to Compare
, CompareNoCase
, Collate
or CollateNoCase
method.
Definition at line 3387 of file ZipArchive.h.
|
protected |
|
protected |
The value set with the SetStringStoreSettings() method.
Definition at line 3584 of file ZipArchive.h.
|
protected |
The value set with SetRootPath().
Definition at line 3432 of file ZipArchive.h.
|
protected |
The value set with SetTempPath().
Definition at line 3437 of file ZipArchive.h.
|
protected |
The value set with SetCompressionMethod.
Definition at line 3557 of file ZipArchive.h.