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

Enumerations

enum  FileOverwriteMode { fomRegular = 0x00 , fomRemoveReadOnly = 0x01 , fomOnlyIfNewer = 0x02 , fomRecycleBin = 0x04 }

Functions

ZIP_API DWORD GetDefaultAttributes ()
ZIP_API DWORD GetDefaultDirAttributes ()
ZIP_API ULONGLONG GetDeviceFreeSpace (LPCTSTR lpszPath)
ZIP_API bool GetSystemCaseSensitivity ()
ZIP_API int GetSystemID ()
ZIP_API CZipString GetTmpFileName (LPCTSTR lpszPath=NULL, ZIP_SIZE_TYPE uSizeNeeded=0)
Various operations on files and directories.

If the functions returns a bool value, then true indicates that the operation was successful.

ZIP_API bool GetCurrentDirectory (CZipString &sz)
 Returns the current directory and stores it in sz.
ZIP_API bool ChangeDirectory (LPCTSTR lpDirectory)
 Changes the current directory.
ZIP_API bool SetFileAttr (LPCTSTR lpFileName, DWORD uAttr)
 Sets the file attributes.
ZIP_API bool GetFileAttr (LPCTSTR lpFileName, DWORD &uAttr)
 Returns the file attributes.
ZIP_API bool GetFileTimes (LPCTSTR lpFileName, time_t *tModificationTime, time_t *tCreationTime=NULL, time_t *tLastAccessTime=NULL)
 Retrieves file times.
ZIP_API bool SetFileTimes (LPCTSTR lpFileName, const time_t *tModificationTime, const time_t *tCreationTime=NULL, const time_t *tLastAccessTime=NULL)
 Sets file times.
ZIP_API bool GetFileSize (LPCTSTR lpszFileName, ZIP_SIZE_TYPE &dSize)
 Returns the file size.
ZIP_API bool CreateNewDirectory (LPCTSTR lpDirectory)
 Creates a new directory.
ZIP_API bool SetVolLabel (LPCTSTR lpszPath, LPCTSTR lpszLabel)
 Sets a label on a removable device. lpszPath may point to a file on the device.
ZIP_API bool ForceDirectory (LPCTSTR lpDirectory)
 Creates nested directories at once.
ZIP_API bool RemoveFile (LPCTSTR lpszFileName, bool bThrow=true, int iMode=fomRegular)
 Removes a file.
ZIP_API bool RenameFile (LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow=true)
 Renames a file.
ZIP_API void ConvertTimeToFileTime (const time_t &ttime, ZFILETIME &fileTime)
ZIP_API bool ConvertFileTimeToTime (const ZFILETIME &fileTime, time_t &ttime)
ZIP_API time_t GetTimeZoneOffset ()
 Returns the time zone offset.
ZIP_API bool SetFileAttr (HANDLE handle, DWORD uAttr)
 Sets the file attributes.
ZIP_API bool SetFileTimes (HANDLE handle, const time_t *tModificationTime, const time_t *tCreationTime=NULL, const time_t *tLastAccessTime=NULL)
 Set file times.
ZIP_API bool TruncateFile (int iDes, ULONGLONG uSize)
ZIP_API int OpenFile (LPCTSTR lpszFileName, UINT iMode, int iShareMode)
ZIP_API bool FlushFile (int iDes)
ZIP_API intptr_t GetFileSystemHandle (int iDes)
ZIP_API bool IsDriveRemovable (LPCTSTR lpszFilePath)
ZIP_API bool IsDirectory (DWORD uAttr)
ZIP_API void AnsiOem (CZipAutoBuffer &buffer, bool bAnsiToOem)
ZIP_API int FileExists (LPCTSTR lpszName)
ZIP_API DWORD Crc32 (DWORD crc, const unsigned char *buf, DWORD len)
DWORD CrcByte (DWORD crc, unsigned char c)
ZIP_API bool IsHwCrcAvailable ()
ZIP_API int WideToMultiByte (LPCWSTR lpszIn, CZipAutoBuffer &szOut, UINT uCodePage)
ZIP_API int WideToMultiByte (LPCWSTR lpszIn, CZipAutoBuffer &szOut, bool bAddNull, UINT uCodePage)
ZIP_API int MultiByteToWide (const CZipAutoBuffer &szIn, CZipString &szOut, UINT uCodePage)
ZIP_API int MultiByteToWide (const char *szIn, int iInSize, CZipString &szOut, UINT uCodePage)

Detailed Description

Includes functions that require system-specific implementation.

Enumeration Type Documentation

◆ FileOverwriteMode

The mode for deleting files.

Enumerator
fomRegular 

No special action is taken when overwriting a file.

fomRemoveReadOnly 

The read-only attribute is cleared before overwriting a file.

fomOnlyIfNewer 

The file will be overwritten during extraction, only if the file being extracted is newer.

fomRecycleBin 

The overwritten file is moved to the Recycle Bin (Windows only).

Function Documentation

◆ AnsiOem()

ZIP_API void ZipPlatform::AnsiOem ( CZipAutoBuffer & buffer,
bool bAnsiToOem )

Performs the translation between ANSI and OEM character sets.

Parameters
bufferThe buffer containing characters to be translated.
bAnsiToOemIf true, convert ANSI to OEM; if false, OEM to ANSI.

◆ ChangeDirectory()

ZIP_API bool ZipPlatform::ChangeDirectory ( LPCTSTR lpDirectory)

Changes the current directory.

◆ ConvertFileTimeToTime()

ZIP_API bool ZipPlatform::ConvertFileTimeToTime ( const ZFILETIME & fileTime,
time_t & ttime )

Converts time from the FILETIME format to the time_t format.

Parameters
fileTimeThe file time in FILETIME format.
ttimeThe output time in time_t format.
Returns
true if conversion was successful; false otherwise.

◆ ConvertTimeToFileTime()

ZIP_API void ZipPlatform::ConvertTimeToFileTime ( const time_t & ttime,
ZFILETIME & fileTime )

Converts time from the time_t format to the FILETIME format.

Parameters
ttimeThe time in time_t format.
fileTimeThe output file time in FILETIME format.

◆ Crc32()

ZIP_API DWORD ZipPlatform::Crc32 ( DWORD crc,
const unsigned char * buf,
DWORD len )

Computes CRC-32 over a buffer using hardware acceleration when available. Uses Intel PCLMULQDQ on x86/x64 or ARM CRC32 instructions on aarch64. Falls back to software (zlib) CRC-32 when hardware is not available. Interface matches zarch_crc32: handles pre/post complement internally.

Parameters
crcRunning CRC value (0 for initial).
bufData buffer.
lenBuffer length in bytes.
Returns
Updated CRC-32 value.

◆ CrcByte()

DWORD ZipPlatform::CrcByte ( DWORD crc,
unsigned char c )

Computes a single-byte CRC-32 update (raw, no complement). Used by the traditional ZIP encryption key update.

Parameters
crcCurrent raw CRC value.
cByte to process.
Returns
Updated raw CRC value.

◆ CreateNewDirectory()

ZIP_API bool ZipPlatform::CreateNewDirectory ( LPCTSTR lpDirectory)

Creates a new directory.

◆ FileExists()

ZIP_API int ZipPlatform::FileExists ( LPCTSTR lpszName)

Checks if the given file or directory exists.

Parameters
lpszNameThe path to the file or directory to test.
Returns
One of the following values:
  • -1 : the given file exists and is a directory
  • 1 : the given file exists and is a regular file
  • 0 : there is no such a file

◆ FlushFile()

ZIP_API bool ZipPlatform::FlushFile ( int iDes)

Flushes the file to the disk.

Note
Defined only in the STL version.

◆ ForceDirectory()

ZIP_API bool ZipPlatform::ForceDirectory ( LPCTSTR lpDirectory)

Creates nested directories at once.

◆ GetCurrentDirectory()

ZIP_API bool ZipPlatform::GetCurrentDirectory ( CZipString & sz)

Returns the current directory and stores it in sz.

◆ GetDefaultAttributes()

ZIP_API DWORD ZipPlatform::GetDefaultAttributes ( )

Returns the default file attributes for the current system.

Returns
The default file attributes.

◆ GetDefaultDirAttributes()

ZIP_API DWORD ZipPlatform::GetDefaultDirAttributes ( )

Returns the default directory attributes for the current system.

Returns
The default directory attributes.

◆ GetDeviceFreeSpace()

ZIP_API ULONGLONG ZipPlatform::GetDeviceFreeSpace ( LPCTSTR lpszPath)

Returns the free space on the given device.

Parameters
lpszPathPoints to the device to test.
Returns
The free space in bytes.

◆ GetFileAttr()

ZIP_API bool ZipPlatform::GetFileAttr ( LPCTSTR lpFileName,
DWORD & uAttr )

Returns the file attributes.

◆ GetFileSize()

ZIP_API bool ZipPlatform::GetFileSize ( LPCTSTR lpszFileName,
ZIP_SIZE_TYPE & dSize )

Returns the file size.

◆ GetFileSystemHandle()

ZIP_API intptr_t ZipPlatform::GetFileSystemHandle ( int iDes)

Returns the underlying system handle.

Note
Defined only in the STL version.

◆ GetFileTimes()

ZIP_API bool ZipPlatform::GetFileTimes ( LPCTSTR lpFileName,
time_t * tModificationTime,
time_t * tCreationTime = NULL,
time_t * tLastAccessTime = NULL )

Retrieves file times.

◆ GetSystemCaseSensitivity()

ZIP_API bool ZipPlatform::GetSystemCaseSensitivity ( )

Returns the default case-sensitivity for the current file system.

Returns
true, if the system is case-sensitive; false otherwise.

◆ GetSystemID()

ZIP_API int ZipPlatform::GetSystemID ( )

Returns the current system identifier.

Returns
One of the ZipCompatibility::ZipPlatforms values.
See also
CZipArchive::SetSystemCompatibility

◆ GetTimeZoneOffset()

ZIP_API time_t ZipPlatform::GetTimeZoneOffset ( )

Returns the time zone offset.

◆ GetTmpFileName()

ZIP_API CZipString ZipPlatform::GetTmpFileName ( LPCTSTR lpszPath = NULL,
ZIP_SIZE_TYPE uSizeNeeded = 0 )

Returns the name of a temporary file ensuring there is enough free space in the destination directory.

Parameters
lpszPathThe path to the directory to initially create the file in.
uSizeNeededThe requested free space size in bytes. If set to 0, the space availability is not checked.

◆ IsDirectory()

ZIP_API bool ZipPlatform::IsDirectory ( DWORD uAttr)

Checks if the given attributes represent a directory.

Parameters
uAttrThe attributes to test.
Returns
true if the attributes represent a directory; false otherwise.

◆ IsDriveRemovable()

ZIP_API bool ZipPlatform::IsDriveRemovable ( LPCTSTR lpszFilePath)

Checks if the given drive is removable.

Parameters
lpszFilePathThe path to the drive. May point to a file path or a directory on the drive.
Returns
true. if the drive is removable; false otherwise.
Note
Implemented only on Windows system, on all others always returns true.

◆ IsHwCrcAvailable()

ZIP_API bool ZipPlatform::IsHwCrcAvailable ( )

Check if hardware CRC acceleration is available on this CPU and the feature is enabled in the library.

Returns
true if hardware CRC acceleration is available; false otherwise.

◆ MultiByteToWide() [1/2]

ZIP_API int ZipPlatform::MultiByteToWide ( const char * szIn,
int iInSize,
CZipString & szOut,
UINT uCodePage )

Converts a multi-byte character string to a wide character string.

Parameters
szInThe multi-byte character string to convert. Should contain the terminating NULL character or the size should be specified (not less than 0)
iInSizeThe size of the string to convert or less than to if the size should be determined (the szIn string needs to include the terminating NULL character).
szOutReceives the converted string.
uCodePageThe code page used in conversion.
Returns
The length of the string after the conversion (without the terminating NULL character) or -1 when the function did not succeed.
Note
Defined only in the UNICODE version.

◆ MultiByteToWide() [2/2]

ZIP_API int ZipPlatform::MultiByteToWide ( const CZipAutoBuffer & szIn,
CZipString & szOut,
UINT uCodePage )

Converts a multi-byte character string to a wide character string.

Parameters
szInThe multi-byte character string to convert. Should not contain the terminating NULL character.
szOutReceives the converted string.
uCodePageThe code page used in conversion.
Returns
The length of the string after the conversion (without the terminating NULL character) or -1 when the function did not succeed.
Note
Defined only in the UNICODE version.

◆ OpenFile()

ZIP_API int ZipPlatform::OpenFile ( LPCTSTR lpszFileName,
UINT iMode,
int iShareMode )

Opens the file.

Note
Defined only in the STL version.

◆ RemoveFile()

ZIP_API bool ZipPlatform::RemoveFile ( LPCTSTR lpszFileName,
bool bThrow = true,
int iMode = fomRegular )

Removes a file.

◆ RenameFile()

ZIP_API bool ZipPlatform::RenameFile ( LPCTSTR lpszOldName,
LPCTSTR lpszNewName,
bool bThrow = true )

Renames a file.

◆ SetFileAttr() [1/2]

ZIP_API bool ZipPlatform::SetFileAttr ( HANDLE handle,
DWORD uAttr )

Sets the file attributes.

◆ SetFileAttr() [2/2]

ZIP_API bool ZipPlatform::SetFileAttr ( LPCTSTR lpFileName,
DWORD uAttr )

Sets the file attributes.

◆ SetFileTimes() [1/2]

ZIP_API bool ZipPlatform::SetFileTimes ( HANDLE handle,
const time_t * tModificationTime,
const time_t * tCreationTime = NULL,
const time_t * tLastAccessTime = NULL )

Set file times.

◆ SetFileTimes() [2/2]

ZIP_API bool ZipPlatform::SetFileTimes ( LPCTSTR lpFileName,
const time_t * tModificationTime,
const time_t * tCreationTime = NULL,
const time_t * tLastAccessTime = NULL )

Sets file times.

◆ SetVolLabel()

ZIP_API bool ZipPlatform::SetVolLabel ( LPCTSTR lpszPath,
LPCTSTR lpszLabel )

Sets a label on a removable device. lpszPath may point to a file on the device.

◆ TruncateFile()

ZIP_API bool ZipPlatform::TruncateFile ( int iDes,
ULONGLONG uSize )

Truncates the file.

Note
Defined only in the STL version.

◆ WideToMultiByte() [1/2]

ZIP_API int ZipPlatform::WideToMultiByte ( LPCWSTR lpszIn,
CZipAutoBuffer & szOut,
bool bAddNull,
UINT uCodePage )

Converts a wide character string to a multi-byte character string.

Parameters
lpszInThe wide character string to convert.
szOutThe buffer to receive the converted string. It contains the terminating NULL character depending on the bAddNull parameter.
bAddNullIf true, adds the terminating NULL character to the end of the resulting string; false otherwise.
uCodePageThe code page used in conversion.
Returns
The szOut buffer length, or -1 when not succeeded.
Note
Defined only in the UNICODE version.

◆ WideToMultiByte() [2/2]

ZIP_API int ZipPlatform::WideToMultiByte ( LPCWSTR lpszIn,
CZipAutoBuffer & szOut,
UINT uCodePage )

Converts a wide character string to a multi-byte character string.

Parameters
lpszInThe wide character string to convert.
szOutThe buffer to receive the converted string. Does not contain the terminating NULL character.
uCodePageThe code page used in conversion.
Returns
The szOut buffer length, or -1 when not succeeded.
Note
Defined only in the UNICODE version.
Back To Top Up