Update contrib.
1 // Copyright (c) 2001-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 the License "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.
14 // f32\sfile\sf_cache.h
18 #if !defined(__SF_CACHE_H__)
19 #define __SF_CACHE_H__
22 // Cached information for each file
23 class TRomImageHeader;
24 class TDirectoryCacheHeader;
25 class TFileCacheRecord : public TImageInfo
28 inline const TText8* NameText() const
29 { return (const TText8*)(this + 1); }
30 inline TPtrC8 Name() const
31 { return TPtrC8(NameText(), iNameLength); }
32 inline const TUint8* ExportDescription() const
33 { return NameText() + iNameLength; }
34 inline TBool ExtrasValid() const
36 inline const TRomImageHeader* RomImageHeader() const
37 { return (const TRomImageHeader*)iUid[0]; }
38 inline void SetXIP(const TRomImageHeader* aR)
39 { iUid[0] = (TUint32)aR; }
40 inline TBool IsXIP() const
41 { return !(iUid[0]&3); }
42 static TInt Order(const TFileCacheRecord& aL, const TFileCacheRecord& aR);
43 void Dump(const char* aTitle);
45 TInt GetImageInfo(RImageInfo& aInfo, const TDesC8& aPathName, TDirectoryCacheHeader* aDirHead, TInt aIndex);
47 // UID1 must be EXE or DLL, 0 means extra information not valid
48 // UID1 nonzero and multiple of 4 means XIP in which case it points to the ROM image header
49 // iExportDirCount = number of bytes available for export description if iUid[0]=0
50 // 8-bit name follows (store base+ext only, not version)
51 // export description follows name
54 class TFileCacheRecordSearch : public TFileCacheRecord
57 TFileCacheRecordSearch(const TDesC8& aSearchName);
59 TUint8 iSearchName[KMaxKernelName];
62 // Record of a cached path.
66 static TPathListRecord* FindPathNameInList(const TDesC8& aPath);
67 inline const TDesC8* PathName() const
68 { return (const TDesC8*)(this + 1); }
72 static TPathListRecord* New(const TDesC8& aPath, TBool aKeep);
73 static TPathListRecord* DoFindPathNameInList(const TDesC8& aPath);
74 static TPathListRecord* AddToPathList(const TDesC8& aPath, TBool aKeep);
76 TPathListRecord* iNext;
78 // place a TBufC8 immediately after
80 static TPathListRecord* First;
81 static TPathListRecord* LastStatic;
87 TCacheHeapList(TInt aSize);
88 TAny* Allocate(TInt aBytes);
90 TCacheHeapList* iNext;
96 class TDirectoryCacheHeader;
97 NONSHARABLE_CLASS(CCacheNotifyDirChange) : public CActive
100 CCacheNotifyDirChange(TDriveNumber aDrive, TDirectoryCacheHeader& aDirHead);
101 ~CCacheNotifyDirChange();
102 TInt RegisterNotification(TPathListRecord* aPathRec, TNotifyType aType);
107 TDirectoryCacheHeader* iDirHead;
111 class TDirectoryCacheHeader
114 TDirectoryCacheHeader(TPathListRecord* aPath);
115 ~TDirectoryCacheHeader();
116 TAny* Allocate(const TInt aBytes);
117 TFileCacheRecord* NewRecord(const TDesC8& aName, TUint32 aAttr, TUint32 aVer, const TEntry& aEntry);
118 TFileCacheRecord* NewRecord(const TFileCacheRecord& aRecord, TInt aEDS);
119 TInt PopulateFromDrive(const TDesC8& aPathName);
121 TDirectoryCacheHeader* iNext; // list of directories per drive
122 TCacheHeapList* iFirstHeapBlock; // heap blocks to hold TFileCacheRecord entries
123 TPathListRecord* iPath;
124 TInt iRecordCount; // number of TFileCacheRecord entries
125 TFileCacheRecord** iCache; // array of pointers to TFileCacheRecord entries
127 CCacheNotifyDirChange* iNotify;
132 class TDriveCacheHeader
136 ~TDriveCacheHeader();
137 TDirectoryCacheHeader* FindDirCache(TPathListRecord* aPath);
138 TInt GetDirCache(TDirectoryCacheHeader*& aCache, TPathListRecord* aPath, const TDesC8& aDriveAndPath);
140 TDirectoryCacheHeader* iDirectoryList; // List of Directories
146 void InitializeFileNameCache();
147 TInt CheckLoaderCacheInit();