epoc32/include/zipfilememberinputstream.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/zipfilememberinputstream.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/zipfilememberinputstream.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,153 @@
     1.4 -zipfilememberinputstream.h
     1.5 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// $Revision: 1.2 $
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#ifndef _ZIP_FILE_MEMBER_INPUT_STREAM_H_
    1.23 +#define _ZIP_FILE_MEMBER_INPUT_STREAM_H_
    1.24 +
    1.25 +#include <ezlib.h>
    1.26 +#include "localtypes.h"
    1.27 +#include <s32file.h>
    1.28 +
    1.29 +class CZipFile;
    1.30 +
    1.31 +/**
    1.32 +A RZipFileMemberReaderStream represents a input stream for compressed files in the archive. 
    1.33 +This is a friend class to CZipFile. In order to create a input stream for a file in the archive,
    1.34 +CZipFile will call its member function GetInputStreamL() by passing a pointer to 
    1.35 +RZipFileMemberReaderStream and the function will return the input stream for the file
    1.36 +Note: This class is actually a C class as it derives from CBase
    1.37 +
    1.38 +@publishedAll
    1.39 +@released
    1.40 +*/
    1.41 +class RZipFileMemberReaderStream : public CBase
    1.42 +	{
    1.43 +friend class CZipFile;
    1.44 +
    1.45 +public:
    1.46 +	
    1.47 +	IMPORT_C ~RZipFileMemberReaderStream();
    1.48 +	IMPORT_C TInt Read(TDes16& aDes, TInt aLength);
    1.49 +	
    1.50 +	/**
    1.51 +	Overload version of the RZipFileMemberReaderStream read method.
    1.52 +	On return, contains the data read from the stream buffer.
    1.53 +	
    1.54 +	@param aDes The target descriptor for the data read from the stream buffer
    1.55 +	@param aLength The maximum number of bytes to be read
    1.56 +	@return KErrNone If all bytes read successfully.
    1.57 +	@return	KErrCorrupt If reading fails.
    1.58 +	@return KErrEof If end of file is reached.
    1.59 +	@return ... Any one of the system-wide error codes for other errors.
    1.60 +	*/	
    1.61 +	virtual TInt Read(TDes8& aDes, TInt aLength);
    1.62 +	
    1.63 +	/**
    1.64 +	Overload version of the RZipFileMemberReaderStream readL method.
    1.65 +	On return, contains the data read from the stream buffer.
    1.66 +	
    1.67 +	@param aDes The target descriptor for the data read from the stream buffer
    1.68 +	@param aLength The maximum number of bytes to be read
    1.69 +	@leave KErrNone If all bytes read successfully.
    1.70 +	@leave KErrCorrupt If reading fails.
    1.71 +	@leave KErrEof If end of file is reached.
    1.72 +	@leave ... Any one of the system-wide error codes for other errors.
    1.73 +	*/
    1.74 +	virtual void ReadL(TDes16& aDes, TInt aLength);
    1.75 +
    1.76 +
    1.77 +	void Release();
    1.78 +	void Close();
    1.79 +
    1.80 +private:
    1.81 +	RZipFileMemberReaderStream(CZipFile&, TUint32, TUint32, TUint32, TUint32);
    1.82 +	
    1.83 +	static RZipFileMemberReaderStream* NewL(CZipFile&, TUint32, TUint32, TUint32, TUint32);
    1.84 +	void RZipFileMemberReaderStream::ConstructL();
    1.85 +	
    1.86 +	virtual TInt Read(void);
    1.87 +	virtual TInt Read(TByte*, TUint32, TUint32*);
    1.88 +
    1.89 +	TInt GetBytes(TByte*, TUint32, TUint32*);
    1.90 +	TInt GetCompressedBytes(void);
    1.91 +	TInt GetStoredBytes(TByte*, TUint32, TUint32*);
    1.92 +	
    1.93 +	void ReadL(TDes8&);
    1.94 +	void ReadL(TDes16&);
    1.95 +	void ReadL(TDes8&, TChar);
    1.96 +	void ReadL(TDes16&, TChar);
    1.97 +	void ReadL(TUint8*, TInt);
    1.98 +	void ReadL(TUint16*, TInt);
    1.99 +	void ReadL(RWriteStream&);
   1.100 +	void ReadL(RWriteStream&, TInt);
   1.101 +	void ReadL(TInt);
   1.102 +
   1.103 +	TInt8 ReadInt8L();
   1.104 +	TInt16 ReadInt16L();
   1.105 +	TInt32 ReadInt32L();
   1.106 +	TUint8 ReadUint8L();
   1.107 +	TUint16 ReadUint16L();
   1.108 +	TUint32 ReadUint32L();
   1.109 +
   1.110 +	TReal32 ReadReal32L() __SOFTFP;
   1.111 +	TReal64 ReadReal64L() __SOFTFP;
   1.112 +
   1.113 +	void PushL();
   1.114 +	void Pop();
   1.115 +	void Attach(MStreamBuf*);
   1.116 +	void Detach();
   1.117 +	MStreamBuf* Source();
   1.118 +
   1.119 +
   1.120 +private:
   1.121 +
   1.122 +	enum
   1.123 +		{
   1.124 +		kCompressedBytesSize = 1024
   1.125 +		};
   1.126 +		
   1.127 +private:
   1.128 +	
   1.129 +	CZipFile& 	iZipFile;
   1.130 +	
   1.131 +	/** The method for compressing file*/ 
   1.132 +	TUint32   	iCompressionMethod;
   1.133 +	
   1.134 +	z_stream  	iStream;
   1.135 +	
   1.136 +	/** The size of compressed file */
   1.137 +	TUint32     iCompressedSize;
   1.138 +	
   1.139 +	/** The size of uncompressed file */
   1.140 +	TUint32     iUncompressedSize;
   1.141 +	
   1.142 +	TUint32     iFileOffset;
   1.143 +	TUint32     iOffset;
   1.144 +	TBool       iDone;
   1.145 +	
   1.146 +	/** The number of bytes already read in uncompressed bytes*/
   1.147 +	TUint32     iBytesLength;
   1.148 +	
   1.149 +	/** To store compressed bytes read*/
   1.150 +	TByte       iCompressedBytes[kCompressedBytesSize];
   1.151 +	
   1.152 +	/** Not used in implementation*/
   1.153 +	TUint32     iCompressedBytesOffset;
   1.154 +	};
   1.155 +
   1.156 +	
   1.157 +#endif /* !_ZIP_FILE_MEMBER_INPUT_STREAM_H_ */