Update contrib.
     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".
 
     8 // Initial Contributors:
 
     9 // Nokia Corporation - initial contribution.
 
    24 #include <localtypes.h>
 
    25 #include <ziparchive.h>
 
    26 #include <zipfilememberinputstream.h>
 
    27 #include <zipfilememberiterator.h>
 
    28 #include <zipfilemember.h>
 
    30 // Forward Class Declaration(s)
 
    32 class CFileInputStream;
 
    33 class CZipFileMemberIterator;
 
    35 namespace ContentAccess
 
    40 // End of Forward Class Declaration(s)
 
    44 A CZipFile represents a ZIP archive contained in a single file. 
 
    45 Multi file zip archives are not supported.
 
    50 class CZipFile : public CZipArchive
 
    52 	friend class RZipFileMemberReaderStream;
 
    53 	friend class CZipFileMemberIterator;
 
    56 		/**	ZipFile error enumeration.
 
    60 			/** Cannot read file directory in the archive file*/
 
    61 			KZipFileError 		= KZipArchiveMinError - 1,
 
    63 			/** File not found error. It is not used in current implemenation*/
 
    64 			KZipFileNotFound	= KZipFileError - 1,
 
    66 			/** File IO error.Any error occurs during a archive file is readed. 
 
    67 			For examples, any error about reading number of disk,
 
    68 			an offset of signature, or the content of file is non-readable.
 
    70 			KZipFileIOError 	= KZipFileError - 2
 
    74 		IMPORT_C static CZipFile* NewL(RFs& aFs, RFile& aFile);	
 
    75 		IMPORT_C static CZipFile* NewL(RFs& aFs, const TDesC& aFileName);
 
    76 		IMPORT_C CZipFile(RFs& aFs, const TDesC& aFileName);
 
    77 		IMPORT_C TInt OpenL(void);
 
    78 		IMPORT_C void Close(void);
 
    79 		IMPORT_C virtual ~CZipFile();
 
    82 		IMPORT_C void ConstructL(const TDesC& aFileName);
 
    84 		IMPORT_C void ConstructL(RFile& aFile);
 
    87 		IMPORT_C TInt Size(TInt& aSize) const;
 
    89 		IMPORT_C CZipFileMember* MemberL(const TDesC& aName);
 
    90 		IMPORT_C CZipFileMember* CaseInsensitiveMemberL(const TDesC& aName);
 
    91 		IMPORT_C CZipFileMember* CaseSensitiveOrCaseInsensitiveMemberL(const TDesC& aName);
 
    92 		IMPORT_C TInt GetInputStreamL(const CZipFileMember* aMember, RZipFileMemberReaderStream*& aStream);
 
    94   		IMPORT_C CZipFileMemberIterator* GetMembersL(void);
 
   100 	Internal representation of a compressed file in a zipfile
 
   104 	struct TMemberPointer
 
   106 		/** the name of a compressed file*/
 
   109 		/** Not used in current implementation*/
 
   110 		TUint32		iCentralHeaderOffset;
 
   112 		/** The local offset of header in a compressed file*/
 
   113 		TUint32	iLocalHeaderOffset;
 
   115 		/** CRC with 32 bits length in a compressed file*/
 
   118 		/** The size of compressed file */	
 
   119 		TUint32	iCompressedSize;
 
   121 		/** The size of file without compressed*/
 
   122 		TUint32	iUncompressedSize;
 
   126 	TInt FindCentralDirectoryTrailer(TUint32& offset);
 
   127     TInt ReadCentralDirectoryTrailer(TUint32 offset, TCentralDirectoryTrailer&);
 
   128     TInt ReadCentralDirectoryHeaderL(TCentralDirectoryHeader&, TMemberPointer&,
 
   129     	CCnvCharacterSetConverter* aConverter, TInt aConverterState);
 
   131 	TInt ReadLocalHeader(TUint32, TLocalHeader&);
 
   133 	const TMemberPointer* FindMemberPointer(const TDesC&, TBool);
 
   135     TInt LoadMemberPointersL(void);
 
   137 	RZipFileMemberReaderStream*   MakeInputStreamL(TUint32, TUint32, TUint32, TUint32);
 
   138     CZipFileMember* MakeMemberL(TInt);
 
   139     CZipFileMember* MakeMemberL(const TMemberPointer&, const TLocalHeader&);
 
   142     void OpenFileL(const TDesC& aFileName);
 
   144     TInt Read(TByte*, TUint32);
 
   151 	void DeleteMemberPointers(void);
 
   154     const TDesC&				iFileName;
 
   157 	/** The central directory of ZIP File Trailer*/
 
   158 	TCentralDirectoryTrailer iTrailer;
 
   160 	/** The pointer to a a compressed file in a zipfile*/
 
   161 	TMemberPointer*	iMemberPointers;
 
   165 	/** The pointer to CData object created from a zip file*/
 
   166 	ContentAccess::CData* iData;
 
   169 #endif /* !_ZIP_FILE_H_ */