File: ZipStorage.h

package info (click to toggle)
mozilla-firefox 1.0.4-2sarge17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 255,356 kB
  • ctags: 267,207
  • sloc: cpp: 1,623,961; ansic: 792,828; xml: 85,380; makefile: 41,934; perl: 27,802; asm: 14,884; sh: 14,807; cs: 4,507; python: 4,398; java: 4,004; yacc: 1,380; lex: 409; pascal: 354; php: 244; csh: 132; objc: 73; ada: 44; sql: 4
file content (134 lines) | stat: -rw-r--r-- 4,250 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// ZipStorage.h: interface for the CZipStorage class.
//
////////////////////////////////////////////////////////////////////////////////
//  Copyright (C) 2000 Tadeusz Dracz.
//  For conditions of distribution and use, see copyright notice in ZipArchive.h
////////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_)
#define AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_

#include "ZipBigFile.h"	// Added by ClassView
#include "ZipAutoBuffer.h"	// Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// callback function called when there is a need for a disk change
// calling CZipArchive functions, apart from the static ones, may have unexpected results
// iNumber  - disk number needed
// iCode :
//		-1 - disk needed for reading
// other codes occurs during writting
//		>=0 : number of bytes needed
// 		-2 - the file with the archive name already exists on the disk
//		-3 - the disk is probably write - protected
//		-4 - couldn't create a file
//	pData - user defined data
//	return false to abort operation: the proper exception will be thrown
typedef bool (*ZIPCALLBACKFUN )(int iNumber, int iCode, void* pData);

class CZipStorage  
{
public:
	void Open(CMemFile& mf, int iMode);
// return the position in the file, taking into account the bytes in the write buffer
	DWORD GetPosition();

// flush the data from the read buffer to the disk
	void Flush();

// only called by CZipCentralDir when opening an existing archive
	void UpdateSpanMode(WORD uLastDisk);
// the preset size of the write buffer
	int m_iWriteBufferSize;

// user data to be passed to the callback function
	void* m_pCallbackData;

// function used to change disks during writing to the disk spanning archive
	void NextDisk(int iNeeded, LPCTSTR lpszFileName = NULL);

	void Close(bool bAfterException);

// return the numer of the current disk
	int GetCurrentDisk();

	void SetCurrentDisk(int iNumber);

// change the disk during extract operations
	void ChangeDisk(int iNumber);

// Function name	: IsSpanMode
// Description	    : detect span mode
// Return type		: int 
//		-1 - existing span opened
//		 0 - no span
//		 1 - new span
	int IsSpanMode();

	void Open(LPCTSTR szPathName, int iMode, int iVolumeSize);
	void Write(void *pBuf, DWORD iSize, bool bAtOnce);
	DWORD Read(void* pBuf, DWORD iSize, bool bAtOnce);
	CZipBigFile m_internalfile;
	CFile* m_pFile;
	CZipStorage();
	virtual ~CZipStorage();
	enum {noSpan, pkzipSpan, tdSpan, suggestedAuto, suggestedTd};
	int m_iSpanMode;
	ZIPCALLBACKFUN m_pZIPCALLBACKFUN;
	static char m_gszExtHeaderSignat[];

// open tdspan: last disk number, create tdspan: volume size
// create pkspan: not used
	int m_iTdSpanData;

protected:
// how many bytes left free in the write buffer
	DWORD GetFreeInBuffer();
	friend class CZipCentralDir;
// numer of bytes available in the write buffer
	DWORD m_uBytesInWriteBuffer;

//  tdSpan : the total size of the current volume, pkSpan : free space on the current volume
	DWORD m_uCurrentVolSize;

// return the number of bytes left on the current volume
	DWORD VolumeLeft();

// write data to the internal buffer
	void WriteInternalBuffer(char *pBuf, DWORD uSize);

// number of bytes left free in the write buffer
	DWORD m_uVolumeFreeInBuffer;

	CZipAutoBuffer m_pWriteBuffer;

// return the number of free bytes on the current removable disk
	DWORD GetFreeVolumeSpace();

	void CallCallback(int iCode, CString szTemp);

// only disk spanning creation: tells how many bytes have been written physically to the current volume
	DWORD m_iBytesWritten;

// construct the name of the volume in tdSpan mode
	CString GetTdVolumeName(bool bLast, LPCTSTR lpszZipName = NULL);

// change the disk in tdSpan mode
	CString ChangeTdRead();

// change the disk in pkSpan mode
	CString ChangePkzipRead();

//  you can only add a new files to the new disk spanning archive and only extract 
//	them from the existing one
	bool m_bNewSpan;

	int m_iCurrentDisk;
	bool OpenFile(LPCTSTR lpszName, UINT uFlags, bool bThrow = true);
	void ThrowError(int err);
	
};

#endif // !defined(AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_)