Click here to Skip to main content
15,896,154 members
Articles / Desktop Programming / MFC

CleanZipAndGo

Rate me:
Please Sign up or sign in to vote.
4.29/5 (7 votes)
20 May 20031 min read 71K   870   21  
Utility to quickly archive any project to a Zip file.
// ZipException.h: interface for the CZipException class.
//
////////////////////////////////////////////////////////////////////////////////
//  Copyright (C) 2000 Tadeusz Dracz.
//  For conditions of distribution and use, see copyright notice in ZipArchive.h
////////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_ZIPEXCEPTION_H__E3546921_D728_11D3_B7C7_E77339672847__INCLUDED_)
#define AFX_ZIPEXCEPTION_H__E3546921_D728_11D3_B7C7_E77339672847__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef unsigned short uShort;
// errors number definitions
#define ZIP_BADZIPFILE		(-101)
#define ZIP_BADCRC			(-102)
#define ZIP_NOCALLBACK		(-103)
#define ZIP_ABORTED			(-104)
#define ZIP_NONREMOVABLE	(-105)
#define ZIP_TOOMANYVOLUMES	(-106)
#define ZIP_TOOLONGFILENAME (-107)

class CZipException : public CException  
{
public:
	DECLARE_DYNAMIC(CZipException)
	// convert zlib library and internal error code to a ZipException code
	static int ZipErrToCause(int iZipError);
	// name of the zip file where the error occured
	CString m_szFileName;

	enum
	{
		noError,		// no error
		generic,		// unknown error
		streamEnd,			// zlib library errors
		needDict,			//
		errNo,				//
		streamError,		//
		dataError,			//
		memError,			//	
		bufError,			//
		versionError,		// 
		badZipFile,		// damaged or not a zip file
		badCrc,			// crc mismatched
		noCallback,		// no callback function set
		aborted,		// disk change callback function returned false
		nonRemovable,	// the disk selected for pkSpan archive is non removable
		tooManyVolumes,	// limit of the maximum volumes reached (999)
		tooLongFileName	// the file name of the file added to the archive is too long
	};
	// cause - takes one of the codes above
	int m_iCause;
	CZipException(int iCause = generic, LPCTSTR lpszZipName = NULL);
	virtual ~CZipException();

};

// throw zip exception
// Parameters:
//		iZipError	- zlib or internal error code
//		lpszZipName - name of the file where the error occured
void AfxThrowZipException(int iZipError = 1000, LPCTSTR lpszZipName = NULL);

#endif // !defined(AFX_ZIPEXCEPTION_H__E3546921_D728_11D3_B7C7_E77339672847__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions