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