#include <ZipCompressor.h>
Classes | |
struct | COptions |
class | COptionsMap |
Public Types | |
enum | CompressionLevel { levelDefault = -1, levelStore = 0, levelFastest = 1, levelBest = 9 } |
enum | CompressionMethod { methodStore = 0, methodDeflate = 8, methodBzip2 = 12, methodWinZipAes = 99 } |
enum | CompressorType { typeDeflate = 1, typeBzip2 } |
Public Member Functions | |
virtual bool | CanProcess (WORD uMethod)=0 |
virtual void | Compress (const void *pBuffer, DWORD uSize)=0 |
virtual DWORD | Decompress (void *pBuffer, DWORD uSize)=0 |
virtual void | FinishCompression (bool bAfterException) |
virtual void | FinishDecompression (bool bAfterException) |
virtual const COptions * | GetOptions () const |
virtual void | InitCompression (int iLevel, CZipFileHeader *pFile, CZipCryptograph *pCryptograph) |
virtual void | InitDecompression (CZipFileHeader *pFile, CZipCryptograph *pCryptograph) |
void | UpdateOptions (const COptionsMap &optionsMap) |
Static Public Member Functions | |
static CZipCompressor * | CreateCompressor (WORD uMethod, CZipStorage *pStorage) |
static bool | IsCompressionSupported (WORD uCompressionMethod) |
Public Attributes | |
ZIP_SIZE_TYPE | m_uComprLeft |
The number of bytes left to compress. | |
DWORD | m_uCrc32 |
The CRC32 file checksum. | |
ZIP_SIZE_TYPE | m_uUncomprLeft |
The number of bytes left to decompress. | |
Protected Member Functions | |
virtual int | ConvertInternalError (int iErr) const |
CZipCompressor (CZipStorage *pStorage) | |
void | FlushWriteBuffer () |
void | InitBuffer () |
void | ReleaseBuffer () |
void | ThrowError (int iErr, bool bInternal=false) |
void | UpdateCrc (const void *pBuffer, DWORD uSize) |
void | UpdateFileCrc (const void *pBuffer, DWORD uSize) |
virtual void | UpdateOptions (const COptions *pOptions) |
Protected Attributes | |
CZipAutoBuffer | m_pBuffer |
A buffer that receives compressed data or provides data for decompression. | |
CZipCryptograph * | m_pCryptograph |
The current cryptograph. | |
CZipFileHeader * | m_pFile |
The file header being compressed or decompressed. | |
CZipStorage * | m_pStorage |
The current storage object. |
Definition at line 41 of file ZipCompressor.h.
The compression level.
levelDefault |
The default compression level (equals 6 for deflate). |
levelStore | No compression used. Data is stored. |
levelFastest | The fastest compression. The compression ratio is the lowest (apart from levelStore). |
levelBest | The highest compression ratio. It's usually the slowest one. |
Definition at line 78 of file ZipCompressor.h.
The compression method.
methodStore | A file is stored, not compressed. |
methodDeflate | The deflate compression method. |
methodBzip2 |
The bzip2 compression method.
|
methodWinZipAes |
This value means that WinZip AES encryption is used. The original compression method is stored in a WinZip extra field. It is only an informational value - you cannot set it as a compression method. The ZipArchive Library handles this value internally.
|
Definition at line 89 of file ZipCompressor.h.
The type of a compressor.
Definition at line 69 of file ZipCompressor.h.
CZipCompressor::CZipCompressor | ( | CZipStorage * | pStorage | ) | [inline, protected] |
Initializes a new instance of the CZipCompressor class.
pStorage | The current storage object. |
Definition at line 56 of file ZipCompressor.h.
virtual bool CZipCompressor::CanProcess | ( | WORD | uMethod | ) | [pure virtual] |
Returns the value indicating whether the current CZipCompressor object supports the given compression method.
uMethod | The compression method. It can be one of the CompressionMethod values. |
true
, if the compression method is supported; false
otherwise. Implemented in ZipArchiveLib::CDeflateCompressor.
virtual void CZipCompressor::Compress | ( | const void * | pBuffer, | |
DWORD | uSize | |||
) | [pure virtual] |
Compresses the given data.
pBuffer | The buffer that holds the data to compress. | |
uSize | The size of pBuffer. |
Implemented in ZipArchiveLib::CDeflateCompressor.
virtual int CZipCompressor::ConvertInternalError | ( | int | iErr | ) | const [inline, protected, virtual] |
Converts an internal error code of the compressor to the ZipArchive Library error code.
iErr | An internal error code. |
Reimplemented in ZipArchiveLib::CDeflateCompressor.
Definition at line 452 of file ZipCompressor.h.
static CZipCompressor* CZipCompressor::CreateCompressor | ( | WORD | uMethod, | |
CZipStorage * | pStorage | |||
) | [static] |
A factory method that creates an appropriate compressor for the given compression method.
uMethod | The compression method to create a compressor for. It can be one of the CompressionMethod values. | |
pStorage | The current storage object. |
virtual DWORD CZipCompressor::Decompress | ( | void * | pBuffer, | |
DWORD | uSize | |||
) | [pure virtual] |
Decompresses the given data.
pBuffer | The buffer that receives the decompressed data. | |
uSize | The size of pBuffer. |
0
.Implemented in ZipArchiveLib::CDeflateCompressor.
virtual void CZipCompressor::FinishCompression | ( | bool | bAfterException | ) | [inline, virtual] |
The method called at the end of the compression process.
bAfterException | Set to true , if an exception occurred before or to false otherwise. |
Reimplemented in ZipArchiveLib::CDeflateCompressor.
Definition at line 316 of file ZipCompressor.h.
virtual void CZipCompressor::FinishDecompression | ( | bool | bAfterException | ) | [inline, virtual] |
The method called at the end of the decompression process.
bAfterException | Set to true , if an exception occurred before or to false otherwise. |
Reimplemented in ZipArchiveLib::CDeflateCompressor.
Definition at line 329 of file ZipCompressor.h.
void CZipCompressor::FlushWriteBuffer | ( | ) | [inline, protected] |
Flushes data in the buffer into the storage, encrypting the data if needed.
Definition at line 416 of file ZipCompressor.h.
virtual const COptions* CZipCompressor::GetOptions | ( | ) | const [inline, virtual] |
Returns the current options of the compressor.
Reimplemented in ZipArchiveLib::CDeflateCompressor.
Definition at line 344 of file ZipCompressor.h.
void CZipCompressor::InitBuffer | ( | ) | [protected] |
virtual void CZipCompressor::InitCompression | ( | int | iLevel, | |
CZipFileHeader * | pFile, | |||
CZipCryptograph * | pCryptograph | |||
) | [inline, virtual] |
The method called when a new file is opened for compression.
iLevel | The compression level. | |
pFile | The file being compressed. | |
pCryptograph | The current CZipCryptograph. It can be NULL , if no encryption is used. |
Reimplemented in ZipArchiveLib::CDeflateCompressor.
Definition at line 234 of file ZipCompressor.h.
virtual void CZipCompressor::InitDecompression | ( | CZipFileHeader * | pFile, | |
CZipCryptograph * | pCryptograph | |||
) | [inline, virtual] |
The method called when a new file is opened for extraction.
pFile | The file being extracted. | |
pCryptograph | The current CZipCryptograph. It can be NULL , if no decryption is used. |
Reimplemented in ZipArchiveLib::CDeflateCompressor, and ZipArchiveLib::CBaseLibCompressor.
Definition at line 256 of file ZipCompressor.h.
static bool CZipCompressor::IsCompressionSupported | ( | WORD | uCompressionMethod | ) | [inline, static] |
Returns the value indicating whether the given compression method is supported by the ZipArchive Library.
uCompressionMethod | The compression method. It can be one of the CompressionMethod values. |
true
, if the compression method is supported, false
otherwise. Definition at line 194 of file ZipCompressor.h.
void CZipCompressor::ReleaseBuffer | ( | ) | [inline, protected] |
void CZipCompressor::ThrowError | ( | int | iErr, | |
bool | bInternal = false | |||
) | [inline, protected] |
Throws an exception with a given error code.
iErr | An error code. | |
bInternal | true , if iErr is an internal error code and needs a conversion to the ZipArchive Library error code; false otherwise. |
Definition at line 470 of file ZipCompressor.h.
void CZipCompressor::UpdateCrc | ( | const void * | pBuffer, | |
DWORD | uSize | |||
) | [protected] |
Updates CRC value while decompression.
pBuffer | A buffer with data for which the CRC value should be updated. | |
uSize | The size of the buffer. |
void CZipCompressor::UpdateFileCrc | ( | const void * | pBuffer, | |
DWORD | uSize | |||
) | [protected] |
Updates CRC value while compression.
pBuffer | A buffer with data for which the CRC value should be updated. | |
uSize | The size of the buffer. |
virtual void CZipCompressor::UpdateOptions | ( | const COptions * | pOptions | ) | [inline, protected, virtual] |
Updates the current options with the new options.
pOptions | The new options to apply. |
Reimplemented in ZipArchiveLib::CDeflateCompressor.
Definition at line 387 of file ZipCompressor.h.
void CZipCompressor::UpdateOptions | ( | const COptionsMap & | optionsMap | ) |
Updates the current options with the options stored in optionsMap, if the appropriate options are present in the map.
optionsMap | The map to get the new options from. |
CZipAutoBuffer CZipCompressor::m_pBuffer [protected] |
A buffer that receives compressed data or provides data for decompression.
Definition at line 45 of file ZipCompressor.h.
CZipCryptograph* CZipCompressor::m_pCryptograph [protected] |
CZipFileHeader* CZipCompressor::m_pFile [protected] |
CZipStorage* CZipCompressor::m_pStorage [protected] |
ZIP_SIZE_TYPE CZipCompressor::m_uComprLeft |
DWORD CZipCompressor::m_uCrc32 |
ZIP_SIZE_TYPE CZipCompressor::m_uUncomprLeft |