|
1 // Copyright (c) 2004-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __BAARCHIVEIMPL_H__ |
|
17 #define __BAARCHIVEIMPL_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <f32file.h> |
|
21 |
|
22 //Some useful constant |
|
23 const TUid KSpiFileUid={0x10205C2B}; |
|
24 const TUint KSpiFirstRscOffset=32; |
|
25 |
|
26 //Forward declarations |
|
27 class CResourceFile; |
|
28 |
|
29 /** |
|
30 Internal class to store the RSC name and the pointer to data |
|
31 @internalComponent |
|
32 */ |
|
33 NONSHARABLE_CLASS(TRscEntry) |
|
34 { |
|
35 public: |
|
36 TRscEntry(){} |
|
37 public: |
|
38 TPtrC8 iRscName; |
|
39 TPtrC8 iRscData; |
|
40 #ifdef __BASPITEST__ |
|
41 //used for testing purpose to check file association of each resource entry |
|
42 TPtrC iFileNamePtr; |
|
43 #endif |
|
44 }; |
|
45 |
|
46 /** Accesses a resource file and reads the resource data into a buffer. |
|
47 It is the implementation class for RResourceArchive |
|
48 @internalComponent |
|
49 @see RResourceArchive |
|
50 */ |
|
51 NONSHARABLE_CLASS(CResourceArchiveImpl) : public CBase |
|
52 { |
|
53 friend class RStaticPluginInfoTest; |
|
54 public: |
|
55 static CResourceArchiveImpl* NewL(RFs& aFs,const TDesC& aName); |
|
56 static CResourceArchiveImpl* NewL(RFs& aFs,const TDesC& aPath,const TDesC& aPattern); |
|
57 ~CResourceArchiveImpl(); |
|
58 CResourceFile* NextL(HBufC*& aRscFileName); |
|
59 void Reset(); |
|
60 TUid Type(); |
|
61 TBool NextResourceExist() const; |
|
62 |
|
63 private: |
|
64 void ConstructL(RFs& aFs,const TDesC& aName); |
|
65 void ConstructL(RFs& aFs,const TDesC& aPath,const TDesC& aPattern); |
|
66 //helper functions |
|
67 void OpenFileL(RFs& aFs,const TDesC& aName,TPtr8& aBufferPtr); |
|
68 void ValidateHeaderL(TPtr8& aBufferPtr); |
|
69 void ProcessEntryL(TPtr8& aBufferPtr,RArray<TPtrC8>& aHiddenList); |
|
70 CResourceArchiveImpl(); |
|
71 |
|
72 //determine the order in which entry is inserted |
|
73 static TInt EntryOrder(const TRscEntry& aSource,const TRscEntry& aTarget) |
|
74 { |
|
75 return (aSource.iRscName.CompareF(aTarget.iRscName)); |
|
76 } |
|
77 |
|
78 //determine the matching criteria for TPtrC8 |
|
79 static TBool MatchDescriptor(const TPtrC8& aSource,const TPtrC8& aTarget) |
|
80 { |
|
81 if (aSource.CompareF(aTarget)==0) |
|
82 return ETrue; |
|
83 return EFalse; |
|
84 } |
|
85 TInt32 LittleEndianFourByteInteger(const TDesC8& aBuffer,TInt aIndexOfFirstByte) const; |
|
86 private: |
|
87 //current rsc entry index to iRscList |
|
88 TInt iCurrentIndex; |
|
89 //type of spi file |
|
90 TUid iSpiFileType; |
|
91 //combined array of resources |
|
92 RArray<TRscEntry> iRscList; |
|
93 //list of all opened archive buffer |
|
94 RPointerArray<HBufC8> iSpiBufferArray; |
|
95 //list of all opened RChunk buffer |
|
96 RPointerArray<RChunk> iSpiChunkBufferArray; |
|
97 |
|
98 #ifdef __BASPITEST__ |
|
99 //used for testing purpose to check file association of each resource entry |
|
100 RArray<TFileName> iSpiFileNameArray; |
|
101 #endif |
|
102 }; |
|
103 |
|
104 #endif//__BAARCHIVEIMPL_H_ |