williamr@2: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #if !defined(__S32FILE_H__) williamr@2: #define __S32FILE_H__ williamr@2: #if !defined(__F32FILE_H__) williamr@2: #include williamr@2: #endif williamr@2: #if !defined(__S32STOR_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@2: #endif williamr@2: williamr@2: template williamr@2: class TCapture; williamr@2: class RPermanentFileStoreIter; williamr@2: williamr@2: /** A stream buffer hosted by a file. williamr@2: * @publishedAll williamr@2: * @released williamr@2: williamr@2: Instances of this class are used by file based persistent stores, i.e. CFileStore williamr@2: type objects. An RFileBuf object is associated with a file and the file is williamr@2: said to be attached to the stream buffer. williamr@2: williamr@2: An RFileBuf object is also used by RFileReadStream and RFileWriteStream objects williamr@2: to provide buffered file I/O. williamr@2: williamr@2: The stream buffer has intermediate buffering capabilities. williamr@2: williamr@2: When used as the basis for a file store, it hosts multiple streams through williamr@2: the TStreamExchange and RShareBuf classes. williamr@2: williamr@2: Open(), Close(), Attach(), Detach(), File() and Reattach() usage patterns: williamr@2: williamr@2: Pattern 1: RFileBuf owns the file williamr@2: step 1a: Open()/Create()/Temp() is used to connect the buffer to a file williamr@2: step 1b: Use the file buffer williamr@2: step 1c: Close() releases this resource. williamr@2: williamr@2: Pattern 2: RFile is opened elsewhere and ownership is handed over to RFileBuf williamr@2: This may happen if the file is already opened by another API, or from another process for example williamr@2: step 2a: Attach() is used to hand ownership of the opened file to the buffer. After Attach() the supplied file handle is NULLed. williamr@2: step 2b: Use the file buffer williamr@2: step 2c: Close() releases the file resource. williamr@2: williamr@2: Pattern 3: RFileBuf is used transiently to manage an existing opened file: williamr@2: step 3a: Attach() is used to bind the buffer to the already open file. After Attach() the supplied file handle is NULLed. williamr@2: step 3b: Use the file buffer williamr@2: step 3c: RFileBuf::File() is used to retrieve the file handle again, then Detach() is called to disconnect the buffer from the file. williamr@2: At this point, the destruction of the file buffer will have no effect on the file. The retrieved file handle in step 3c must be used to close the file. williamr@2: williamr@2: Pattern 4: Transient direct file access to a buffered file williamr@2: step 4a: RFileBuf::File() is used to retrieve the file handle. [Optional: Detach() is used to disconnect the file buffer] williamr@2: step 4b: Use the file directly. Note that writing to the file may cause coherency problems with the RFileBuf buffer - in which case you need to Reset() the buffer as well. williamr@2: step 4c: [Optional: Reattach() is used to hand the file back to the buffer]. Use of the buffer is resumed williamr@2: williamr@2: @see CFileStore williamr@2: @see RFileReadStream williamr@2: @see RFileWriteStream */ williamr@2: class RFileBuf : public TStreamBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C RFileBuf(); williamr@2: IMPORT_C RFileBuf(TInt aSize); williamr@2: RFileBuf(TCapture aCapture); williamr@2: IMPORT_C void Reset(); williamr@2: inline void Reset(TInt aSize); williamr@2: // williamr@2: IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: IMPORT_C void Attach(RFile& aFile,TInt aPos=0); williamr@2: IMPORT_C void Close(); williamr@2: inline void Detach(); williamr@2: inline void Reattach(RFile& aFile); williamr@2: // williamr@2: IMPORT_C void SetSizeL(TInt aSize); williamr@2: inline RFile& File() const; williamr@2: protected: williamr@2: IMPORT_C TInt UnderflowL(TInt aMaxLength); williamr@2: IMPORT_C void OverflowL(); williamr@2: IMPORT_C void DoRelease(); williamr@2: IMPORT_C void DoSynchL(); williamr@2: IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength); williamr@2: IMPORT_C TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus); williamr@2: IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength); williamr@2: IMPORT_C TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus); williamr@2: IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset); williamr@2: // williamr@2: inline void SetBuf(TRead,TUint8* aPtr,TUint8* anEnd); williamr@2: inline void SetBuf(TWrite,TUint8* aPtr,TUint8* anEnd); williamr@2: inline void SetBuf(TArea anArea,TUint8* aPtr,TUint8* anEnd); williamr@2: private: williamr@2: TUint8* AllocL(); williamr@2: void Free(); williamr@2: // williamr@2: void SetPos(TMark aMark,TInt aPos); williamr@2: inline void SetPos(TRead,TInt aPos); williamr@2: inline void SetPos(TWrite,TInt aPos); williamr@2: inline TInt Pos(TRead) const; williamr@2: inline TInt Pos(TWrite) const; williamr@2: inline TInt MovePos(TRead,TInt anOffset); williamr@2: inline TInt MovePos(TWrite,TInt anOffset); williamr@2: TInt FileReadL(TAny* aPtr,TInt aMaxLength); williamr@2: void FileWriteL(const TAny* aPtr,TInt aLength,TInt aSeek); williamr@2: void FileWriteL(const TAny* aPtr,TInt aLength); williamr@2: TInt EndL(); williamr@2: // williamr@2: inline TInt Lag(TRead) const; williamr@2: inline TInt Lag(TWrite) const; williamr@2: TInt Mark(TMark aMark) const; williamr@2: inline TInt Mark(TRead) const; williamr@2: inline TInt Mark(TWrite) const; williamr@2: inline TUint8* Limit(TWrite) const; williamr@2: inline void SetLimit(TWrite,TUint8* aLimit); williamr@2: inline TInt Span(TWrite) const; williamr@2: inline TInt Reach(TWrite) const; williamr@2: private: williamr@2: TUint8* iBase; williamr@2: TInt iSize; williamr@2: __MUTABLE RFile iFile; williamr@2: TInt iRPos; williamr@2: TInt iWPos; williamr@2: TInt iExt; williamr@2: TUint8* iWLim; williamr@2: friend class CFileStore; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * Supports the reading of a stream from a file. williamr@2: */ williamr@2: class RFileReadStream : public RReadStream williamr@2: { williamr@2: public: williamr@2: /** Constructs an empty read stream object. */ williamr@2: RFileReadStream() {} williamr@2: IMPORT_C RFileReadStream(RFile& aFile,TInt aPos=0); williamr@2: IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C void Attach(RFile& aFile,TInt aPos=0); williamr@2: private: williamr@2: RFileBuf iSource; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * Supports the writing of a stream to a file. williamr@2: */ williamr@2: class RFileWriteStream : public RWriteStream williamr@2: { williamr@2: public: williamr@2: /** Constructs an empty write stream object. */ williamr@2: RFileWriteStream() {} williamr@2: inline RFileWriteStream(const MExternalizer& anExter); williamr@2: IMPORT_C RFileWriteStream(RFile& aFile,TInt aPos=0); williamr@2: IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: IMPORT_C void Attach(RFile& aFile,TInt aPos=0); williamr@2: private: williamr@2: RFileBuf iSink; williamr@2: }; williamr@2: // williamr@2: class CFileStore; williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * A class containing a set of factory functions for opening an existing direct williamr@2: file store and an existing permanent file store identified using a Uidtype. williamr@2: */ williamr@2: class FileStoreFactory williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CFileStore* DirectLC(RFileBuf& aBuf,const TUidType& aType); williamr@2: IMPORT_C static CFileStore* PermanentLC(RFileBuf& aBuf,const TUidType& aType); williamr@2: }; williamr@2: // williamr@2: const TInt KDirectFileStoreLayoutUidValue=268435511; williamr@2: /** The value of the KPermanentFileStoreLayoutUidValue UID. */ williamr@2: const TInt KPermanentFileStoreLayoutUidValue=268435536; williamr@2: /** The UID that identifies a file store as being a direct file store. */ williamr@2: const TUid KDirectFileStoreLayoutUid={KDirectFileStoreLayoutUidValue}; williamr@2: /** The UID that identifies a file store as being a permanent file store. */ williamr@2: const TUid KPermanentFileStoreLayoutUid={KPermanentFileStoreLayoutUidValue}; williamr@2: // williamr@2: typedef CFileStore* (*TFileStoreFactoryFunction)(RFileBuf& aBuf,const TUidType& aType); williamr@2: // williamr@2: #define KDirectFileStoreFactoryFunction (&FileStoreFactory::DirectLC) williamr@2: #define KPermanentFileStoreFactoryFunction (&FileStoreFactory::PermanentLC) williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * File based persistent store abstract base class. williamr@2: williamr@2: The class encapsulates the basic behaviour of file based stores. File based williamr@2: stores are persistent stores, i.e. they have the ability to keep the external williamr@2: representation of objects for longer than the lifetime of the applications williamr@2: which created those objects. williamr@2: williamr@2: The class forms the base for the direct file store, CDirectFileStore, and williamr@2: the permanent file store, CPermanentFileStore. In general, it is sufficient williamr@2: for pointers to file based store objects to be of type CFileStore, rather williamr@2: than of the concrete file store type. williamr@2: williamr@2: Existing file stores can be opened using the member functions OpenL(), OpenLC(), williamr@2: FromL() and FromLC(). New file stores, however, must be created using the williamr@2: appropriate member function of the concrete type. williamr@2: */ williamr@2: class CFileStore : public CPersistentStore williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C static CFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: IMPORT_C static CFileStore* FromL(RFile& aFile); williamr@2: IMPORT_C static CFileStore* FromLC(RFile& aFile); williamr@2: // williamr@2: IMPORT_C static CFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[]); williamr@2: IMPORT_C static CFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[]); williamr@2: IMPORT_C static CFileStore* FromL(RFile& aFile,const TFileStoreFactoryFunction aFactory[]); williamr@2: IMPORT_C static CFileStore* FromLC(RFile& aFile,const TFileStoreFactoryFunction aFactory[]); williamr@2: // williamr@2: inline const TUidType& Type() const; williamr@2: IMPORT_C void SetTypeL(const TUidType& aType); williamr@2: /** Gets the UID that uniquely identifies the specific type of this file store. williamr@2: williamr@2: This function must be defined and implemented by classes derived from CFileStore. williamr@2: The direct file store, CDirectFileStore and the permanent file store, CPermanentFileStore williamr@2: both implement suitable functions. williamr@2: williamr@2: @return The UID that uniquely identifies the specific type of file store. williamr@2: @see KDirectFileStoreLayoutUid williamr@2: @see KPermanentFileStoreLayoutUid */ williamr@2: virtual TUid Layout() const=0; williamr@2: // williamr@2: inline void Reset(); williamr@2: inline void Reset(TInt aSize); williamr@2: inline void Detach(); williamr@2: inline void Reattach(RFile& aFile); williamr@2: inline RFile& File() const; williamr@2: // williamr@2: IMPORT_C void MarshalL(); williamr@2: IMPORT_C ~CFileStore(); williamr@2: protected: williamr@2: typedef CFileStore* (*TNewFunction)(RFile& aFile); williamr@2: protected: williamr@2: IMPORT_C static CFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,TFileStoreFactoryFunction aFunction); williamr@2: IMPORT_C static CFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode,TFileStoreFactoryFunction aFunction); williamr@2: IMPORT_C static CFileStore* CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); williamr@2: IMPORT_C static CFileStore* CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); williamr@2: IMPORT_C static CFileStore* ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); williamr@2: IMPORT_C static CFileStore* ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); williamr@2: IMPORT_C static CFileStore* TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode,TNewFunction aFunction); williamr@2: IMPORT_C static CFileStore* TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode,TNewFunction aFunction); williamr@2: // williamr@2: IMPORT_C static CFileStore* FromL(RFile& aFile,TFileStoreFactoryFunction aFunction); williamr@2: IMPORT_C static CFileStore* FromLC(RFile& aFile,TFileStoreFactoryFunction aFunction); williamr@2: IMPORT_C static CFileStore* NewL(RFile& aFile,TNewFunction aFunction); williamr@2: IMPORT_C static CFileStore* NewLC(RFile& aFile,TNewFunction aFunction); williamr@2: // williamr@2: IMPORT_C CFileStore(RFile& aFile); williamr@2: IMPORT_C CFileStore(RFileBuf& aBuf,const TUidType& aType); williamr@2: IMPORT_C void Destruct(); williamr@2: // williamr@2: inline TStreamExchange& Host() const; williamr@2: inline TBool IsHost(const MStreamBuf* aBuf) const; williamr@2: IMPORT_C void SynchL(); williamr@2: inline void SetSizeL(TInt aSize); williamr@2: IMPORT_C void ChangedL(); williamr@2: IMPORT_C void RefreshL(); williamr@2: // williamr@2: IMPORT_C void DoCommitL(); williamr@2: IMPORT_C void DoRevertL(); williamr@2: private: williamr@2: virtual void ExternalizeL(RWriteStream& aStream) const=0; williamr@2: virtual void InternalizeL(RReadStream& aStream)=0; williamr@2: // williamr@2: static CFileStore* DoNewL(RFile& aFile,TNewFunction aFunction); williamr@2: private: williamr@2: RFileBuf iBuf; williamr@2: TUidType iType; williamr@2: __MUTABLE TStreamExchange iHost; williamr@2: }; williamr@2: const TInt KFileStoreStartOffset=sizeof(TCheckedUid); williamr@2: #if defined(__NO_CLASS_CONSTS__) williamr@2: #define KFileStoreStart TStreamPos(KFileStoreStartOffset) williamr@2: #else williamr@2: const TStreamPos KFileStoreStart=TStreamPos(KFileStoreStartOffset); williamr@2: #endif williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * Direct file store. williamr@2: williamr@2: A direct file store implements a subset of the operations defined by the store williamr@2: abstract framework. Direct file stores allow streams to be created and objects williamr@2: externalised to them however once the streams have been committed and williamr@2: closed, they cannot subsequently be changed, i.e. streams cannot be replaced, williamr@2: deleted, extended or changed in any way. williamr@2: */ williamr@2: class CDirectFileStore : public CFileStore williamr@2: { williamr@2: public: williamr@2: inline static CDirectFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: inline static CDirectFileStore* TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: // williamr@2: inline static CDirectFileStore* FromL(RFile& aFile); williamr@2: inline static CDirectFileStore* FromLC(RFile& aFile); williamr@2: inline static CDirectFileStore* NewL(RFile& aFile); williamr@2: inline static CDirectFileStore* NewLC(RFile& aFile); williamr@2: // williamr@2: IMPORT_C TUid Layout() const; williamr@2: // williamr@2: IMPORT_C CDirectFileStore(RFile& aFile); williamr@2: IMPORT_C CDirectFileStore(RFileBuf& aBuf,const TUidType& aType); williamr@2: protected: williamr@2: IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const; williamr@2: IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId); williamr@2: private: williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; williamr@2: IMPORT_C void InternalizeL(RReadStream& aStream); williamr@2: IMPORT_C void DoSetRootL(TStreamId anId); williamr@2: // williamr@2: IMPORT_C static CFileStore* DoNewL(RFile& aFile); williamr@2: }; williamr@2: // williamr@2: class CPermanentStoreCoord; williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * Permanent file store. williamr@2: williamr@2: This type of store supports full manipulation of store contents. Existing williamr@2: streams within this type of store can be changed. williamr@2: */ williamr@2: class CPermanentFileStore : public CFileStore williamr@2: { williamr@2: friend class RPermanentFileStoreIter; williamr@2: public: williamr@2: inline static CPermanentFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: inline static CPermanentFileStore* TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: // williamr@2: inline static CPermanentFileStore* FromL(RFile& aFile); williamr@2: inline static CPermanentFileStore* FromLC(RFile& aFile); williamr@2: inline static CPermanentFileStore* NewL(RFile& aFile); williamr@2: inline static CPermanentFileStore* NewLC(RFile& aFile); williamr@2: // williamr@2: IMPORT_C TUid Layout() const; williamr@2: // williamr@2: IMPORT_C CPermanentFileStore(RFile& aFile); williamr@2: IMPORT_C CPermanentFileStore(RFileBuf& aBuf,const TUidType& aType); williamr@2: IMPORT_C void MarshalL(); williamr@2: IMPORT_C ~CPermanentFileStore(); williamr@2: protected: williamr@2: IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const; williamr@2: IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId); williamr@2: IMPORT_C MStreamBuf* DoWriteL(TStreamId anId); williamr@2: IMPORT_C MStreamBuf* DoReplaceL(TStreamId anId); williamr@2: private: williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; williamr@2: IMPORT_C void InternalizeL(RReadStream& aStream); williamr@2: IMPORT_C void DoSetRootL(TStreamId anId); williamr@2: IMPORT_C TStreamId DoExtendL(); williamr@2: IMPORT_C void DoDeleteL(TStreamId anId); williamr@2: IMPORT_C void DoCommitL(); williamr@2: IMPORT_C void DoRevertL(); williamr@2: IMPORT_C MIncrementalCollector* DoReclaimL(); williamr@2: IMPORT_C MIncrementalCollector* DoCompactL(); williamr@2: // williamr@2: inline CPermanentStoreCoord& Coord() const; williamr@2: CPermanentStoreCoord& CoordL() const; williamr@2: CPermanentStoreCoord& TrimL(); williamr@2: // williamr@2: IMPORT_C static CFileStore* DoNewL(RFile& aFile); williamr@2: private: williamr@2: __MUTABLE CPermanentStoreCoord* iCoord; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * File based dictionary store. williamr@2: williamr@2: A dictionary store is a store where a stream is accessed by UID, rather than williamr@2: directly by stream ID. A dictionary store contains streams in the usual way williamr@2: but, in addition, the root stream is a stream dictionary, i.e. a CStreamDictionary williamr@2: type. williamr@2: */ williamr@2: class CDictionaryFileStore : public CDictionaryStore williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CDictionaryFileStore* SystemL(RFs& aFs); williamr@2: IMPORT_C static CDictionaryFileStore* SystemLC(RFs& aFs); williamr@2: IMPORT_C static CDictionaryFileStore* OpenL(RFs& aFs,const TDesC& aName,TUid aUid3); williamr@2: IMPORT_C static CDictionaryFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUid aUid3); williamr@2: private: williamr@2: void ConstructL(RFs& aFs,const TDesC& aName,TUid aUid3); williamr@2: void CreateStoreL(RFile& aFile,const TUidType& aType); williamr@2: }; williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * Uses a file directly to implement the page pool interface MPagePool. williamr@2: williamr@2: The pages are written sequentially through the file. You should call Close() williamr@2: to release the file resource after CreateL(), OpenL(), ReplaceL() or Temp(). williamr@2: williamr@2: A file page pool uses a cache to store pages in-memory and to cache frequently williamr@2: accessed pages. You should provide a cache object (CPageCache) to the pool williamr@2: for this purpose. williamr@2: williamr@2: @see CPageCache williamr@2: @see RFile williamr@2: */ williamr@2: class RFilePagePool : public TCachePagePool williamr@2: { williamr@2: public: williamr@2: IMPORT_C RFilePagePool(); williamr@2: IMPORT_C RFilePagePool(CPageCache& aCache); williamr@2: // williamr@2: inline TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode); williamr@2: inline TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); williamr@2: inline void Attach(RFile& aFile); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C void Release(); williamr@2: IMPORT_C TInt Flush(); williamr@2: IMPORT_C void FlushL(); williamr@2: inline void Detach(); williamr@2: // williamr@2: inline RFile& File() const; williamr@2: protected: williamr@2: IMPORT_C TPageRef ExtendL(const TAny* aPage,TPageReclamation aReclamation); williamr@2: IMPORT_C void WriteL(TPageRef aRef,const TAny* aPage,TPageChange aChange); williamr@2: IMPORT_C void ReadL(TPageRef aRef,TAny* aPage); williamr@2: private: williamr@2: __MUTABLE RFile iFile; williamr@2: }; williamr@2: williamr@2: #include williamr@2: #endif