File: ZipFileHeader.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 (106 lines) | stat: -rw-r--r-- 3,838 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
// ZipFileHeader.h: interface for the CZipFileHeader class.
//
////////////////////////////////////////////////////////////////////////////////
//  Copyright (C) 2000 Tadeusz Dracz.
//  For conditions of distribution and use, see copyright notice in ZipArchive.h
////////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_ZipFileHeader_H__0081FC65_C9C9_4D48_AF72_DBF37DF5E0CF__INCLUDED_)
#define AFX_ZipFileHeader_H__0081FC65_C9C9_4D48_AF72_DBF37DF5E0CF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ZipException.h"
#include "ZipStorage.h"
#include "ZipAutoBuffer.h"

class CZipFileHeader  
{
public:	
// convert characters in the filename from oem to ansi or vice-versa	
	void AnsiOem(bool bAnsiToOem);
// change slash to backslash or vice-versa	
	void SlashChange(bool bWindowsStyle);
// return the filename size in characters (without NULL);	
	WORD GetFileNameSize(){return (WORD)m_pszFileName.GetSize();}
// return the comment size in characters (without NULL);		
	WORD GetCommentSize(){return (WORD)m_pszComment.GetSize();}
// return the extra field size in characters (without NULL);		
	WORD GetExtraFieldSize(){return (WORD)m_pExtraField.GetSize();}

	CString GetFileName();
// return true if confersion from unicode to single byte was successful	
	bool SetFileName(LPCTSTR lpszFileName);
	CString GetComment();
// return true if confersion from unicode to single byte was successful	
	bool SetComment(LPCTSTR lpszComment);
// return true if the data descriptor is present	
	bool IsDataDescr();
//	return true if the file is encrypted
	bool IsEncrypted();
//         central file header signature   4 bytes  (0x02014b50)
	char m_szSignature[4];
//         version made by                 2 bytes
	WORD m_uVersionMadeBy;
//         version needed to extract       2 bytes
	WORD m_uVersionNeeded;
//         general purpose bit flag        2 bytes
	WORD m_uFlag;
//         compression method              2 bytes
	WORD m_uMethod;
//         last mod file time              2 bytes
	WORD m_uModTime;
//         last mod file date              2 bytes
	WORD m_uModDate;
//         crc-32                          4 bytes
	DWORD m_uCrc32;
//         compressed size                 4 bytes
	DWORD m_uComprSize;
//         uncompressed size               4 bytes
	DWORD m_uUncomprSize;
//         filename length                 2 bytes
// 	WORD m_uFileNameSize;
//         extra field length              2 bytes
// 	WORD m_uExtraFieldSize;
//         file comment length             2 bytes
// 	WORD m_uCommentSize;
//         disk number start               2 bytes
	WORD m_uDiskStart;
//         internal file attributes        2 bytes
	WORD m_uInternalAttr;
//         external file attributes        4 bytes
	DWORD m_uExternalAttr;
//         relative offset of local header 4 bytes
	DWORD m_uOffset;	
//         extra field (variable size)
	CZipAutoBuffer m_pExtraField;

	CZipFileHeader();
	virtual ~CZipFileHeader();
	CTime GetTime();
	void SetTime(const CTime& time);
	static char m_gszSignature[];
	static char m_gszLocalSignature[];
// return the total size of the structure as stored in the central directory	
	DWORD GetSize();
protected:
//         filename (variable size)
	CZipAutoBuffer m_pszFileName;	
//         file comment (variable size)
	CZipAutoBuffer m_pszComment;

	void GetCrcAndSizes(char * pBuffer);
	bool PrepareData(int iLevel, bool bExtraHeader, bool bEncrypted);
	void WriteLocal(CZipStorage& storage);
	bool CheckCrcAndSizes(char* pBuf);
	friend class CZipCentralDir;
	friend class CZipArchive;
	bool Read(CZipStorage *pStorage);
	bool ReadLocal(CZipStorage *pStorage, WORD& iLocExtrFieldSize);
	DWORD Write(CZipStorage *pStorage);

};

#endif // !defined(AFX_ZipFileHeader_H__0081FC65_C9C9_4D48_AF72_DBF37DF5E0CF__INCLUDED_)