CZipException Class Reference

A class representing exceptions specific to the ZipArchive library. More...

#include <ZipException.h>

List of all members.

Public Types

enum  ZipErrors {
  noError, generic = 100, badZipFile, badCrc,
  noCallback, aborted, abortedAction, abortedSafely,
  nonRemovable, tooManyVolumes, tooLongFileName, badPassword,
  dirWithSize, internal, notRemoved, notRenamed,
  platfNotSupp, cdirNotFound, streamEnd = 500, needDict,
  errNo, streamError, dataError, memError,
  bufError, versionError
}
 The codes of errors thrown by the ZipArchive library. More...

Public Member Functions

 CZipException (int iCause=generic, LPCTSTR lpszZipName=NULL)
 CZipException (CZipException &e)
CZipString GetErrorDescription ()
 Return the error description.
BOOL GetErrorMessage (LPTSTR lpszError, UINT nMaxError, UINT *=NULL)
 Return the description of the error based on system variables (this function is provided only for compatibility with MFC CException::GetErrorMessage).

Static Public Member Functions

static void Throw (int iZipError=CZipException::generic, LPCTSTR lpszZipName=NULL)
 Throw an exception.
static int ZlibErrToZip (int iZlibError)
 Convert a zlib library error code to a CZipException error code .

Public Attributes

CZipString m_szFileName
 The name of the zip file where the error occurred.
int m_iCause
 A cause of the error - takes one of the ZipErrors enumeration codes.

Protected Member Functions

CZipString GetInternalErrorDescription (int iCause, bool bNoLoop=false)
 Return the error description.
CZipString GetSystemErrorDescription ()
 Return the description of the error based on system variables.


Detailed Description

A class representing exceptions specific to the ZipArchive library.

Library exception class derived in the MFC version from CException and in non-MFC version from std::exception.

Definition at line 45 of file ZipException.h.


Member Enumeration Documentation

enum CZipException::ZipErrors
 

The codes of errors thrown by the ZipArchive library.

Enumerator:
noError  no error
generic  unknown error
badZipFile  damaged or not a zip file
badCrc  crc mismatched
noCallback  no disk-spanning callback object set
aborted  callback object's method Callback returned false while disk change in the disk-spanning archive
abortedAction  callback object's method Callback returned false in CZipArchive class members: AddNewFile, ExtractFile, TestFile, DeleteFile or DeleteFiles
abortedSafely  the same as above, you may be sure that the operation was successfully completed before or it didn't cause any damage in the archive (break when counting before deleting files; see CZipArchive::cbDeleteCnt)
nonRemovable  the disk selected for pkzipSpan archive is non removable
tooManyVolumes  limit of the maximum volumes reached (999)
tooLongFileName  the filename of the file added to the archive is too long
badPassword  incorrect password set for the file being decrypted
dirWithSize  during testing: found the directory with the size greater than 0
internal  internal error
notRemoved  error while removing a file (under Windows call GetLastError() to find out more)
notRenamed  error while renaming a file (under Windows call GetLastError() to find out more)
platfNotSupp  the platform that the zip file is being created for is not supported
cdirNotFound  the central directory was not found in the archive (it is thrown also when the last disk of multi-disk archive is not in the drive when opening the archive)
streamEnd  zlib library error
needDict  zlib library error
errNo  zlib library error
streamError  zlib library error
dataError  zlib library error
memError  zlib library error thrown by CZipMemFile as well
bufError  zlib library error
versionError  zlib library error

Definition at line 147 of file ZipException.h.


Constructor & Destructor Documentation

CZipException::CZipException int  iCause = generic,
LPCTSTR  lpszZipName = NULL
 

Parameters:
iCause error cause (takes one of the ZipErrors enumeration codes)
lpszZipName the name of the file where the error occurred (if applicable)


Member Function Documentation

CZipString CZipException::GetErrorDescription  ) 
 

Return the error description.

Note:
You need to have defined ZIP_ENABLE_ERROR_DESCRIPTION (in file ZipException.h); undefine this value if you don't want to store the messages in the library.

BOOL CZipException::GetErrorMessage LPTSTR  lpszError,
UINT  nMaxError,
UINT *  = NULL
 

Return the description of the error based on system variables (this function is provided only for compatibility with MFC CException::GetErrorMessage).

Parameters:
lpszError a pointer to a buffer that will receive the error message if NULL
nMaxError the maximum number of characters the buffer can hold, including the NULL terminator
Returns:
TRUE if the error string is not empty
Note:
  • The function will not copy more than nMaxError – 1 characters to the buffer, and it always adds a trailing null to end the string; if the buffer is too small, the error message will be truncated.
  • You need to have defined ZIP_ENABLE_ERROR_DESCRIPTION (in file ZipException.h); undefine this value if you don't want to store the messages in the library.

CZipString CZipException::GetInternalErrorDescription int  iCause,
bool  bNoLoop = false
[protected]
 

Return the error description.

Parameters:
iCause : error number
bNoLoop,: if true tells not to search for en error description, it the error is generic
Returns:

CZipString CZipException::GetSystemErrorDescription  )  [protected]
 

Return the description of the error based on system variables.

Returns:

static void CZipException::Throw int  iZipError = CZipException::generic,
LPCTSTR  lpszZipName = NULL
[inline, static]
 

Throw an exception.

Throw CZipException* in the MFC version of the library (the object must be deleted with Delete() method) and CZipException in other versions.

The arguments are the same as in CZipException().

Parameters:
iZipError 
lpszZipName 
See also:
CZipException()

Definition at line 78 of file ZipException.h.

Referenced by CZipCentralDir::CompareHeaders().

static int CZipException::ZlibErrToZip int  iZlibError  )  [static]
 

Convert a zlib library error code to a CZipException error code .

Parameters:
iZlibError zlib library error code
Returns:
CZipException error code


The documentation for this class was generated from the following file:
ZipArchive Copyright © 2000 - 2006 Tadeusz Dracz . Generated at Fri Apr 7 13:55:25 2006.