os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_cache.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32\sfile\sf_cache.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#if !defined(__SF_CACHE_H__)
sl@0
    19
#define __SF_CACHE_H__
sl@0
    20
#include "sf_image.h"
sl@0
    21
sl@0
    22
// Cached information for each file
sl@0
    23
class TRomImageHeader;
sl@0
    24
class TDirectoryCacheHeader;
sl@0
    25
class TFileCacheRecord : public TImageInfo
sl@0
    26
	{
sl@0
    27
public:
sl@0
    28
	inline const TText8* NameText() const
sl@0
    29
		{ return (const TText8*)(this + 1); }
sl@0
    30
	inline TPtrC8 Name() const
sl@0
    31
		{ return TPtrC8(NameText(), iNameLength); }
sl@0
    32
	inline const TUint8* ExportDescription() const
sl@0
    33
		{ return NameText() + iNameLength; }
sl@0
    34
	inline TBool ExtrasValid() const
sl@0
    35
		{ return iUid[0]; }
sl@0
    36
	inline const TRomImageHeader* RomImageHeader() const
sl@0
    37
		{ return (const TRomImageHeader*)iUid[0]; }
sl@0
    38
	inline void SetXIP(const TRomImageHeader* aR)
sl@0
    39
		{ iUid[0] = (TUint32)aR; }
sl@0
    40
	inline TBool IsXIP() const
sl@0
    41
		{ return !(iUid[0]&3); }
sl@0
    42
	static TInt Order(const TFileCacheRecord& aL, const TFileCacheRecord& aR);
sl@0
    43
	void Dump(const char* aTitle);
sl@0
    44
public:
sl@0
    45
	TInt GetImageInfo(RImageInfo& aInfo, const TDesC8& aPathName, TDirectoryCacheHeader* aDirHead, TInt aIndex);
sl@0
    46
public:
sl@0
    47
	// UID1 must be EXE or DLL, 0 means extra information not valid
sl@0
    48
	// UID1 nonzero and multiple of 4 means XIP in which case it points to the ROM image header
sl@0
    49
	// iExportDirCount = number of bytes available for export description if iUid[0]=0
sl@0
    50
	// 8-bit name follows (store base+ext only, not version)
sl@0
    51
	// export description follows name
sl@0
    52
	};
sl@0
    53
sl@0
    54
class TFileCacheRecordSearch : public TFileCacheRecord
sl@0
    55
	{
sl@0
    56
public:
sl@0
    57
	TFileCacheRecordSearch(const TDesC8& aSearchName);
sl@0
    58
public:
sl@0
    59
	TUint8 iSearchName[KMaxKernelName];
sl@0
    60
	};
sl@0
    61
sl@0
    62
// Record of a cached path.
sl@0
    63
class TPathListRecord
sl@0
    64
	{
sl@0
    65
public:
sl@0
    66
	static TPathListRecord* FindPathNameInList(const TDesC8& aPath);
sl@0
    67
	inline const TDesC8* PathName() const
sl@0
    68
		{ return (const TDesC8*)(this + 1); }
sl@0
    69
	static TInt Init();
sl@0
    70
private:
sl@0
    71
	void MoveToHead();
sl@0
    72
	static TPathListRecord* New(const TDesC8& aPath, TBool aKeep);
sl@0
    73
	static TPathListRecord* DoFindPathNameInList(const TDesC8& aPath);
sl@0
    74
	static TPathListRecord* AddToPathList(const TDesC8& aPath, TBool aKeep);
sl@0
    75
public:
sl@0
    76
	TPathListRecord* iNext;
sl@0
    77
	TBool iKeep;
sl@0
    78
	// place a TBufC8 immediately after
sl@0
    79
public:
sl@0
    80
	static TPathListRecord* First;
sl@0
    81
	static TPathListRecord* LastStatic;
sl@0
    82
	};
sl@0
    83
sl@0
    84
class TCacheHeapList
sl@0
    85
	{
sl@0
    86
public:
sl@0
    87
	TCacheHeapList(TInt aSize);
sl@0
    88
	TAny* Allocate(TInt aBytes);
sl@0
    89
public:
sl@0
    90
	TCacheHeapList* iNext;
sl@0
    91
private:
sl@0
    92
	TInt iAllocated;
sl@0
    93
	TInt iSize;
sl@0
    94
	};
sl@0
    95
sl@0
    96
class TDirectoryCacheHeader;
sl@0
    97
NONSHARABLE_CLASS(CCacheNotifyDirChange) : public CActive
sl@0
    98
	{
sl@0
    99
public:
sl@0
   100
	CCacheNotifyDirChange(TDriveNumber aDrive, TDirectoryCacheHeader& aDirHead);
sl@0
   101
	~CCacheNotifyDirChange();
sl@0
   102
	TInt RegisterNotification(TPathListRecord* aPathRec, TNotifyType aType);
sl@0
   103
	void DoCancel();
sl@0
   104
	void RunL();
sl@0
   105
private:
sl@0
   106
    TDriveNumber iDrive;
sl@0
   107
	TDirectoryCacheHeader* iDirHead;
sl@0
   108
	};
sl@0
   109
sl@0
   110
class TEntry;
sl@0
   111
class TDirectoryCacheHeader
sl@0
   112
	{
sl@0
   113
public:
sl@0
   114
	TDirectoryCacheHeader(TPathListRecord* aPath);
sl@0
   115
	~TDirectoryCacheHeader();
sl@0
   116
	TAny* Allocate(const TInt aBytes);
sl@0
   117
	TFileCacheRecord* NewRecord(const TDesC8& aName, TUint32 aAttr, TUint32 aVer, const TEntry& aEntry);
sl@0
   118
	TFileCacheRecord* NewRecord(const TFileCacheRecord& aRecord, TInt aEDS);
sl@0
   119
	TInt PopulateFromDrive(const TDesC8& aPathName);
sl@0
   120
public:
sl@0
   121
	TDirectoryCacheHeader* iNext;		// list of directories per drive
sl@0
   122
	TCacheHeapList* iFirstHeapBlock;	// heap blocks to hold TFileCacheRecord entries
sl@0
   123
	TPathListRecord* iPath;
sl@0
   124
	TInt iRecordCount;					// number of TFileCacheRecord entries
sl@0
   125
	TFileCacheRecord** iCache;			// array of pointers to TFileCacheRecord entries
sl@0
   126
	TBool iNotPresent;
sl@0
   127
	CCacheNotifyDirChange* iNotify;
sl@0
   128
private:
sl@0
   129
	TInt GetMoreHeap();
sl@0
   130
	};
sl@0
   131
sl@0
   132
class TDriveCacheHeader
sl@0
   133
	{
sl@0
   134
public:
sl@0
   135
	TDriveCacheHeader();
sl@0
   136
	~TDriveCacheHeader();
sl@0
   137
	TDirectoryCacheHeader* FindDirCache(TPathListRecord* aPath);
sl@0
   138
	TInt GetDirCache(TDirectoryCacheHeader*& aCache, TPathListRecord* aPath, const TDesC8& aDriveAndPath);
sl@0
   139
public:
sl@0
   140
	TDirectoryCacheHeader* iDirectoryList; // List of Directories
sl@0
   141
	TUint iDriveAtt;
sl@0
   142
	TInt iDriveNumber;
sl@0
   143
	};
sl@0
   144
sl@0
   145
sl@0
   146
void InitializeFileNameCache();
sl@0
   147
TInt CheckLoaderCacheInit();
sl@0
   148
sl@0
   149
#endif