sl@0: // Copyright (c) 2001-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 the License "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: // f32\sfile\sf_cache.h sl@0: // sl@0: // sl@0: sl@0: #if !defined(__SF_CACHE_H__) sl@0: #define __SF_CACHE_H__ sl@0: #include "sf_image.h" sl@0: sl@0: // Cached information for each file sl@0: class TRomImageHeader; sl@0: class TDirectoryCacheHeader; sl@0: class TFileCacheRecord : public TImageInfo sl@0: { sl@0: public: sl@0: inline const TText8* NameText() const sl@0: { return (const TText8*)(this + 1); } sl@0: inline TPtrC8 Name() const sl@0: { return TPtrC8(NameText(), iNameLength); } sl@0: inline const TUint8* ExportDescription() const sl@0: { return NameText() + iNameLength; } sl@0: inline TBool ExtrasValid() const sl@0: { return iUid[0]; } sl@0: inline const TRomImageHeader* RomImageHeader() const sl@0: { return (const TRomImageHeader*)iUid[0]; } sl@0: inline void SetXIP(const TRomImageHeader* aR) sl@0: { iUid[0] = (TUint32)aR; } sl@0: inline TBool IsXIP() const sl@0: { return !(iUid[0]&3); } sl@0: static TInt Order(const TFileCacheRecord& aL, const TFileCacheRecord& aR); sl@0: void Dump(const char* aTitle); sl@0: public: sl@0: TInt GetImageInfo(RImageInfo& aInfo, const TDesC8& aPathName, TDirectoryCacheHeader* aDirHead, TInt aIndex); sl@0: public: sl@0: // UID1 must be EXE or DLL, 0 means extra information not valid sl@0: // UID1 nonzero and multiple of 4 means XIP in which case it points to the ROM image header sl@0: // iExportDirCount = number of bytes available for export description if iUid[0]=0 sl@0: // 8-bit name follows (store base+ext only, not version) sl@0: // export description follows name sl@0: }; sl@0: sl@0: class TFileCacheRecordSearch : public TFileCacheRecord sl@0: { sl@0: public: sl@0: TFileCacheRecordSearch(const TDesC8& aSearchName); sl@0: public: sl@0: TUint8 iSearchName[KMaxKernelName]; sl@0: }; sl@0: sl@0: // Record of a cached path. sl@0: class TPathListRecord sl@0: { sl@0: public: sl@0: static TPathListRecord* FindPathNameInList(const TDesC8& aPath); sl@0: inline const TDesC8* PathName() const sl@0: { return (const TDesC8*)(this + 1); } sl@0: static TInt Init(); sl@0: private: sl@0: void MoveToHead(); sl@0: static TPathListRecord* New(const TDesC8& aPath, TBool aKeep); sl@0: static TPathListRecord* DoFindPathNameInList(const TDesC8& aPath); sl@0: static TPathListRecord* AddToPathList(const TDesC8& aPath, TBool aKeep); sl@0: public: sl@0: TPathListRecord* iNext; sl@0: TBool iKeep; sl@0: // place a TBufC8 immediately after sl@0: public: sl@0: static TPathListRecord* First; sl@0: static TPathListRecord* LastStatic; sl@0: }; sl@0: sl@0: class TCacheHeapList sl@0: { sl@0: public: sl@0: TCacheHeapList(TInt aSize); sl@0: TAny* Allocate(TInt aBytes); sl@0: public: sl@0: TCacheHeapList* iNext; sl@0: private: sl@0: TInt iAllocated; sl@0: TInt iSize; sl@0: }; sl@0: sl@0: class TDirectoryCacheHeader; sl@0: NONSHARABLE_CLASS(CCacheNotifyDirChange) : public CActive sl@0: { sl@0: public: sl@0: CCacheNotifyDirChange(TDriveNumber aDrive, TDirectoryCacheHeader& aDirHead); sl@0: ~CCacheNotifyDirChange(); sl@0: TInt RegisterNotification(TPathListRecord* aPathRec, TNotifyType aType); sl@0: void DoCancel(); sl@0: void RunL(); sl@0: private: sl@0: TDriveNumber iDrive; sl@0: TDirectoryCacheHeader* iDirHead; sl@0: }; sl@0: sl@0: class TEntry; sl@0: class TDirectoryCacheHeader sl@0: { sl@0: public: sl@0: TDirectoryCacheHeader(TPathListRecord* aPath); sl@0: ~TDirectoryCacheHeader(); sl@0: TAny* Allocate(const TInt aBytes); sl@0: TFileCacheRecord* NewRecord(const TDesC8& aName, TUint32 aAttr, TUint32 aVer, const TEntry& aEntry); sl@0: TFileCacheRecord* NewRecord(const TFileCacheRecord& aRecord, TInt aEDS); sl@0: TInt PopulateFromDrive(const TDesC8& aPathName); sl@0: public: sl@0: TDirectoryCacheHeader* iNext; // list of directories per drive sl@0: TCacheHeapList* iFirstHeapBlock; // heap blocks to hold TFileCacheRecord entries sl@0: TPathListRecord* iPath; sl@0: TInt iRecordCount; // number of TFileCacheRecord entries sl@0: TFileCacheRecord** iCache; // array of pointers to TFileCacheRecord entries sl@0: TBool iNotPresent; sl@0: CCacheNotifyDirChange* iNotify; sl@0: private: sl@0: TInt GetMoreHeap(); sl@0: }; sl@0: sl@0: class TDriveCacheHeader sl@0: { sl@0: public: sl@0: TDriveCacheHeader(); sl@0: ~TDriveCacheHeader(); sl@0: TDirectoryCacheHeader* FindDirCache(TPathListRecord* aPath); sl@0: TInt GetDirCache(TDirectoryCacheHeader*& aCache, TPathListRecord* aPath, const TDesC8& aDriveAndPath); sl@0: public: sl@0: TDirectoryCacheHeader* iDirectoryList; // List of Directories sl@0: TUint iDriveAtt; sl@0: TInt iDriveNumber; sl@0: }; sl@0: sl@0: sl@0: void InitializeFileNameCache(); sl@0: TInt CheckLoaderCacheInit(); sl@0: sl@0: #endif