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

#include <ZstdCompressor.h>

Inheritance diagram for ZipArchiveLib::CZstdCompressor:
Inheritance graph

Classes

struct  COptions

Public Member Functions

bool CanProcess (WORD uMethod)
void Compress (const void *pBuffer, DWORD uSize)
int CompressionLevelToNative (CompressionLevel iLevel)
 CZstdCompressor (CZipStorage *pStorage)
DWORD Decompress (void *pBuffer, DWORD uSize)
void FinishCompression (bool bAfterException)
void FinishDecompression (bool bAfterException)
const CZipCompressor::COptionsGetOptions () const
void InitCompression (int iLevel, CZipFileHeader *pFile, CZipCryptograph *pCryptograph)
void InitDecompression (CZipFileHeader *pFile, CZipCryptograph *pCryptograph)
Public Member Functions inherited from ZipArchiveLib::CBaseLibCompressor
 CBaseLibCompressor (CZipStorage *pStorage)
Public Member Functions inherited from CZipCompressor
virtual void FinishCompression (bool ZIP_UNUSED bAfterException)
virtual void FinishDecompression (bool ZIP_UNUSED bAfterException)
virtual void InitCompression (int ZIP_UNUSED iLevel, CZipFileHeader *pFile, CZipCryptograph *pCryptograph)
bool PrepareForSeek (CZipFileHeader *pCurrentFile, COffsetsPair *pPair)
void UpdateOptions (const COptionsMap &optionsMap)

Protected Member Functions

int ConvertInternalError (int iErr) const
bool IsCodeErrorOK (int iErr) const
void UpdateOptions (const CZipCompressor::COptions *pOptions)
Protected Member Functions inherited from ZipArchiveLib::CBaseLibCompressor
void CheckForError (int iErr)
void EmptyPtrList ()
void SetOpaque (void **opaque, const COptions *pOptions)
Protected Member Functions inherited from CZipCompressor
 CZipCompressor (CZipStorage *pStorage)
DWORD FillBuffer ()
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 *ZIP_UNUSED pOptions)
void WriteBuffer (char *pBuffer, DWORD uSize)

Static Protected Member Functions

static void * _zstdalloc (void *opaque, size_t size)
Static Protected Member Functions inherited from ZipArchiveLib::CBaseLibCompressor
static void * _zipalloc (void *opaque, UINT items, UINT size)
static void _zipfree (void *opaque, void *address)

Additional Inherited Members

Public Types inherited from CZipCompressor
enum  CompressionLevel { levelDefault = 0x7FFFFFFE , levelStore = 0 , levelFastest = 1 , levelBest = 0x7FFFFFFF }
enum  CompressionMethod {
  methodStore = 0 , methodDeflate = 8 , methodBzip2 = 12 , methodZstd = 93 ,
  methodWinZipAes = 99
}
enum  CompressorType { typeDeflate = 1 , typeBzip2 , typePPMd , typeZstd }
typedef CZipArray< COffsetsPair * > CZipOffsetsPairsArray
Static Public Member Functions inherited from CZipCompressor
static CZipCompressorCreateCompressor (WORD uMethod, CZipStorage *pStorage)
static bool IsCompressionSupported (WORD uCompressionMethod)
Public Attributes inherited from CZipCompressor
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 Attributes inherited from ZipArchiveLib::CBaseLibCompressor
bool m_bDecompressionDone
Protected Attributes inherited from CZipCompressor
CZipAutoBuffer m_pBuffer
 A buffer that receives compressed data or provides data for decompression.
CZipCryptographm_pCryptograph
 The current cryptograph.
CZipFileHeaderm_pFile
 The file header being compressed or decompressed.
CZipStoragem_pStorage
 The current storage object.

Detailed Description

A compressor that uses the Zstandard (zstd) algorithm.

See also
Compressing Data
CZipArchive::SetCompressionOptions
CZstdCompressor::COptions

Constructor & Destructor Documentation

◆ CZstdCompressor()

ZipArchiveLib::CZstdCompressor::CZstdCompressor ( CZipStorage * pStorage)

Initializes a new instance of the CZstdCompressor class.

Parameters
pStorageThe current storage object.

Member Function Documentation

◆ _zstdalloc()

void * ZipArchiveLib::CZstdCompressor::_zstdalloc ( void * opaque,
size_t size )
inlinestaticprotected

Custom memory allocation function for zstd.

Parameters
opaqueOpaque pointer passed to the allocation function.
sizeThe size of memory to allocate.
Returns
Pointer to the allocated memory.

◆ CanProcess()

bool ZipArchiveLib::CZstdCompressor::CanProcess ( WORD uMethod)
inlinevirtual

Returns the value indicating whether the current CZipCompressor object supports the given compression method.

Parameters
uMethodThe compression method. It can be one of the CompressionMethod values.
Returns
true, if the compression method is supported; false otherwise.

Implements CZipCompressor.

◆ Compress()

void ZipArchiveLib::CZstdCompressor::Compress ( const void * pBuffer,
DWORD uSize )
virtual

Compresses the given data.

Parameters
pBufferThe buffer that holds the data to compress.
uSizeThe size of pBuffer.
See also
InitCompression
FinishCompression

Implements CZipCompressor.

◆ CompressionLevelToNative()

int ZipArchiveLib::CZstdCompressor::CompressionLevelToNative ( CompressionLevel iLevel)
virtual

Converts a generic compression level to the compressor's native level.

Parameters
iLevelThe generic compression level.
Returns
The native compression level for this compressor.

Implements CZipCompressor.

◆ ConvertInternalError()

int ZipArchiveLib::CZstdCompressor::ConvertInternalError ( int iErr) const
inlineprotectedvirtual

Converts a Zstandard internal error code to a ZipArchive Library error code.

Parameters
iErrA Zstandard function return value cast to int. When an error occurs, Zstandard returns (size_t)-error_enum_value, which becomes negative when cast to int.
Returns
A ZipArchive Library error code in the range [CZipException::zstdErrorMin, CZipException::zstdErrorMax] that preserves the original error information.
Note
Zstandard encodes errors as ((size_t)-error_enum_value), e.g., ZSTD_error_GENERIC (1) becomes (size_t)-1. When cast to int, this becomes -1. Subtracting this negative value from zstdErrorMin (which is equivalent to adding its absolute value) stores the error enum value offset from zstdErrorMin.

Reimplemented from CZipCompressor.

◆ Decompress()

DWORD ZipArchiveLib::CZstdCompressor::Decompress ( void * pBuffer,
DWORD uSize )
virtual

Decompresses the given data.

Parameters
pBufferThe buffer that receives the decompressed data.
uSizeThe size of pBuffer.
Returns
The number of bytes decompressed and written to pBuffer.
Note
This method should be called repeatedly until it returns 0.
See also
InitDecompression
FinishDecompression

Implements CZipCompressor.

◆ FinishCompression()

void ZipArchiveLib::CZstdCompressor::FinishCompression ( bool bAfterException)

The method called at the end of the compression process.

Parameters
bAfterExceptionSet to true, if an exception occurred before or to false otherwise.

◆ FinishDecompression()

void ZipArchiveLib::CZstdCompressor::FinishDecompression ( bool bAfterException)

The method called at the end of the decompression process.

Parameters
bAfterExceptionSet to true, if an exception occurred before or to false otherwise.

◆ GetOptions()

const CZipCompressor::COptions * ZipArchiveLib::CZstdCompressor::GetOptions ( ) const
inlinevirtual

Returns the current options of the compressor.

Returns
The current options for the compressor.
See also
Compressing Data
CZipArchive::SetCompressionOptions
UpdateOptions

Reimplemented from CZipCompressor.

◆ InitCompression()

void ZipArchiveLib::CZstdCompressor::InitCompression ( int iLevel,
CZipFileHeader * pFile,
CZipCryptograph * pCryptograph )

The method called when a new file is opened for compression.

Parameters
iLevelThe compression level. Use numeric values here, not CZipCompressor::CompressionLevel values.
pFileThe file being compressed.
pCryptographThe current CZipCryptograph. It can be NULL, if no encryption is used.

◆ InitDecompression()

void ZipArchiveLib::CZstdCompressor::InitDecompression ( CZipFileHeader * pFile,
CZipCryptograph * pCryptograph )
virtual

The method called when a new file is opened for extraction.

Parameters
pFileThe file being extracted.
pCryptographThe current CZipCryptograph. It can be NULL, if no decryption is used.
See also
Decompress
FinishDecompression

Reimplemented from ZipArchiveLib::CBaseLibCompressor.

◆ IsCodeErrorOK()

bool ZipArchiveLib::CZstdCompressor::IsCodeErrorOK ( int iErr) const
inlineprotectedvirtual

Checks whether iErr value is an error code.

Parameters
iErrThe code to check.
Returns
true, if iErr is an error code; false otherwise.

Implements ZipArchiveLib::CBaseLibCompressor.

◆ UpdateOptions()

void ZipArchiveLib::CZstdCompressor::UpdateOptions ( const CZipCompressor::COptions * pOptions)
inlineprotected

Updates the current options with the new options.

Parameters
pOptionsThe new options to apply.
See also
CZstdCompressor::COptions

The documentation for this class was generated from the following file:
Back To Top Up