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