|
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 // zipfilememberinputstream.h |
|
15 // $Revision: 1.2 $ |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef _EZIP_FILE_MEMBER_INPUT_STREAM_H_ |
|
20 #define _EZIP_FILE_MEMBER_INPUT_STREAM_H_ |
|
21 |
|
22 #include "OldEZlib.h" |
|
23 #include "localtypes.h" |
|
24 #include <s32file.h> |
|
25 |
|
26 class TOLDEZIP::CZipFile; |
|
27 |
|
28 /** |
|
29 A RZipFileMemberReaderStream represents a input stream for compressed files in the archive. |
|
30 This is a friend class to CZipFile. In order to create a input stream for a file in the archive, |
|
31 CZipFile will call its member function GetInputStreamL() by passing a pointer to |
|
32 RZipFileMemberReaderStream and the function will return the input stream for the file |
|
33 Note: This class is actually a C class as it derives from CBase |
|
34 |
|
35 @publishedAll |
|
36 @released |
|
37 */ |
|
38 namespace TOLDEZIP |
|
39 { |
|
40 class RZipFileMemberReaderStream : public CBase |
|
41 { |
|
42 friend class CZipFile; |
|
43 |
|
44 public: |
|
45 |
|
46 IMPORT_C ~RZipFileMemberReaderStream(); |
|
47 IMPORT_C TInt Read(TDes16& aDes, TInt aLength); |
|
48 |
|
49 /** |
|
50 Overload version of the RZipFileMemberReaderStream read method. |
|
51 On return, contains the data read from the stream buffer. |
|
52 |
|
53 @param aDes The target descriptor for the data read from the stream buffer |
|
54 @param aLength The maximum number of bytes to be read |
|
55 @return KErrNone If all bytes read successfully. |
|
56 @return KErrCorrupt If reading fails. |
|
57 @return KErrEof If end of file is reached. |
|
58 @return ... Any one of the system-wide error codes for other errors. |
|
59 */ |
|
60 virtual TInt Read(TDes8& aDes, TInt aLength); |
|
61 |
|
62 /** |
|
63 Overload version of the RZipFileMemberReaderStream readL method. |
|
64 On return, contains the data read from the stream buffer. |
|
65 |
|
66 @param aDes The target descriptor for the data read from the stream buffer |
|
67 @param aLength The maximum number of bytes to be read |
|
68 @leave KErrNone If all bytes read successfully. |
|
69 @leave KErrCorrupt If reading fails. |
|
70 @leave KErrEof If end of file is reached. |
|
71 @leave ... Any one of the system-wide error codes for other errors. |
|
72 */ |
|
73 virtual void ReadL(TDes16& aDes, TInt aLength); |
|
74 |
|
75 |
|
76 void Release(); |
|
77 void Close(); |
|
78 |
|
79 private: |
|
80 RZipFileMemberReaderStream(CZipFile&, TUint32, TUint32, TUint32, TUint32); |
|
81 |
|
82 static RZipFileMemberReaderStream* NewL(CZipFile&, TUint32, TUint32, TUint32, TUint32); |
|
83 void RZipFileMemberReaderStream::ConstructL(); |
|
84 |
|
85 virtual TInt Read(void); |
|
86 virtual TInt Read(TByte*, TUint32, TUint32*); |
|
87 |
|
88 TInt GetBytes(TByte*, TUint32, TUint32*); |
|
89 TInt GetCompressedBytes(void); |
|
90 TInt GetStoredBytes(TByte*, TUint32, TUint32*); |
|
91 |
|
92 void ReadL(TDes8&); |
|
93 void ReadL(TDes16&); |
|
94 void ReadL(TDes8&, TChar); |
|
95 void ReadL(TDes16&, TChar); |
|
96 void ReadL(TUint8*, TInt); |
|
97 void ReadL(TUint16*, TInt); |
|
98 void ReadL(RWriteStream&); |
|
99 void ReadL(RWriteStream&, TInt); |
|
100 void ReadL(TInt); |
|
101 |
|
102 TInt8 ReadInt8L(); |
|
103 TInt16 ReadInt16L(); |
|
104 TInt32 ReadInt32L(); |
|
105 TUint8 ReadUint8L(); |
|
106 TUint16 ReadUint16L(); |
|
107 TUint32 ReadUint32L(); |
|
108 |
|
109 TReal32 ReadReal32L() __SOFTFP; |
|
110 TReal64 ReadReal64L() __SOFTFP; |
|
111 |
|
112 void PushL(); |
|
113 void Pop(); |
|
114 void Attach(MStreamBuf*); |
|
115 void Detach(); |
|
116 MStreamBuf* Source(); |
|
117 |
|
118 |
|
119 private: |
|
120 |
|
121 enum |
|
122 { |
|
123 kCompressedBytesSize = 1024 |
|
124 }; |
|
125 |
|
126 private: |
|
127 |
|
128 CZipFile& iZipFile; |
|
129 |
|
130 /** The method for compressing file*/ |
|
131 TUint32 iCompressionMethod; |
|
132 |
|
133 z_stream iStream; |
|
134 |
|
135 /** The size of compressed file */ |
|
136 TUint32 iCompressedSize; |
|
137 |
|
138 /** The size of uncompressed file */ |
|
139 TUint32 iUncompressedSize; |
|
140 |
|
141 TUint32 iFileOffset; |
|
142 TUint32 iOffset; |
|
143 TBool iDone; |
|
144 |
|
145 /** The number of bytes already read in uncompressed bytes*/ |
|
146 TUint32 iBytesLength; |
|
147 |
|
148 /** To store compressed bytes read*/ |
|
149 TByte iCompressedBytes[kCompressedBytesSize]; |
|
150 |
|
151 /** Not used in implementation*/ |
|
152 TUint32 iCompressedBytesOffset; |
|
153 }; |
|
154 }//TOLDEZIP |
|
155 #endif /* !_ZIP_FILE_MEMBER_INPUT_STREAM_H_ */ |
|
156 |