sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #ifndef _ZIP_FILE_H_ sl@0: #define _ZIP_FILE_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: // Forward Class Declaration(s) sl@0: sl@0: class CFileInputStream; sl@0: class CZipFileMemberIterator; sl@0: class CZipFileMember; sl@0: namespace ContentAccess sl@0: { sl@0: class CData; sl@0: } sl@0: sl@0: // End of Forward Class Declaration(s) sl@0: sl@0: sl@0: /** sl@0: A CZipFile represents a ZIP archive contained in a single file. sl@0: Multi file zip archives are not supported. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CZipFile : public CZipArchive sl@0: { sl@0: friend class RZipFileMemberReaderStream; sl@0: friend class CZipFileMemberIterator; sl@0: sl@0: public: sl@0: /** ZipFile error enumeration. sl@0: */ sl@0: enum sl@0: { sl@0: /** Cannot read file directory in the archive file*/ sl@0: KZipFileError = KZipArchiveMinError - 1, sl@0: sl@0: /** File not found error. It is not used in current implemenation*/ sl@0: KZipFileNotFound = KZipFileError - 1, sl@0: sl@0: /** File IO error.Any error occurs during a archive file is readed. sl@0: For examples, any error about reading number of disk, sl@0: an offset of signature, or the content of file is non-readable. sl@0: */ sl@0: KZipFileIOError = KZipFileError - 2 sl@0: }; sl@0: sl@0: public: sl@0: IMPORT_C static CZipFile* NewL(RFs& aFs, RFile& aFile); sl@0: IMPORT_C static CZipFile* NewL(RFs& aFs, const TDesC& aFileName); sl@0: IMPORT_C CZipFile(RFs& aFs, const TDesC& aFileName); sl@0: IMPORT_C TInt OpenL(void); sl@0: IMPORT_C void Close(void); sl@0: IMPORT_C virtual ~CZipFile(); sl@0: sl@0: protected: sl@0: IMPORT_C void ConstructL(const TDesC& aFileName); sl@0: sl@0: IMPORT_C void ConstructL(RFile& aFile); sl@0: sl@0: public: sl@0: IMPORT_C TInt Size(TInt& aSize) const; sl@0: sl@0: IMPORT_C CZipFileMember* MemberL(const TDesC& aName); sl@0: IMPORT_C CZipFileMember* CaseInsensitiveMemberL(const TDesC& aName); sl@0: IMPORT_C CZipFileMember* CaseSensitiveOrCaseInsensitiveMemberL(const TDesC& aName); sl@0: IMPORT_C TInt GetInputStreamL(const CZipFileMember* aMember, RZipFileMemberReaderStream*& aStream); sl@0: sl@0: IMPORT_C CZipFileMemberIterator* GetMembersL(void); sl@0: sl@0: sl@0: protected: sl@0: sl@0: /** sl@0: Internal representation of a compressed file in a zipfile sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: struct TMemberPointer sl@0: { sl@0: /** the name of a compressed file*/ sl@0: TFileName* iName; sl@0: sl@0: /** Not used in current implementation*/ sl@0: TUint32 iCentralHeaderOffset; sl@0: sl@0: /** The local offset of header in a compressed file*/ sl@0: TUint32 iLocalHeaderOffset; sl@0: sl@0: /** CRC with 32 bits length in a compressed file*/ sl@0: TUint32 iCRC32; sl@0: sl@0: /** The size of compressed file */ sl@0: TUint32 iCompressedSize; sl@0: sl@0: /** The size of file without compressed*/ sl@0: TUint32 iUncompressedSize; sl@0: }; sl@0: sl@0: protected: sl@0: TInt FindCentralDirectoryTrailer(TUint32& offset); sl@0: TInt ReadCentralDirectoryTrailer(TUint32 offset, TCentralDirectoryTrailer&); sl@0: TInt ReadCentralDirectoryHeaderL(TCentralDirectoryHeader&, TMemberPointer&, sl@0: CCnvCharacterSetConverter* aConverter, TInt aConverterState); sl@0: sl@0: TInt ReadLocalHeader(TUint32, TLocalHeader&); sl@0: sl@0: const TMemberPointer* FindMemberPointer(const TDesC&, TBool); sl@0: sl@0: TInt LoadMemberPointersL(void); sl@0: sl@0: RZipFileMemberReaderStream* MakeInputStreamL(TUint32, TUint32, TUint32, TUint32); sl@0: CZipFileMember* MakeMemberL(TInt); sl@0: CZipFileMember* MakeMemberL(const TMemberPointer&, const TLocalHeader&); sl@0: sl@0: // File I/O Support sl@0: void OpenFileL(const TDesC& aFileName); sl@0: sl@0: TInt Read(TByte*, TUint32); sl@0: TInt Read(TUint16&); sl@0: TInt Read(TUint32&); sl@0: sl@0: TInt Seek(TInt); sl@0: sl@0: // Misc sl@0: void DeleteMemberPointers(void); sl@0: sl@0: private: sl@0: const TDesC& iFileName; sl@0: TUint32 iFileLength; sl@0: sl@0: /** The central directory of ZIP File Trailer*/ sl@0: TCentralDirectoryTrailer iTrailer; sl@0: sl@0: /** The pointer to a a compressed file in a zipfile*/ sl@0: TMemberPointer* iMemberPointers; sl@0: sl@0: RFs& iFs; sl@0: sl@0: /** The pointer to CData object created from a zip file*/ sl@0: ContentAccess::CData* iData; sl@0: }; sl@0: sl@0: #endif /* !_ZIP_FILE_H_ */