os/ossrv/compressionlibs/ziplib/inc/zipfile.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
//
sl@0
    15
sl@0
    16
sl@0
    17
#ifndef _ZIP_FILE_H_
sl@0
    18
#define _ZIP_FILE_H_
sl@0
    19
sl@0
    20
#include <e32std.h>
sl@0
    21
#include <s32file.h>
sl@0
    22
#include <charconv.h>
sl@0
    23
sl@0
    24
#include <localtypes.h>
sl@0
    25
#include <ziparchive.h>
sl@0
    26
#include <zipfilememberinputstream.h>
sl@0
    27
#include <zipfilememberiterator.h>
sl@0
    28
#include <zipfilemember.h>
sl@0
    29
sl@0
    30
// Forward Class Declaration(s)
sl@0
    31
sl@0
    32
class CFileInputStream;
sl@0
    33
class CZipFileMemberIterator;
sl@0
    34
class CZipFileMember;
sl@0
    35
namespace ContentAccess
sl@0
    36
	{
sl@0
    37
	class CData;
sl@0
    38
	}
sl@0
    39
sl@0
    40
// End of Forward Class Declaration(s)
sl@0
    41
sl@0
    42
sl@0
    43
/** 
sl@0
    44
A CZipFile represents a ZIP archive contained in a single file. 
sl@0
    45
Multi file zip archives are not supported.
sl@0
    46
sl@0
    47
@publishedAll
sl@0
    48
@released
sl@0
    49
*/
sl@0
    50
class CZipFile : public CZipArchive
sl@0
    51
	{
sl@0
    52
	friend class RZipFileMemberReaderStream;
sl@0
    53
	friend class CZipFileMemberIterator;
sl@0
    54
sl@0
    55
	public:
sl@0
    56
		/**	ZipFile error enumeration.
sl@0
    57
		*/
sl@0
    58
		enum
sl@0
    59
			{
sl@0
    60
			/** Cannot read file directory in the archive file*/
sl@0
    61
			KZipFileError 		= KZipArchiveMinError - 1,
sl@0
    62
			
sl@0
    63
			/** File not found error. It is not used in current implemenation*/
sl@0
    64
			KZipFileNotFound	= KZipFileError - 1,
sl@0
    65
			
sl@0
    66
			/** File IO error.Any error occurs during a archive file is readed. 
sl@0
    67
			For examples, any error about reading number of disk,
sl@0
    68
			an offset of signature, or the content of file is non-readable.
sl@0
    69
			*/
sl@0
    70
			KZipFileIOError 	= KZipFileError - 2
sl@0
    71
			};
sl@0
    72
sl@0
    73
	public:
sl@0
    74
		IMPORT_C static CZipFile* NewL(RFs& aFs, RFile& aFile);	
sl@0
    75
		IMPORT_C static CZipFile* NewL(RFs& aFs, const TDesC& aFileName);
sl@0
    76
		IMPORT_C CZipFile(RFs& aFs, const TDesC& aFileName);
sl@0
    77
		IMPORT_C TInt OpenL(void);
sl@0
    78
		IMPORT_C void Close(void);
sl@0
    79
		IMPORT_C virtual ~CZipFile();
sl@0
    80
sl@0
    81
	protected:
sl@0
    82
		IMPORT_C void ConstructL(const TDesC& aFileName);
sl@0
    83
		
sl@0
    84
		IMPORT_C void ConstructL(RFile& aFile);
sl@0
    85
sl@0
    86
	public:
sl@0
    87
		IMPORT_C TInt Size(TInt& aSize) const;
sl@0
    88
    
sl@0
    89
		IMPORT_C CZipFileMember* MemberL(const TDesC& aName);
sl@0
    90
		IMPORT_C CZipFileMember* CaseInsensitiveMemberL(const TDesC& aName);
sl@0
    91
		IMPORT_C CZipFileMember* CaseSensitiveOrCaseInsensitiveMemberL(const TDesC& aName);
sl@0
    92
		IMPORT_C TInt GetInputStreamL(const CZipFileMember* aMember, RZipFileMemberReaderStream*& aStream);
sl@0
    93
sl@0
    94
  		IMPORT_C CZipFileMemberIterator* GetMembersL(void);
sl@0
    95
	
sl@0
    96
    
sl@0
    97
protected:
sl@0
    98
sl@0
    99
	/** 
sl@0
   100
	Internal representation of a compressed file in a zipfile
sl@0
   101
	@publishedAll
sl@0
   102
	@released
sl@0
   103
	*/
sl@0
   104
	struct TMemberPointer
sl@0
   105
		{
sl@0
   106
		/** the name of a compressed file*/
sl@0
   107
		TFileName*  iName;
sl@0
   108
		
sl@0
   109
		/** Not used in current implementation*/
sl@0
   110
		TUint32		iCentralHeaderOffset;
sl@0
   111
		
sl@0
   112
		/** The local offset of header in a compressed file*/
sl@0
   113
		TUint32	iLocalHeaderOffset;
sl@0
   114
		
sl@0
   115
		/** CRC with 32 bits length in a compressed file*/
sl@0
   116
		TUint32 iCRC32;
sl@0
   117
		
sl@0
   118
		/** The size of compressed file */	
sl@0
   119
		TUint32	iCompressedSize;
sl@0
   120
		
sl@0
   121
		/** The size of file without compressed*/
sl@0
   122
		TUint32	iUncompressedSize;
sl@0
   123
		};
sl@0
   124
		
sl@0
   125
protected:
sl@0
   126
	TInt FindCentralDirectoryTrailer(TUint32& offset);
sl@0
   127
    TInt ReadCentralDirectoryTrailer(TUint32 offset, TCentralDirectoryTrailer&);
sl@0
   128
    TInt ReadCentralDirectoryHeaderL(TCentralDirectoryHeader&, TMemberPointer&,
sl@0
   129
    	CCnvCharacterSetConverter* aConverter, TInt aConverterState);
sl@0
   130
sl@0
   131
	TInt ReadLocalHeader(TUint32, TLocalHeader&);
sl@0
   132
	
sl@0
   133
	const TMemberPointer* FindMemberPointer(const TDesC&, TBool);
sl@0
   134
	
sl@0
   135
    TInt LoadMemberPointersL(void);
sl@0
   136
    
sl@0
   137
	RZipFileMemberReaderStream*   MakeInputStreamL(TUint32, TUint32, TUint32, TUint32);
sl@0
   138
    CZipFileMember* MakeMemberL(TInt);
sl@0
   139
    CZipFileMember* MakeMemberL(const TMemberPointer&, const TLocalHeader&);
sl@0
   140
    
sl@0
   141
    // File I/O Support
sl@0
   142
    void OpenFileL(const TDesC& aFileName);
sl@0
   143
  
sl@0
   144
    TInt Read(TByte*, TUint32);
sl@0
   145
    TInt Read(TUint16&);
sl@0
   146
    TInt Read(TUint32&);
sl@0
   147
    
sl@0
   148
    TInt Seek(TInt);
sl@0
   149
sl@0
   150
	// Misc
sl@0
   151
	void DeleteMemberPointers(void);
sl@0
   152
sl@0
   153
private:
sl@0
   154
    const TDesC&				iFileName;
sl@0
   155
    TUint32 iFileLength;
sl@0
   156
	
sl@0
   157
	/** The central directory of ZIP File Trailer*/
sl@0
   158
	TCentralDirectoryTrailer iTrailer;
sl@0
   159
	
sl@0
   160
	/** The pointer to a a compressed file in a zipfile*/
sl@0
   161
	TMemberPointer*	iMemberPointers;
sl@0
   162
	
sl@0
   163
	RFs& iFs;
sl@0
   164
	
sl@0
   165
	/** The pointer to CData object created from a zip file*/
sl@0
   166
	ContentAccess::CData* iData;
sl@0
   167
	};
sl@0
   168
sl@0
   169
#endif /* !_ZIP_FILE_H_ */