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