Zip File

Detailed Description

Based upon zlib, see http://www.zlib.net/ for more information.

Groups

 EXTRACT_INFO
 
 FILETIME
 
 ZIP_APPEND
 
 ZIP_EXTRACT
 
 ZIP_FILE_FLAG
 
 ZIP_FILE_FLAG_UNIX
 
 ZIP_FLAG
 
 ZipMethod
 

Classes

struct  ZipFileTime
 
struct  ZipFileGlobalInfo
 
struct  ZipFileInfo
 
struct  ZipWriteInfo
 
class  ZipFile
 

Macros

#define COMPRESS_DATA_32_BYTE_PADDING
 
#define LIBRARY_ZIPFILE
 

Typedefs

typedef Int32(* ExtractDirectoryCallback) (const Filename &fnSrc, const Filename &fnDest, void *pData, Int32 lInfo)
 
typedef struct _ZHandle ZHandle
 

Functions

Bool GetFileTime (const Filename &fn, UINT &nYear, UINT &nMonth, UINT &nDay, UINT &nHour, UINT &nMinute, UINT &nSec, Int32 lType, Bool bIsDir)
 
Bool SetFileTime (const Filename &fn, UINT nYear, UINT nMonth, UINT nDay, UINT nHour, UINT nMinute, UINT nSec, Int32 lType, Bool bIsDir)
 
Bool CompressDataRaw (const void *pSrcData, Int lSrcLen, void *pDestData, Int *plDestLen, Int32 lLevel)
 
Bool UncompressDataRaw (const void *pSrcData, Int lSrcLen, void *pDestData, Int *plDestLen, Int *plRead=nullptr)
 
Bool CompressData (const void *pSrcData, Int lSrcLen, void *&pDestData, Int &lDestLen, Int32 lLevel)
 
Bool UncompressData (const void *pSrcData, Int lSrcLen, void *&pDestData, Int &lDestLen, Int *plRead=nullptr)
 
ZHandleCompressDataInit (Int32 lLevel)
 
Bool CompressDataDoIt (ZHandle *handle, const void *pSrcData, Int lSrcLen, void *&pDestData, Int &lDestLen, Int32 lFlags)
 
void CompressDataFree (ZHandle *&handle)
 

Macro Definition Documentation

◆ COMPRESS_DATA_32_BYTE_PADDING

#define COMPRESS_DATA_32_BYTE_PADDING

For CompressData(), COMPRESS_DATA_32_BYTE_PADDING | lLevel to make lDestLen a multiple of 32.

◆ LIBRARY_ZIPFILE

#define LIBRARY_ZIPFILE

ZIP file library ID.

Typedef Documentation

◆ ExtractDirectoryCallback

typedef Int32(* ExtractDirectoryCallback) (const Filename &fnSrc, const Filename &fnDest, void *pData, Int32 lInfo)

Called during file extraction.

Parameters
[in]fnSrcThe source filename within the ZIP file.
[in]fnDestThe filename of the destination file (the extracted file).
[in]pDataThe private data passed to ZipFile::ExtractToDirectory().
[in]lInfoThe extraction info: EXTRACT_INFO
Returns
The result: EXTRACT_INFO

◆ ZHandle

typedef struct _ZHandle ZHandle

Function Documentation

◆ GetFileTime()

Bool GetFileTime ( const Filename fn,
UINT nYear,
UINT nMonth,
UINT nDay,
UINT nHour,
UINT nMinute,
UINT nSec,
Int32  lType,
Bool  bIsDir 
)

Retrieves the time of a file.

Parameters
[in]fnThe file to get the time for.
[out]nYearAssigned the year.
[out]nMonthAssigned the month.
[out]nDayAssigned the day.
[out]nHourAssigned the hour.
[out]nMinuteAssigned the minute.
[out]nSecAssigned the second.
[in]lTypeThe type of file time to get: FILETIME
[in]bIsDirtrue for a directory.
Returns
true if successful, otherwise false.

◆ SetFileTime()

Bool SetFileTime ( const Filename fn,
UINT  nYear,
UINT  nMonth,
UINT  nDay,
UINT  nHour,
UINT  nMinute,
UINT  nSec,
Int32  lType,
Bool  bIsDir 
)

Sets the time of a file.

Parameters
[in]fnThe file to set the time for.
[in]nYearThe year.
[in]nMonthThe month.
[in]nDayThe day.
[in]nHourThe hour.
[in]nMinuteThe minute.
[in]nSecThe second.
[in]lTypeThe type of file time to set: FILETIME
[in]bIsDirtrue for a directory.
Returns
true if successful, otherwise false.

◆ CompressDataRaw()

Bool CompressDataRaw ( const void *  pSrcData,
Int  lSrcLen,
void *  pDestData,
Int plDestLen,
Int32  lLevel 
)

Compresses data into a caller supplied buffer.

Parameters
[in]pSrcDataThe source data.
[in]lSrcLenThe source data length.
[in,out]pDestDataFilled with the compressed data.
[in,out]plDestLenThe compressed data length. The destination buffer needs to be at least 0.1% bigger than the data to compress plus 12 bytes for the header.
Updated with the actual length used.
[in]lLevelThe compression level, ranges from 0 (min) to 9 (max).
Returns
true if successful, otherwise false.

◆ UncompressDataRaw()

Bool UncompressDataRaw ( const void *  pSrcData,
Int  lSrcLen,
void *  pDestData,
Int plDestLen,
Int plRead = nullptr 
)

Uncompresses data into a caller supplied buffer.

Parameters
[in]pSrcDataThe source data.
[in]lSrcLenThe source data length. May not be greater than 2 GB.
[in,out]pDestDataFilled with the uncompressed data. The buffer needs to be big enough to fit the uncompressed data.
[in,out]plDestLenThe uncompressed data length. Updated with the actual length used.
[out]plReadAssigned the amount of data read.
Returns
true if successful, otherwise false.

◆ CompressData()

Bool CompressData ( const void *  pSrcData,
Int  lSrcLen,
void *&  pDestData,
Int lDestLen,
Int32  lLevel 
)

Compresses data and give the caller a pointer in pDestData to memory that must be freed with DeleteMem().

Parameters
[in]pSrcDataThe source data.
[in]lSrcLenThe source data length. May not be greater than 2 GB.
[out]pDestDataAssigned a pointer to the destination compressed data. Needs to be freed with DeleteMem().
[out]lDestLenAssigned the destination length. Pass COMPRESS_DATA_32_BYTE_PADDING | lLevel to make lDestLen a multiple of 32.
[in]lLevelThe compression level, ranges from 0 (min) to 9 (max).
Returns
true if successful, otherwise false.

◆ UncompressData()

Bool UncompressData ( const void *  pSrcData,
Int  lSrcLen,
void *&  pDestData,
Int lDestLen,
Int plRead = nullptr 
)

Uncompresses data and give the caller a pointer in pDestData to memory that must be freed with DeleteMem().

Parameters
[in]pSrcDataThe source data.
[in]lSrcLenThe source data length. May not be greater than 2 GB.
[out]pDestDataAssigned the destination data pointer. Needs to be freed with DeleteMem().
[out]lDestLenAssigned the destination length.
[out]plReadAssigned the amount of data read.
Returns
true if successful, otherwise false.

◆ CompressDataInit()

ZHandle* CompressDataInit ( Int32  lLevel)

Initializes data compression.

See also
CompressDataDoIt()
Parameters
[in]lLevelThe compression level, ranges from 0 (min) to 9 (max).
Returns
The handle for data compression.

◆ CompressDataDoIt()

Bool CompressDataDoIt ( ZHandle handle,
const void *  pSrcData,
Int  lSrcLen,
void *&  pDestData,
Int lDestLen,
Int32  lFlags 
)

Compresses data.
Example:

static ZHandle *zhandle = nullptr;
zhandle = CompressDataInit(5);
res = zhandle && CompressDataDoIt(zhandle, c, l, l_zippedmem, l_ziplen, 0);
DeleteMem(l_zippedmem);
Py_UNICODE c
Definition: unicodeobject.h:1200
Py_UCS4 * res
Definition: unicodeobject.h:1113
Bool CompressDataDoIt(ZHandle *handle, const void *pSrcData, Int lSrcLen, void *&pDestData, Int &lDestLen, Int32 lFlags)
ZHandle * CompressDataInit(Int32 lLevel)
struct _ZHandle ZHandle
Definition: lib_zipfile.h:557
void CompressDataFree(ZHandle *&handle)
void DeleteMem(T *&p)
Definition: defaultallocator.h:257
PyObject PyObject int PyObject PyObject * l
Definition: pythonrun.h:156
Parameters
[in]handleThe handle for data compression.
[in]pSrcDataThe address to the source data.
[in]lSrcLenThe size of the source data block.
[out]pDestDataAssigned the address of the compressed data. Must be freed with DeleteMem().
[out]lDestLenAssigned the size of the compressed data block.
[in]lFlagsUsually 0 but can be set to COMPRESS_DATA_32_BYTE_PADDING.
Returns
true if successful, otherwise false.

◆ CompressDataFree()

void CompressDataFree ( ZHandle *&  handle)

Frees the handle of the compressed data. See also CompressDataDoIt().

Parameters
[in,out]handleThe handle for data compression to be freed.