williamr@2: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@4: williamr@2: #ifndef _ZIP_FILE_MEMBER_INPUT_STREAM_H_ williamr@2: #define _ZIP_FILE_MEMBER_INPUT_STREAM_H_ williamr@2: williamr@4: #include williamr@4: #include williamr@2: #include williamr@2: williamr@2: class CZipFile; williamr@2: williamr@2: /** williamr@2: A RZipFileMemberReaderStream represents a input stream for compressed files in the archive. williamr@2: This is a friend class to CZipFile. In order to create a input stream for a file in the archive, williamr@2: CZipFile will call its member function GetInputStreamL() by passing a pointer to williamr@2: RZipFileMemberReaderStream and the function will return the input stream for the file williamr@2: Note: This class is actually a C class as it derives from CBase williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class RZipFileMemberReaderStream : public CBase williamr@2: { williamr@2: friend class CZipFile; williamr@2: williamr@2: public: williamr@2: williamr@2: IMPORT_C ~RZipFileMemberReaderStream(); williamr@2: IMPORT_C TInt Read(TDes16& aDes, TInt aLength); williamr@2: williamr@2: /** williamr@2: Overload version of the RZipFileMemberReaderStream read method. williamr@2: On return, contains the data read from the stream buffer. williamr@2: williamr@2: @param aDes The target descriptor for the data read from the stream buffer williamr@2: @param aLength The maximum number of bytes to be read williamr@2: @return KErrNone If all bytes read successfully. williamr@2: @return KErrCorrupt If reading fails. williamr@2: @return KErrEof If end of file is reached. williamr@2: @return ... Any one of the system-wide error codes for other errors. williamr@2: */ williamr@2: virtual TInt Read(TDes8& aDes, TInt aLength); williamr@2: williamr@2: /** williamr@2: Overload version of the RZipFileMemberReaderStream readL method. williamr@2: On return, contains the data read from the stream buffer. williamr@2: williamr@2: @param aDes The target descriptor for the data read from the stream buffer williamr@2: @param aLength The maximum number of bytes to be read williamr@2: @leave KErrNone If all bytes read successfully. williamr@2: @leave KErrCorrupt If reading fails. williamr@2: @leave KErrEof If end of file is reached. williamr@2: @leave ... Any one of the system-wide error codes for other errors. williamr@2: */ williamr@2: virtual void ReadL(TDes16& aDes, TInt aLength); williamr@2: williamr@2: williamr@2: void Release(); williamr@2: void Close(); williamr@2: williamr@2: private: williamr@2: RZipFileMemberReaderStream(CZipFile&, TUint32, TUint32, TUint32, TUint32); williamr@2: williamr@2: static RZipFileMemberReaderStream* NewL(CZipFile&, TUint32, TUint32, TUint32, TUint32); williamr@2: void RZipFileMemberReaderStream::ConstructL(); williamr@2: williamr@2: virtual TInt Read(void); williamr@2: virtual TInt Read(TByte*, TUint32, TUint32*); williamr@2: williamr@2: TInt GetBytes(TByte*, TUint32, TUint32*); williamr@2: TInt GetCompressedBytes(void); williamr@2: TInt GetStoredBytes(TByte*, TUint32, TUint32*); williamr@2: williamr@2: void ReadL(TDes8&); williamr@2: void ReadL(TDes16&); williamr@2: void ReadL(TDes8&, TChar); williamr@2: void ReadL(TDes16&, TChar); williamr@2: void ReadL(TUint8*, TInt); williamr@2: void ReadL(TUint16*, TInt); williamr@2: void ReadL(RWriteStream&); williamr@2: void ReadL(RWriteStream&, TInt); williamr@2: void ReadL(TInt); williamr@2: williamr@2: TInt8 ReadInt8L(); williamr@2: TInt16 ReadInt16L(); williamr@2: TInt32 ReadInt32L(); williamr@2: TUint8 ReadUint8L(); williamr@2: TUint16 ReadUint16L(); williamr@2: TUint32 ReadUint32L(); williamr@2: williamr@2: TReal32 ReadReal32L() __SOFTFP; williamr@2: TReal64 ReadReal64L() __SOFTFP; williamr@2: williamr@2: void PushL(); williamr@2: void Pop(); williamr@2: void Attach(MStreamBuf*); williamr@2: void Detach(); williamr@2: MStreamBuf* Source(); williamr@2: williamr@2: williamr@2: private: williamr@2: williamr@2: enum williamr@2: { williamr@2: kCompressedBytesSize = 1024 williamr@2: }; williamr@2: williamr@2: private: williamr@2: williamr@2: CZipFile& iZipFile; williamr@2: williamr@2: /** The method for compressing file*/ williamr@2: TUint32 iCompressionMethod; williamr@2: williamr@2: z_stream iStream; williamr@2: williamr@2: /** The size of compressed file */ williamr@2: TUint32 iCompressedSize; williamr@2: williamr@2: /** The size of uncompressed file */ williamr@2: TUint32 iUncompressedSize; williamr@2: williamr@2: TUint32 iFileOffset; williamr@2: TUint32 iOffset; williamr@2: TBool iDone; williamr@2: williamr@2: /** The number of bytes already read in uncompressed bytes*/ williamr@2: TUint32 iBytesLength; williamr@2: williamr@2: /** To store compressed bytes read*/ williamr@2: TByte iCompressedBytes[kCompressedBytesSize]; williamr@2: williamr@2: /** Not used in implementation*/ williamr@2: TUint32 iCompressedBytesOffset; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif /* !_ZIP_FILE_MEMBER_INPUT_STREAM_H_ */ williamr@4: