os/ossrv/compressionlibs/ziplib/test/oldezlib/inc/oldzipfile.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// zipfile.h
sl@0
    15
// $Revision: 1.1 $
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#ifndef _EZIP_FILE_H_
sl@0
    20
#define _EZIP_FILE_H_
sl@0
    21
sl@0
    22
#include <e32std.h>
sl@0
    23
#include <s32file.h>
sl@0
    24
#include <charconv.h>
sl@0
    25
sl@0
    26
#include "localtypes.h"
sl@0
    27
#include "oldziparchive.h"
sl@0
    28
#include "OldZipFileMember.h"
sl@0
    29
#include "OldZipFileMemberIterator.h"
sl@0
    30
#include "oldzipfilememberinputstream.h"
sl@0
    31
// Forward Class Declaration(s)
sl@0
    32
sl@0
    33
class CFileInputStream;
sl@0
    34
class TOLDEZIP::CZipFileMemberIterator;
sl@0
    35
class TOLDEZIP::CZipFileMember;
sl@0
    36
sl@0
    37
namespace ContentAccess
sl@0
    38
	{
sl@0
    39
	class CData;
sl@0
    40
	}
sl@0
    41
sl@0
    42
sl@0
    43
// End of Forward Class Declaration(s)
sl@0
    44
sl@0
    45
sl@0
    46
/** 
sl@0
    47
A CZipFile represents a ZIP archive contained in a single file. 
sl@0
    48
Multi file zip archives are not supported.
sl@0
    49
sl@0
    50
@publishedAll
sl@0
    51
@released
sl@0
    52
*/
sl@0
    53
namespace TOLDEZIP
sl@0
    54
{
sl@0
    55
class CZipFile : public TOLDEZIP::CZipArchive
sl@0
    56
	{
sl@0
    57
	friend class RZipFileMemberReaderStream;
sl@0
    58
	friend class CZipFileMemberIterator;
sl@0
    59
sl@0
    60
	public:
sl@0
    61
		/**	ZipFile error enumeration.
sl@0
    62
		*/
sl@0
    63
		enum
sl@0
    64
			{
sl@0
    65
			/** Cannot read file directory in the archive file*/
sl@0
    66
			KZipFileError 		= KZipArchiveMinError - 1,
sl@0
    67
			
sl@0
    68
			/** File not found error. It is not used in current implemenation*/
sl@0
    69
			KZipFileNotFound	= KZipFileError - 1,
sl@0
    70
			
sl@0
    71
			/** File IO error.Any error occurs during a archive file is readed. 
sl@0
    72
			For examples, any error about reading number of disk,
sl@0
    73
			an offset of signature, or the content of file is non-readable.
sl@0
    74
			*/
sl@0
    75
			KZipFileIOError 	= KZipFileError - 2
sl@0
    76
			};
sl@0
    77
sl@0
    78
	public:
sl@0
    79
		IMPORT_C static CZipFile* NewL(RFs& aFs, RFile& aFile);	
sl@0
    80
		IMPORT_C static CZipFile* NewL(RFs& aFs, const TDesC& aFileName);
sl@0
    81
		IMPORT_C CZipFile(RFs& aFs, const TDesC& aFileName);
sl@0
    82
		IMPORT_C TInt OpenL(void);
sl@0
    83
		IMPORT_C void Close(void);
sl@0
    84
		IMPORT_C virtual ~CZipFile();
sl@0
    85
sl@0
    86
	protected:
sl@0
    87
		IMPORT_C void ConstructL(const TDesC& aFileName);
sl@0
    88
		
sl@0
    89
		IMPORT_C void ConstructL(RFile& aFile);
sl@0
    90
sl@0
    91
	public:
sl@0
    92
		IMPORT_C TInt Size(TInt& aSize) const;
sl@0
    93
    
sl@0
    94
		IMPORT_C CZipFileMember* MemberL(const TDesC& aName);
sl@0
    95
		IMPORT_C CZipFileMember* CaseInsensitiveMemberL(const TDesC& aName);
sl@0
    96
		IMPORT_C CZipFileMember* CaseSensitiveOrCaseInsensitiveMemberL(const TDesC& aName);
sl@0
    97
		IMPORT_C TInt GetInputStreamL(const CZipFileMember* aMember, RZipFileMemberReaderStream*& aStream);
sl@0
    98
sl@0
    99
  		IMPORT_C CZipFileMemberIterator* GetMembersL(void);
sl@0
   100
	
sl@0
   101
    
sl@0
   102
protected:
sl@0
   103
sl@0
   104
	/** 
sl@0
   105
	Internal representation of a compressed file in a zipfile
sl@0
   106
	@publishedAll
sl@0
   107
	@released
sl@0
   108
	*/
sl@0
   109
	struct TMemberPointer
sl@0
   110
		{
sl@0
   111
		/** the name of a compressed file*/
sl@0
   112
		TFileName*  iName;
sl@0
   113
		
sl@0
   114
		/** Not used in current implementation*/
sl@0
   115
		TUint32		iCentralHeaderOffset;
sl@0
   116
		
sl@0
   117
		/** The local offset of header in a compressed file*/
sl@0
   118
		TUint32	iLocalHeaderOffset;
sl@0
   119
		
sl@0
   120
		/** CRC with 32 bits length in a compressed file*/
sl@0
   121
		TUint32 iCRC32;
sl@0
   122
		
sl@0
   123
		/** The size of compressed file */	
sl@0
   124
		TUint32	iCompressedSize;
sl@0
   125
		
sl@0
   126
		/** The size of file without compressed*/
sl@0
   127
		TUint32	iUncompressedSize;
sl@0
   128
		};
sl@0
   129
		
sl@0
   130
protected:
sl@0
   131
	TInt FindCentralDirectoryTrailer(TUint32& offset);
sl@0
   132
    TInt ReadCentralDirectoryTrailer(TUint32 offset, TCentralDirectoryTrailer&);
sl@0
   133
    TInt ReadCentralDirectoryHeaderL(TCentralDirectoryHeader&, TMemberPointer&,
sl@0
   134
    	CCnvCharacterSetConverter* aConverter, TInt aConverterState);
sl@0
   135
sl@0
   136
	TInt ReadLocalHeader(TUint32, TLocalHeader&);
sl@0
   137
	
sl@0
   138
	const TMemberPointer* FindMemberPointer(const TDesC&, TBool);
sl@0
   139
	
sl@0
   140
    TInt LoadMemberPointersL(void);
sl@0
   141
    
sl@0
   142
	RZipFileMemberReaderStream*   MakeInputStreamL(TUint32, TUint32, TUint32, TUint32);
sl@0
   143
    CZipFileMember* MakeMemberL(TInt);
sl@0
   144
    CZipFileMember* MakeMemberL(const TMemberPointer&, const TLocalHeader&);
sl@0
   145
    
sl@0
   146
    // File I/O Support
sl@0
   147
    void OpenFileL(const TDesC& aFileName);
sl@0
   148
  
sl@0
   149
    TInt Read(TByte*, TUint32);
sl@0
   150
    TInt Read(TUint16&);
sl@0
   151
    TInt Read(TUint32&);
sl@0
   152
    
sl@0
   153
    TInt Seek(TInt);
sl@0
   154
sl@0
   155
	// Misc
sl@0
   156
	void DeleteMemberPointers(void);
sl@0
   157
sl@0
   158
private:
sl@0
   159
    const TDesC&				iFileName;
sl@0
   160
    TUint32 iFileLength;
sl@0
   161
	
sl@0
   162
	/** The central directory of ZIP File Trailer*/
sl@0
   163
	TCentralDirectoryTrailer iTrailer;
sl@0
   164
	
sl@0
   165
	/** The pointer to a a compressed file in a zipfile*/
sl@0
   166
	TMemberPointer*	iMemberPointers;
sl@0
   167
	
sl@0
   168
	RFs& iFs;
sl@0
   169
	
sl@0
   170
	/** The pointer to CData object created from a zip file*/
sl@0
   171
	ContentAccess::CData* iData;
sl@0
   172
	};
sl@0
   173
}//TOLDEZIP
sl@0
   174
#endif /* !_ZIP_FILE_H_ */