|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #ifndef _ZIP_ARCHIVE_H_ |
|
18 #define _ZIP_ARCHIVE_H_ |
|
19 |
|
20 #include <localtypes.h> |
|
21 |
|
22 /** |
|
23 This class represents a zip archive |
|
24 |
|
25 @publishedAll |
|
26 @released |
|
27 */ |
|
28 class CZipArchive: public CBase |
|
29 { |
|
30 public: |
|
31 |
|
32 enum |
|
33 { |
|
34 KZipArchiveError = -256, |
|
35 KCentralDirectoryTrailerNotFound = KZipArchiveError - 1, |
|
36 KCentralDirectoryTrailerInvalid = KZipArchiveError - 3, |
|
37 KCompressionMethodNotSupported = KZipArchiveError - 4, |
|
38 KLocalHeaderSignatureInvalid = KZipArchiveError - 5, |
|
39 KMultiDiskArchivesNotSupported = KZipArchiveError - 6, |
|
40 KMemberNotFound = KZipArchiveError - 7, |
|
41 |
|
42 KZipArchiveMinError = KZipArchiveError - 8 |
|
43 |
|
44 }; |
|
45 |
|
46 enum TCompressionMethod |
|
47 { |
|
48 |
|
49 EStored = 0, |
|
50 EShrunk = 1, |
|
51 EReducedCFOne = 2, |
|
52 EReducedCFTwo = 3, |
|
53 EReducedCFThree = 4, |
|
54 EReducedCFFour = 5, |
|
55 EImploded = 6, |
|
56 EReservedOne = 7, |
|
57 EDeflated = 8, |
|
58 EReservedTwo = 9, |
|
59 EPKWAREImploded = 10 |
|
60 |
|
61 }; |
|
62 |
|
63 protected: |
|
64 |
|
65 enum // Constants |
|
66 { |
|
67 |
|
68 KCentralDirectorySignature = 0x06054b50, |
|
69 KCentralDirectoryHeaderSignature = 0x02014b50, |
|
70 KLocalHeaderSignature = 0x04034b50 |
|
71 }; |
|
72 |
|
73 enum // Lengths |
|
74 { |
|
75 |
|
76 KCentralDirectoryTrailerFixedLength = 22, |
|
77 KLocalHeaderFixedLength = 30, |
|
78 KCentralDirectoryHeaderFixedLength = 46, |
|
79 KSignatureLength = 4, |
|
80 KMaxTrailerSearchLength = 65536 |
|
81 }; |
|
82 |
|
83 enum // Offsets |
|
84 { |
|
85 |
|
86 KCentralFileHeaderFileNameLengthOffset = 28, |
|
87 KCentralFileHeaderExtraFieldLengthOffset = 30, |
|
88 KCentralFileHeaderFileNameOffset = 46 |
|
89 }; |
|
90 |
|
91 /** |
|
92 Represents the archive's central directory trailer - the central directory contains information |
|
93 about files in the arhive |
|
94 |
|
95 @publishedAll |
|
96 @released |
|
97 */ |
|
98 struct TCentralDirectoryTrailer |
|
99 { |
|
100 TUint32 iSignature; |
|
101 TUint16 iDiskNumber; |
|
102 TUint16 iStartDiskNumber; |
|
103 TUint16 iLocalEntryCount; |
|
104 TUint16 iTotalEntryCount; |
|
105 TUint32 iSize; |
|
106 TUint32 iOffset; |
|
107 TUint16 iCommentLength; |
|
108 // comment -- variable length |
|
109 }; |
|
110 |
|
111 /** |
|
112 Represents the archive's central directory header - the central directory contains information |
|
113 about files in the arhive |
|
114 |
|
115 @publishedAll |
|
116 @released |
|
117 */ |
|
118 struct TCentralDirectoryHeader |
|
119 { |
|
120 TUint32 iSignature; |
|
121 TUint16 iMadeBy; |
|
122 TUint16 iRequired; |
|
123 TUint16 iFlags; |
|
124 TUint16 iCompressionMethod; |
|
125 TUint16 iLastModifiedFileTime; |
|
126 TUint16 iLastModifiedFileDate; |
|
127 TUint32 iCRC32; |
|
128 TUint32 iCompressedSize; |
|
129 TUint32 iUncompressedSize; |
|
130 TUint16 iFileNameLength; |
|
131 TUint16 iExtraFieldLength; |
|
132 TUint16 iFileCommentLength; |
|
133 TUint16 iDiskNumberStart; |
|
134 TUint16 iInternalFileAttributes; |
|
135 TUint32 iExternalFileAttributes; |
|
136 TUint32 iLocalHeaderOffset; |
|
137 // file name -- variable length |
|
138 // extra field -- variable length |
|
139 // file comment -- variable length |
|
140 }; |
|
141 |
|
142 /** |
|
143 Represents the archive's local header |
|
144 |
|
145 @publishedAll |
|
146 @released |
|
147 */ |
|
148 struct TLocalHeader |
|
149 { |
|
150 TUint32 iSignature; |
|
151 TUint16 iVersionNeeded; |
|
152 TUint16 iFlags; |
|
153 TUint16 iCompressionMethod; |
|
154 TUint16 iLastModifiedFileTime; |
|
155 TUint16 iLastModifiedFileDate; |
|
156 TUint32 iCRC32; |
|
157 TUint32 iCompressedSize; |
|
158 TUint32 iUncompressedSize; |
|
159 TUint16 iFileNameLength; |
|
160 TUint16 iExtraFieldLength; |
|
161 // file name -- variable length |
|
162 // extra field -- variable length |
|
163 }; |
|
164 }; |
|
165 |
|
166 #endif /* !_ZIP_ARCHIVE_H_ */ |
|
167 |