| 0 |      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".
 | 
|  |      7 | //
 | 
|  |      8 | // Initial Contributors:
 | 
|  |      9 | // Nokia Corporation - initial contribution.
 | 
|  |     10 | //
 | 
|  |     11 | // Contributors:
 | 
|  |     12 | //
 | 
|  |     13 | // Description:
 | 
|  |     14 | // f32\sfile\sf_cache.h
 | 
|  |     15 | // 
 | 
|  |     16 | //
 | 
|  |     17 | 
 | 
|  |     18 | #if !defined(__SF_CACHE_H__)
 | 
|  |     19 | #define __SF_CACHE_H__
 | 
|  |     20 | #include "sf_image.h"
 | 
|  |     21 | 
 | 
|  |     22 | // Cached information for each file
 | 
|  |     23 | class TRomImageHeader;
 | 
|  |     24 | class TDirectoryCacheHeader;
 | 
|  |     25 | class TFileCacheRecord : public TImageInfo
 | 
|  |     26 | 	{
 | 
|  |     27 | public:
 | 
|  |     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
 | 
|  |     35 | 		{ return iUid[0]; }
 | 
|  |     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);
 | 
|  |     44 | public:
 | 
|  |     45 | 	TInt GetImageInfo(RImageInfo& aInfo, const TDesC8& aPathName, TDirectoryCacheHeader* aDirHead, TInt aIndex);
 | 
|  |     46 | public:
 | 
|  |     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
 | 
|  |     52 | 	};
 | 
|  |     53 | 
 | 
|  |     54 | class TFileCacheRecordSearch : public TFileCacheRecord
 | 
|  |     55 | 	{
 | 
|  |     56 | public:
 | 
|  |     57 | 	TFileCacheRecordSearch(const TDesC8& aSearchName);
 | 
|  |     58 | public:
 | 
|  |     59 | 	TUint8 iSearchName[KMaxKernelName];
 | 
|  |     60 | 	};
 | 
|  |     61 | 
 | 
|  |     62 | // Record of a cached path.
 | 
|  |     63 | class TPathListRecord
 | 
|  |     64 | 	{
 | 
|  |     65 | public:
 | 
|  |     66 | 	static TPathListRecord* FindPathNameInList(const TDesC8& aPath);
 | 
|  |     67 | 	inline const TDesC8* PathName() const
 | 
|  |     68 | 		{ return (const TDesC8*)(this + 1); }
 | 
|  |     69 | 	static TInt Init();
 | 
|  |     70 | private:
 | 
|  |     71 | 	void MoveToHead();
 | 
|  |     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);
 | 
|  |     75 | public:
 | 
|  |     76 | 	TPathListRecord* iNext;
 | 
|  |     77 | 	TBool iKeep;
 | 
|  |     78 | 	// place a TBufC8 immediately after
 | 
|  |     79 | public:
 | 
|  |     80 | 	static TPathListRecord* First;
 | 
|  |     81 | 	static TPathListRecord* LastStatic;
 | 
|  |     82 | 	};
 | 
|  |     83 | 
 | 
|  |     84 | class TCacheHeapList
 | 
|  |     85 | 	{
 | 
|  |     86 | public:
 | 
|  |     87 | 	TCacheHeapList(TInt aSize);
 | 
|  |     88 | 	TAny* Allocate(TInt aBytes);
 | 
|  |     89 | public:
 | 
|  |     90 | 	TCacheHeapList* iNext;
 | 
|  |     91 | private:
 | 
|  |     92 | 	TInt iAllocated;
 | 
|  |     93 | 	TInt iSize;
 | 
|  |     94 | 	};
 | 
|  |     95 | 
 | 
|  |     96 | class TDirectoryCacheHeader;
 | 
|  |     97 | NONSHARABLE_CLASS(CCacheNotifyDirChange) : public CActive
 | 
|  |     98 | 	{
 | 
|  |     99 | public:
 | 
|  |    100 | 	CCacheNotifyDirChange(TDriveNumber aDrive, TDirectoryCacheHeader& aDirHead);
 | 
|  |    101 | 	~CCacheNotifyDirChange();
 | 
|  |    102 | 	TInt RegisterNotification(TPathListRecord* aPathRec, TNotifyType aType);
 | 
|  |    103 | 	void DoCancel();
 | 
|  |    104 | 	void RunL();
 | 
|  |    105 | private:
 | 
|  |    106 |     TDriveNumber iDrive;
 | 
|  |    107 | 	TDirectoryCacheHeader* iDirHead;
 | 
|  |    108 | 	};
 | 
|  |    109 | 
 | 
|  |    110 | class TEntry;
 | 
|  |    111 | class TDirectoryCacheHeader
 | 
|  |    112 | 	{
 | 
|  |    113 | public:
 | 
|  |    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);
 | 
|  |    120 | public:
 | 
|  |    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
 | 
|  |    126 | 	TBool iNotPresent;
 | 
|  |    127 | 	CCacheNotifyDirChange* iNotify;
 | 
|  |    128 | private:
 | 
|  |    129 | 	TInt GetMoreHeap();
 | 
|  |    130 | 	};
 | 
|  |    131 | 
 | 
|  |    132 | class TDriveCacheHeader
 | 
|  |    133 | 	{
 | 
|  |    134 | public:
 | 
|  |    135 | 	TDriveCacheHeader();
 | 
|  |    136 | 	~TDriveCacheHeader();
 | 
|  |    137 | 	TDirectoryCacheHeader* FindDirCache(TPathListRecord* aPath);
 | 
|  |    138 | 	TInt GetDirCache(TDirectoryCacheHeader*& aCache, TPathListRecord* aPath, const TDesC8& aDriveAndPath);
 | 
|  |    139 | public:
 | 
|  |    140 | 	TDirectoryCacheHeader* iDirectoryList; // List of Directories
 | 
|  |    141 | 	TUint iDriveAtt;
 | 
|  |    142 | 	TInt iDriveNumber;
 | 
|  |    143 | 	};
 | 
|  |    144 | 
 | 
|  |    145 | 
 | 
|  |    146 | void InitializeFileNameCache();
 | 
|  |    147 | TInt CheckLoaderCacheInit();
 | 
|  |    148 | 
 | 
|  |    149 | #endif
 |