Mercurial > vba-linux
comparison src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 // Archive/RarHeader.h | |
2 | |
3 #ifndef __ARCHIVE_RAR_HEADER_H | |
4 #define __ARCHIVE_RAR_HEADER_H | |
5 | |
6 #include "Common/Types.h" | |
7 | |
8 namespace NArchive{ | |
9 namespace NRar{ | |
10 namespace NHeader{ | |
11 | |
12 const int kMarkerSize = 7; | |
13 extern Byte kMarker[kMarkerSize]; | |
14 | |
15 const int kArchiveSolid = 0x1; | |
16 | |
17 namespace NBlockType | |
18 { | |
19 enum EBlockType | |
20 { | |
21 kMarker = 0x72, | |
22 kArchiveHeader = 0x73, | |
23 kFileHeader = 0x74, | |
24 kCommentHeader = 0x75, | |
25 kOldAuthenticity = 0x76, | |
26 kSubBlock = 0x77, | |
27 kRecoveryRecord = 0x78, | |
28 kAuthenticity = 0x79, | |
29 | |
30 kEndOfArchive = 0x7B // Is not safe | |
31 }; | |
32 } | |
33 | |
34 namespace NArchive | |
35 { | |
36 const UInt16 kVolume = 1; | |
37 const UInt16 kComment = 2; | |
38 const UInt16 kLock = 4; | |
39 const UInt16 kSolid = 8; | |
40 const UInt16 kNewVolName = 0x10; // ('volname.partN.rar') | |
41 const UInt16 kAuthenticity = 0x20; | |
42 const UInt16 kRecovery = 0x40; | |
43 const UInt16 kBlockEncryption = 0x80; | |
44 const UInt16 kFirstVolume = 0x100; // (set only by RAR 3.0 and later) | |
45 const UInt16 kEncryptVer = 0x200; // RAR 3.6 there is EncryptVer Byte in End of MainHeader | |
46 | |
47 const int kHeaderSizeMin = 7; | |
48 | |
49 struct CBlock | |
50 { | |
51 UInt16 CRC; | |
52 Byte Type; | |
53 UInt16 Flags; | |
54 UInt16 Size; | |
55 UInt16 Reserved1; | |
56 UInt32 Reserved2; | |
57 // UInt16 GetRealCRC() const; | |
58 }; | |
59 | |
60 const int kArchiveHeaderSize = 13; | |
61 | |
62 const int kBlockHeadersAreEncrypted = 0x80; | |
63 | |
64 struct CHeader360: public CBlock | |
65 { | |
66 Byte EncryptVersion; | |
67 bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; } | |
68 bool IsThereEncryptVer() const { return (Flags & NHeader::NArchive::kEncryptVer) != 0; } | |
69 bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); } | |
70 UInt32 GetBaseSize() const { return kArchiveHeaderSize + (IsEncryptOld() ? 0 : 1); } | |
71 }; | |
72 } | |
73 | |
74 namespace NFile | |
75 { | |
76 const int kSplitBefore = 1 << 0; | |
77 const int kSplitAfter = 1 << 1; | |
78 const int kEncrypted = 1 << 2; | |
79 const int kComment = 1 << 3; | |
80 const int kSolid = 1 << 4; | |
81 | |
82 const int kDictBitStart = 5; | |
83 const int kNumDictBits = 3; | |
84 const int kDictMask = (1 << kNumDictBits) - 1; | |
85 const int kDictDirectoryValue = 0x7; | |
86 | |
87 const int kSize64Bits = 1 << 8; | |
88 const int kUnicodeName = 1 << 9; | |
89 const int kSalt = 1 << 10; | |
90 const int kOldVersion = 1 << 11; | |
91 const int kExtTime = 1 << 12; | |
92 // const int kExtFlags = 1 << 13; | |
93 // const int kSkipIfUnknown = 1 << 14; | |
94 | |
95 const int kLongBlock = 1 << 15; | |
96 | |
97 /* | |
98 struct CBlock | |
99 { | |
100 // UInt16 HeadCRC; | |
101 // Byte Type; | |
102 // UInt16 Flags; | |
103 // UInt16 HeadSize; | |
104 UInt32 PackSize; | |
105 UInt32 UnPackSize; | |
106 Byte HostOS; | |
107 UInt32 FileCRC; | |
108 UInt32 Time; | |
109 Byte UnPackVersion; | |
110 Byte Method; | |
111 UInt16 NameSize; | |
112 UInt32 Attributes; | |
113 }; | |
114 */ | |
115 | |
116 /* | |
117 struct CBlock32 | |
118 { | |
119 UInt16 HeadCRC; | |
120 Byte Type; | |
121 UInt16 Flags; | |
122 UInt16 HeadSize; | |
123 UInt32 PackSize; | |
124 UInt32 UnPackSize; | |
125 Byte HostOS; | |
126 UInt32 FileCRC; | |
127 UInt32 Time; | |
128 Byte UnPackVersion; | |
129 Byte Method; | |
130 UInt16 NameSize; | |
131 UInt32 Attributes; | |
132 UInt16 GetRealCRC(const void *aName, UInt32 aNameSize, | |
133 bool anExtraDataDefined = false, Byte *anExtraData = 0) const; | |
134 }; | |
135 struct CBlock64 | |
136 { | |
137 UInt16 HeadCRC; | |
138 Byte Type; | |
139 UInt16 Flags; | |
140 UInt16 HeadSize; | |
141 UInt32 PackSizeLow; | |
142 UInt32 UnPackSizeLow; | |
143 Byte HostOS; | |
144 UInt32 FileCRC; | |
145 UInt32 Time; | |
146 Byte UnPackVersion; | |
147 Byte Method; | |
148 UInt16 NameSize; | |
149 UInt32 Attributes; | |
150 UInt32 PackSizeHigh; | |
151 UInt32 UnPackSizeHigh; | |
152 UInt16 GetRealCRC(const void *aName, UInt32 aNameSize) const; | |
153 }; | |
154 */ | |
155 | |
156 const int kLabelFileAttribute = 0x08; | |
157 const int kWinFileDirectoryAttributeMask = 0x10; | |
158 | |
159 enum CHostOS | |
160 { | |
161 kHostMSDOS = 0, | |
162 kHostOS2 = 1, | |
163 kHostWin32 = 2, | |
164 kHostUnix = 3, | |
165 kHostMacOS = 4, | |
166 kHostBeOS = 5 | |
167 }; | |
168 } | |
169 | |
170 namespace NBlock | |
171 { | |
172 const UInt16 kLongBlock = 1 << 15; | |
173 struct CBlock | |
174 { | |
175 UInt16 CRC; | |
176 Byte Type; | |
177 UInt16 Flags; | |
178 UInt16 HeadSize; | |
179 // UInt32 DataSize; | |
180 }; | |
181 } | |
182 | |
183 /* | |
184 struct CSubBlock | |
185 { | |
186 UInt16 HeadCRC; | |
187 Byte HeadType; | |
188 UInt16 Flags; | |
189 UInt16 HeadSize; | |
190 UInt32 DataSize; | |
191 UInt16 SubType; | |
192 Byte Level; // Reserved : Must be 0 | |
193 }; | |
194 | |
195 struct CCommentBlock | |
196 { | |
197 UInt16 HeadCRC; | |
198 Byte HeadType; | |
199 UInt16 Flags; | |
200 UInt16 HeadSize; | |
201 UInt16 UnpSize; | |
202 Byte UnpVer; | |
203 Byte Method; | |
204 UInt16 CommCRC; | |
205 }; | |
206 | |
207 | |
208 struct CProtectHeader | |
209 { | |
210 UInt16 HeadCRC; | |
211 Byte HeadType; | |
212 UInt16 Flags; | |
213 UInt16 HeadSize; | |
214 UInt32 DataSize; | |
215 Byte Version; | |
216 UInt16 RecSectors; | |
217 UInt32 TotalBlocks; | |
218 Byte Mark[8]; | |
219 }; | |
220 */ | |
221 | |
222 }}} | |
223 | |
224 #endif |