|
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 // zipfile.h |
|
15 // $Revision: 1.1 $ |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef _EZIP_FILE_H_ |
|
20 #define _EZIP_FILE_H_ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <s32file.h> |
|
24 #include <charconv.h> |
|
25 |
|
26 #include "localtypes.h" |
|
27 #include "oldziparchive.h" |
|
28 #include "OldZipFileMember.h" |
|
29 #include "OldZipFileMemberIterator.h" |
|
30 #include "oldzipfilememberinputstream.h" |
|
31 // Forward Class Declaration(s) |
|
32 |
|
33 class CFileInputStream; |
|
34 class TOLDEZIP::CZipFileMemberIterator; |
|
35 class TOLDEZIP::CZipFileMember; |
|
36 |
|
37 namespace ContentAccess |
|
38 { |
|
39 class CData; |
|
40 } |
|
41 |
|
42 |
|
43 // End of Forward Class Declaration(s) |
|
44 |
|
45 |
|
46 /** |
|
47 A CZipFile represents a ZIP archive contained in a single file. |
|
48 Multi file zip archives are not supported. |
|
49 |
|
50 @publishedAll |
|
51 @released |
|
52 */ |
|
53 namespace TOLDEZIP |
|
54 { |
|
55 class CZipFile : public TOLDEZIP::CZipArchive |
|
56 { |
|
57 friend class RZipFileMemberReaderStream; |
|
58 friend class CZipFileMemberIterator; |
|
59 |
|
60 public: |
|
61 /** ZipFile error enumeration. |
|
62 */ |
|
63 enum |
|
64 { |
|
65 /** Cannot read file directory in the archive file*/ |
|
66 KZipFileError = KZipArchiveMinError - 1, |
|
67 |
|
68 /** File not found error. It is not used in current implemenation*/ |
|
69 KZipFileNotFound = KZipFileError - 1, |
|
70 |
|
71 /** File IO error.Any error occurs during a archive file is readed. |
|
72 For examples, any error about reading number of disk, |
|
73 an offset of signature, or the content of file is non-readable. |
|
74 */ |
|
75 KZipFileIOError = KZipFileError - 2 |
|
76 }; |
|
77 |
|
78 public: |
|
79 IMPORT_C static CZipFile* NewL(RFs& aFs, RFile& aFile); |
|
80 IMPORT_C static CZipFile* NewL(RFs& aFs, const TDesC& aFileName); |
|
81 IMPORT_C CZipFile(RFs& aFs, const TDesC& aFileName); |
|
82 IMPORT_C TInt OpenL(void); |
|
83 IMPORT_C void Close(void); |
|
84 IMPORT_C virtual ~CZipFile(); |
|
85 |
|
86 protected: |
|
87 IMPORT_C void ConstructL(const TDesC& aFileName); |
|
88 |
|
89 IMPORT_C void ConstructL(RFile& aFile); |
|
90 |
|
91 public: |
|
92 IMPORT_C TInt Size(TInt& aSize) const; |
|
93 |
|
94 IMPORT_C CZipFileMember* MemberL(const TDesC& aName); |
|
95 IMPORT_C CZipFileMember* CaseInsensitiveMemberL(const TDesC& aName); |
|
96 IMPORT_C CZipFileMember* CaseSensitiveOrCaseInsensitiveMemberL(const TDesC& aName); |
|
97 IMPORT_C TInt GetInputStreamL(const CZipFileMember* aMember, RZipFileMemberReaderStream*& aStream); |
|
98 |
|
99 IMPORT_C CZipFileMemberIterator* GetMembersL(void); |
|
100 |
|
101 |
|
102 protected: |
|
103 |
|
104 /** |
|
105 Internal representation of a compressed file in a zipfile |
|
106 @publishedAll |
|
107 @released |
|
108 */ |
|
109 struct TMemberPointer |
|
110 { |
|
111 /** the name of a compressed file*/ |
|
112 TFileName* iName; |
|
113 |
|
114 /** Not used in current implementation*/ |
|
115 TUint32 iCentralHeaderOffset; |
|
116 |
|
117 /** The local offset of header in a compressed file*/ |
|
118 TUint32 iLocalHeaderOffset; |
|
119 |
|
120 /** CRC with 32 bits length in a compressed file*/ |
|
121 TUint32 iCRC32; |
|
122 |
|
123 /** The size of compressed file */ |
|
124 TUint32 iCompressedSize; |
|
125 |
|
126 /** The size of file without compressed*/ |
|
127 TUint32 iUncompressedSize; |
|
128 }; |
|
129 |
|
130 protected: |
|
131 TInt FindCentralDirectoryTrailer(TUint32& offset); |
|
132 TInt ReadCentralDirectoryTrailer(TUint32 offset, TCentralDirectoryTrailer&); |
|
133 TInt ReadCentralDirectoryHeaderL(TCentralDirectoryHeader&, TMemberPointer&, |
|
134 CCnvCharacterSetConverter* aConverter, TInt aConverterState); |
|
135 |
|
136 TInt ReadLocalHeader(TUint32, TLocalHeader&); |
|
137 |
|
138 const TMemberPointer* FindMemberPointer(const TDesC&, TBool); |
|
139 |
|
140 TInt LoadMemberPointersL(void); |
|
141 |
|
142 RZipFileMemberReaderStream* MakeInputStreamL(TUint32, TUint32, TUint32, TUint32); |
|
143 CZipFileMember* MakeMemberL(TInt); |
|
144 CZipFileMember* MakeMemberL(const TMemberPointer&, const TLocalHeader&); |
|
145 |
|
146 // File I/O Support |
|
147 void OpenFileL(const TDesC& aFileName); |
|
148 |
|
149 TInt Read(TByte*, TUint32); |
|
150 TInt Read(TUint16&); |
|
151 TInt Read(TUint32&); |
|
152 |
|
153 TInt Seek(TInt); |
|
154 |
|
155 // Misc |
|
156 void DeleteMemberPointers(void); |
|
157 |
|
158 private: |
|
159 const TDesC& iFileName; |
|
160 TUint32 iFileLength; |
|
161 |
|
162 /** The central directory of ZIP File Trailer*/ |
|
163 TCentralDirectoryTrailer iTrailer; |
|
164 |
|
165 /** The pointer to a a compressed file in a zipfile*/ |
|
166 TMemberPointer* iMemberPointers; |
|
167 |
|
168 RFs& iFs; |
|
169 |
|
170 /** The pointer to CData object created from a zip file*/ |
|
171 ContentAccess::CData* iData; |
|
172 }; |
|
173 }//TOLDEZIP |
|
174 #endif /* !_ZIP_FILE_H_ */ |