CFileStore Class Reference

class CFileStore : public CPersistentStore

File based persistent store abstract base class.

The class encapsulates the basic behaviour of file based stores. File based stores are persistent stores, i.e. they have the ability to keep the external representation of objects for longer than the lifetime of the applications which created those objects.

The class forms the base for the direct file store, CDirectFileStore, and the permanent file store, CPermanentFileStore. In general, it is sufficient for pointers to file based store objects to be of type CFileStore, rather than of the concrete file store type.

Existing file stores can be opened using the member functions OpenL(), OpenLC(), FromL() and FromLC(). New file stores, however, must be created using the appropriate member function of the concrete type.

Inherits from

Public Member Functions
~CFileStore()
RFile &File()
IMPORT_C CFileStore *FromLC(RFile &)
IMPORT_C CFileStore *FromLC(RFile &, const TFileStoreFactoryFunction)
TUid Layout()
IMPORT_C voidMarshalL()
IMPORT_C CFileStore *OpenL(RFs &, const TDesC &, TUint)
IMPORT_C CFileStore *OpenL(RFs &, const TDesC &, TUint, const TFileStoreFactoryFunction)
IMPORT_C CFileStore *OpenLC(RFs &, const TDesC &, TUint)
IMPORT_C CFileStore *OpenLC(RFs &, const TDesC &, TUint, const TFileStoreFactoryFunction)
voidReattach(RFile &)
voidReset()
voidReset(TInt)
IMPORT_C voidSetTypeL(const TUidType &)
const TUidType &Type()
Protected Member Functions
CFileStore(RFile &)
IMPORT_C CFileStore *CreateLC(RFs &, const TDesC &, TUint, TNewFunction)
IMPORT_C voidDestruct()
IMPORT_C voidDoCommitL()
IMPORT_C voidDoRevertL()
IMPORT_C CFileStore *FromL(RFile &, TFileStoreFactoryFunction)
IMPORT_C CFileStore *FromLC(RFile &, TFileStoreFactoryFunction)
TStreamExchange &Host()
TBool IsHost(const MStreamBuf *)
IMPORT_C CFileStore *NewL(RFile &, TNewFunction)
IMPORT_C CFileStore *NewLC(RFile &, TNewFunction)
IMPORT_C CFileStore *OpenL(RFs &, const TDesC &, TUint, TFileStoreFactoryFunction)
IMPORT_C CFileStore *OpenLC(RFs &, const TDesC &, TUint, TFileStoreFactoryFunction)
IMPORT_C voidRefreshL()
IMPORT_C CFileStore *ReplaceL(RFs &, const TDesC &, TUint, TNewFunction)
IMPORT_C CFileStore *ReplaceLC(RFs &, const TDesC &, TUint, TNewFunction)
voidSetSizeL(TInt)
IMPORT_C voidSynchL()
IMPORT_C CFileStore *TempL(RFs &, const TDesC &, TFileName &, TUint, TNewFunction)
IMPORT_C CFileStore *TempLC(RFs &, const TDesC &, TFileName &, TUint, TNewFunction)
Private Member Functions
CFileStore *DoNewL(RFile &, TNewFunction)
voidExternalizeL(RWriteStream &)
voidInternalizeL(RReadStream &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
CPersistentStore::CPersistentStore()
CPersistentStore::Root()const
CPersistentStore::SetRootL(TStreamId)
CStreamStore::Commit()
CStreamStore::CommitL()
CStreamStore::CompactL()
CStreamStore::Delete(TStreamId)
CStreamStore::DeleteL(TStreamId)
CStreamStore::ExtendL()
CStreamStore::ReclaimL()
CStreamStore::Revert()
CStreamStore::RevertL()
Protected Member Type Definitions
typedef CFileStore *(* TNewFunction
Private Attributes
RFileBuf iBuf
__MUTABLE TStreamExchangeiHost
TUidType iType
Inherited Attributes
CPersistentStore::iRoot

Constructor & Destructor Documentation

CFileStore(RFile &)

IMPORT_CCFileStore(RFile &aFile)[protected]

Parameters

RFile & aFile

~CFileStore()

IMPORT_C~CFileStore()

Frees resources owned by the object, prior to its destruction. In particular, it closes the associated file.

Member Functions Documentation

CreateLC(RFs &, const TDesC &, TUint, TNewFunction)

IMPORT_C CFileStore *CreateLC(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
TNewFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TNewFunction aFunction

Destruct()

IMPORT_C voidDestruct()[protected]

DoCommitL()

IMPORT_C voidDoCommitL()[protected, virtual]

Commits any changes to the store. For a store that provides atomic updates, this writes all of the pending updates to the to the permanent storage medium. After committing the store contains all or none of the updates since the last commit/revert.

This function provides the implementation for the public CommitL() function.

DoNewL(RFile &, TNewFunction)

CFileStore *DoNewL(RFile &aFile,
TNewFunctionaFunction
)[private, static]

Parameters

RFile & aFile
TNewFunction aFunction

DoRevertL()

IMPORT_C voidDoRevertL()[protected, virtual]

Discards any pending changes to the store. This includes all changes which have not been committed to a permanent storage medium.

This function provides the implementation for the public Revert() function.

Note:

The function need only be implemented by stores that provide atomic updates, as revert has no meaning for other implementations.

ExternalizeL(RWriteStream &)

voidExternalizeL(RWriteStream &aStream)const [private, pure virtual]

Parameters

RWriteStream & aStream

File()

RFile &File()const [inline]

FromL(RFile &, TFileStoreFactoryFunction)

IMPORT_C CFileStore *FromL(RFile &aFile,
TFileStoreFactoryFunctionaFunction
)[protected, static]

Parameters

RFile & aFile
TFileStoreFactoryFunction aFunction

FromLC(RFile &)

IMPORT_C CFileStore *FromLC(RFile &aFile)[static]

Constructs a file store object from an opened file, and places the pointer onto the cleanup stack.

The file must already be open before calling this function.

The resulting file store object is of concrete type, i.e. either CDirectFileStore or CPermanentFileStore. The specific type is determined from the layout information held in the file store.

Note that ownership of the file passes to the store. The referenced RFile is cleared and is no longer valid:

CFileStore::Layout()

Parameters

RFile & aFileA reference to the opened file.

FromLC(RFile &, const TFileStoreFactoryFunction)

IMPORT_C CFileStore *FromLC(RFile &aFile,
const TFileStoreFactoryFunctionaFactory
)[static]

Parameters

RFile & aFile
const TFileStoreFactoryFunction aFactory

FromLC(RFile &, TFileStoreFactoryFunction)

IMPORT_C CFileStore *FromLC(RFile &aFile,
TFileStoreFactoryFunctionaFunction
)[protected, static]

Parameters

RFile & aFile
TFileStoreFactoryFunction aFunction

Host()

TStreamExchange &Host()const [protected, inline]

InternalizeL(RReadStream &)

voidInternalizeL(RReadStream &aStream)[private, pure virtual]

Parameters

RReadStream & aStream

IsHost(const MStreamBuf *)

TBool IsHost(const MStreamBuf *aBuf)const [protected, inline]

Parameters

const MStreamBuf * aBuf

Layout()

TUid Layout()const [pure virtual]

Gets the UID that uniquely identifies the specific type of this file store.

This function must be defined and implemented by classes derived from CFileStore. The direct file store, CDirectFileStore and the permanent file store, CPermanentFileStore both implement suitable functions.

KDirectFileStoreLayoutUid KPermanentFileStoreLayoutUid

MarshalL()

IMPORT_C voidMarshalL()

NewL(RFile &, TNewFunction)

IMPORT_C CFileStore *NewL(RFile &aFile,
TNewFunctionaFunction
)[protected, static]

Parameters

RFile & aFile
TNewFunction aFunction

NewLC(RFile &, TNewFunction)

IMPORT_C CFileStore *NewLC(RFile &aFile,
TNewFunctionaFunction
)[protected, static]

Parameters

RFile & aFile
TNewFunction aFunction

OpenL(RFs &, const TDesC &, TUint)

IMPORT_C CFileStore *OpenL(RFs &aFs,
const TDesC &aName,
TUintaFileMode
)[static]

Opens a file containing a store and constructs an appropriate file store object.

The resulting file store object is of concrete type, i.e. either CDirectFileStore or CPermanentFileStore. The specific type is determined from the layout information held in the file store.

TFileMode CFileStore::Layout()

Parameters

RFs & aFsHandle to a file server session.
const TDesC & aNameThe full path name of the file containing the store.
TUint aFileModeThe mode in which the file is to be accessed. The mode is defined by the TFileMode type.

OpenL(RFs &, const TDesC &, TUint, const TFileStoreFactoryFunction)

IMPORT_C CFileStore *OpenL(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
const TFileStoreFactoryFunctionaFactory
)[static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
const TFileStoreFactoryFunction aFactory

OpenL(RFs &, const TDesC &, TUint, TFileStoreFactoryFunction)

IMPORT_C CFileStore *OpenL(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
TFileStoreFactoryFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TFileStoreFactoryFunction aFunction

OpenLC(RFs &, const TDesC &, TUint)

IMPORT_C CFileStore *OpenLC(RFs &aFs,
const TDesC &aName,
TUintaFileMode
)[static]

Opens a file containing a store, constructs an appropriate file store object and places the pointer onto the cleanup stack.

The resulting file store object is of concrete type, i.e. either CDirectFileStore or CPermanentFileStore. The specific type is determined from the layout information held in the file store.

TFileMode CFileStore::Layout()

Parameters

RFs & aFsHandle to a file server session.
const TDesC & aNameThe full path name of the file containing the store.
TUint aFileModeThe mode in which the file is to be accessed. The mode is defined by the TFileMode type.

OpenLC(RFs &, const TDesC &, TUint, const TFileStoreFactoryFunction)

IMPORT_C CFileStore *OpenLC(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
const TFileStoreFactoryFunctionaFactory
)[static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
const TFileStoreFactoryFunction aFactory

OpenLC(RFs &, const TDesC &, TUint, TFileStoreFactoryFunction)

IMPORT_C CFileStore *OpenLC(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
TFileStoreFactoryFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TFileStoreFactoryFunction aFunction

Reattach(RFile &)

voidReattach(RFile &aFile)[inline]

Reattaches a file to the file store. The file should be the one that was detached using the Detach() function.

File()

Parameters

RFile & aFileThe file to be associated with this file store.

RefreshL()

IMPORT_C voidRefreshL()[protected]

ReplaceL(RFs &, const TDesC &, TUint, TNewFunction)

IMPORT_C CFileStore *ReplaceL(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
TNewFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TNewFunction aFunction

ReplaceLC(RFs &, const TDesC &, TUint, TNewFunction)

IMPORT_C CFileStore *ReplaceLC(RFs &aFs,
const TDesC &aName,
TUintaFileMode,
TNewFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TNewFunction aFunction

Reset()

voidReset()[inline]

Frees the file store s buffer space.

The buffer space is automatically re-allocated when needed.

This function should only be used immediately after a successful call to CommitL() or RevertL().

CStreamStore::CommitL() CStreamStore::RevertL()

Reset(TInt)

voidReset(TIntaSize)[inline]

Parameters

TInt aSize

SetSizeL(TInt)

voidSetSizeL(TIntaSize)[protected, inline]

Parameters

TInt aSize

SetTypeL(const TUidType &)

IMPORT_C voidSetTypeL(const TUidType &aType)

Parameters

const TUidType & aType

SynchL()

IMPORT_C voidSynchL()[protected]

TempL(RFs &, const TDesC &, TFileName &, TUint, TNewFunction)

IMPORT_C CFileStore *TempL(RFs &aFs,
const TDesC &aPath,
TFileName &aName,
TUintaFileMode,
TNewFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aPath
TFileName & aName
TUint aFileMode
TNewFunction aFunction

TempLC(RFs &, const TDesC &, TFileName &, TUint, TNewFunction)

IMPORT_C CFileStore *TempLC(RFs &aFs,
const TDesC &aPath,
TFileName &aName,
TUintaFileMode,
TNewFunctionaFunction
)[protected, static]

Parameters

RFs & aFs
const TDesC & aPath
TFileName & aName
TUint aFileMode
TNewFunction aFunction

Type()

const TUidType &Type()const [inline]

Gets the UID type of the file store.

TUid

Member Type Definitions Documentation

Typedef TNewFunction

typedef CFileStore *(*TNewFunction[protected]

Member Data Documentation

RFileBuf iBuf

RFileBuf iBuf[private]

__MUTABLE TStreamExchange iHost

__MUTABLE TStreamExchangeiHost[private]

TUidType iType

TUidType iType[private]