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

Enumerations

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

Functions

ZIP_API void AnsiOem (CZipAutoBuffer &buffer, bool bAnsiToOem)
 
ZIP_API int FileExists (LPCTSTR lpszName)
 
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)
 
ZIP_API bool IsDirectory (DWORD uAttr)
 
ZIP_API bool IsDriveRemovable (LPCTSTR lpszFilePath)
 
ZIP_API int MultiByteToWide (const CZipAutoBuffer &szIn, CZipString &szOut, UINT uCodePage)
 
ZIP_API int MultiByteToWide (const char *szIn, int iInSize, CZipString &szOut, UINT uCodePage)
 
ZIP_API int WideToMultiByte (LPCWSTR lpszIn, CZipAutoBuffer &szOut, UINT uCodePage)
 
ZIP_API int WideToMultiByte (LPCWSTR lpszIn, CZipAutoBuffer &szOut, bool bAddNull, UINT uCodePage)
 
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.
 
void ConvertTimeToFileTime (const time_t &ttime, ZFILETIME &fileTime)
 
bool ConvertFileTimeToTime (const ZFILETIME &fileTime, time_t &ttime)
 
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)
 

Detailed Description

Includes functions that require system-specific implementation.

Enumeration Type Documentation

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

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.
ZIP_API bool ZipPlatform::ChangeDirectory ( LPCTSTR  lpDirectory)

Changes the current directory.

ZIP_API bool ZipPlatform::CreateNewDirectory ( LPCTSTR  lpDirectory)

Creates a new directory.

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
ZIP_API bool ZipPlatform::FlushFile ( int  iDes)

Flushes the file to the disk.

Note
Defined only in the STL version.
ZIP_API bool ZipPlatform::ForceDirectory ( LPCTSTR  lpDirectory)

Creates nested directories at once.

ZIP_API bool ZipPlatform::GetCurrentDirectory ( CZipString &  sz)

Returns the current directory and stores it in sz.

ZIP_API DWORD ZipPlatform::GetDefaultAttributes ( )

Returns the default file attributes for the current system.

Returns
The default file attributes.
ZIP_API DWORD ZipPlatform::GetDefaultDirAttributes ( )

Returns the default directory attributes for the current system.

Returns
The default directory attributes.
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.
ZIP_API bool ZipPlatform::GetFileAttr ( LPCTSTR  lpFileName,
DWORD &  uAttr 
)

Returns the file attributes.

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

Returns the file size.

ZIP_API intptr_t ZipPlatform::GetFileSystemHandle ( int  iDes)

Returns the underlying system handle.

Note
Defined only in the STL version.
ZIP_API bool ZipPlatform::GetFileTimes ( LPCTSTR  lpFileName,
time_t *  tModificationTime,
time_t *  tCreationTime = NULL,
time_t *  tLastAccessTime = NULL 
)

Retrieves file times.

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.
ZIP_API int ZipPlatform::GetSystemID ( )

Returns the current system identifier.

Returns
One of the ZipCompatibility::ZipPlatforms values.
See Also
CZipArchive::SetSystemCompatibility
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.
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.
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.
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.
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.
ZIP_API int ZipPlatform::OpenFile ( LPCTSTR  lpszFileName,
UINT  iMode,
int  iShareMode 
)

Opens the file.

Note
Defined only in the STL version.
ZIP_API bool ZipPlatform::RemoveFile ( LPCTSTR  lpszFileName,
bool  bThrow = true,
int  iMode = fomRegular 
)

Removes a file.

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

Renames a file.

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

Sets the file attributes.

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

Sets the file attributes.

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

Sets file times.

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

Set file times.

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.

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

Truncates the file.

Note
Defined only in the STL version.
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.
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.
Back To Top Up