epoc32/include/zipfile.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/zipfile.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/zipfile.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,170 @@
     1.4 -zipfile.h
     1.5 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// $Revision: 1.1 $
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#ifndef _ZIP_FILE_H_
    1.23 +#define _ZIP_FILE_H_
    1.24 +
    1.25 +#include <e32std.h>
    1.26 +#include <s32file.h>
    1.27 +#include <charconv.h>
    1.28 +
    1.29 +#include "localtypes.h"
    1.30 +#include "ziparchive.h"
    1.31 +#include "zipfilememberinputstream.h"
    1.32 +#include <zipfilememberiterator.h>
    1.33 +#include <zipfilemember.h>
    1.34 +
    1.35 +// Forward Class Declaration(s)
    1.36 +
    1.37 +class CFileInputStream;
    1.38 +class CZipFileMemberIterator;
    1.39 +class CZipFileMember;
    1.40 +namespace ContentAccess
    1.41 +	{
    1.42 +	class CData;
    1.43 +	}
    1.44 +
    1.45 +// End of Forward Class Declaration(s)
    1.46 +
    1.47 +
    1.48 +/** 
    1.49 +A CZipFile represents a ZIP archive contained in a single file. 
    1.50 +Multi file zip archives are not supported.
    1.51 +
    1.52 +@publishedAll
    1.53 +@released
    1.54 +*/
    1.55 +class CZipFile : public CZipArchive
    1.56 +	{
    1.57 +	friend class RZipFileMemberReaderStream;
    1.58 +	friend class CZipFileMemberIterator;
    1.59 +
    1.60 +	public:
    1.61 +		/**	ZipFile error enumeration.
    1.62 +		*/
    1.63 +		enum
    1.64 +			{
    1.65 +			/** Cannot read file directory in the archive file*/
    1.66 +			KZipFileError 		= KZipArchiveMinError - 1,
    1.67 +			
    1.68 +			/** File not found error. It is not used in current implemenation*/
    1.69 +			KZipFileNotFound	= KZipFileError - 1,
    1.70 +			
    1.71 +			/** File IO error.Any error occurs during a archive file is readed. 
    1.72 +			For examples, any error about reading number of disk,
    1.73 +			an offset of signature, or the content of file is non-readable.
    1.74 +			*/
    1.75 +			KZipFileIOError 	= KZipFileError - 2
    1.76 +			};
    1.77 +
    1.78 +	public:
    1.79 +		IMPORT_C static CZipFile* NewL(RFs& aFs, RFile& aFile);	
    1.80 +		IMPORT_C static CZipFile* NewL(RFs& aFs, const TDesC& aFileName);
    1.81 +		IMPORT_C CZipFile(RFs& aFs, const TDesC& aFileName);
    1.82 +		IMPORT_C TInt OpenL(void);
    1.83 +		IMPORT_C void Close(void);
    1.84 +		IMPORT_C virtual ~CZipFile();
    1.85 +
    1.86 +	protected:
    1.87 +		IMPORT_C void ConstructL(const TDesC& aFileName);
    1.88 +		
    1.89 +		IMPORT_C void ConstructL(RFile& aFile);
    1.90 +
    1.91 +	public:
    1.92 +		IMPORT_C TInt Size(TInt& aSize) const;
    1.93 +    
    1.94 +		IMPORT_C CZipFileMember* MemberL(const TDesC& aName);
    1.95 +		IMPORT_C CZipFileMember* CaseInsensitiveMemberL(const TDesC& aName);
    1.96 +		IMPORT_C CZipFileMember* CaseSensitiveOrCaseInsensitiveMemberL(const TDesC& aName);
    1.97 +		IMPORT_C TInt GetInputStreamL(const CZipFileMember* aMember, RZipFileMemberReaderStream*& aStream);
    1.98 +
    1.99 +  		IMPORT_C CZipFileMemberIterator* GetMembersL(void);
   1.100 +	
   1.101 +    
   1.102 +protected:
   1.103 +
   1.104 +	/** 
   1.105 +	Internal representation of a compressed file in a zipfile
   1.106 +	@publishedAll
   1.107 +	@released
   1.108 +	*/
   1.109 +	struct TMemberPointer
   1.110 +		{
   1.111 +		/** the name of a compressed file*/
   1.112 +		TFileName*  iName;
   1.113 +		
   1.114 +		/** Not used in current implementation*/
   1.115 +		TUint32		iCentralHeaderOffset;
   1.116 +		
   1.117 +		/** The local offset of header in a compressed file*/
   1.118 +		TUint32	iLocalHeaderOffset;
   1.119 +		
   1.120 +		/** CRC with 32 bits length in a compressed file*/
   1.121 +		TUint32 iCRC32;
   1.122 +		
   1.123 +		/** The size of compressed file */	
   1.124 +		TUint32	iCompressedSize;
   1.125 +		
   1.126 +		/** The size of file without compressed*/
   1.127 +		TUint32	iUncompressedSize;
   1.128 +		};
   1.129 +		
   1.130 +protected:
   1.131 +	TInt FindCentralDirectoryTrailer(TUint32& offset);
   1.132 +    TInt ReadCentralDirectoryTrailer(TUint32 offset, TCentralDirectoryTrailer&);
   1.133 +    TInt ReadCentralDirectoryHeaderL(TCentralDirectoryHeader&, TMemberPointer&,
   1.134 +    	CCnvCharacterSetConverter* aConverter, TInt aConverterState);
   1.135 +
   1.136 +	TInt ReadLocalHeader(TUint32, TLocalHeader&);
   1.137 +	
   1.138 +	const TMemberPointer* FindMemberPointer(const TDesC&, TBool);
   1.139 +	
   1.140 +    TInt LoadMemberPointersL(void);
   1.141 +    
   1.142 +	RZipFileMemberReaderStream*   MakeInputStreamL(TUint32, TUint32, TUint32, TUint32);
   1.143 +    CZipFileMember* MakeMemberL(TInt);
   1.144 +    CZipFileMember* MakeMemberL(const TMemberPointer&, const TLocalHeader&);
   1.145 +    
   1.146 +    // File I/O Support
   1.147 +    void OpenFileL(const TDesC& aFileName);
   1.148 +  
   1.149 +    TInt Read(TByte*, TUint32);
   1.150 +    TInt Read(TUint16&);
   1.151 +    TInt Read(TUint32&);
   1.152 +    
   1.153 +    TInt Seek(TInt);
   1.154 +
   1.155 +	// Misc
   1.156 +	void DeleteMemberPointers(void);
   1.157 +
   1.158 +private:
   1.159 +    const TDesC&				iFileName;
   1.160 +    TUint32 iFileLength;
   1.161 +	
   1.162 +	/** The central directory of ZIP File Trailer*/
   1.163 +	TCentralDirectoryTrailer iTrailer;
   1.164 +	
   1.165 +	/** The pointer to a a compressed file in a zipfile*/
   1.166 +	TMemberPointer*	iMemberPointers;
   1.167 +	
   1.168 +	RFs& iFs;
   1.169 +	
   1.170 +	/** The pointer to CData object created from a zip file*/
   1.171 +	ContentAccess::CData* iData;
   1.172 +	};
   1.173 +
   1.174 +#endif /* !_ZIP_FILE_H_ */