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