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.

Public Member Functions
~CFileStore ()
RFile & File ()
IMPORT_C CFileStore * FromLC ( RFile &)
IMPORT_C CFileStore * FromLC ( RFile &, const TFileStoreFactoryFunction )
TUid Layout ()
IMPORT_C void MarshalL ()
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 )
void Reattach ( RFile &)
void Reset ()
void Reset ( TInt )
IMPORT_C void SetTypeL (const TUidType &)
const TUidType & Type ()
Protected Member Functions
CFileStore ( RFile &)
IMPORT_C CFileStore * CreateLC ( RFs &, const TDesC &, TUint , TNewFunction )
IMPORT_C void Destruct ()
IMPORT_C void DoCommitL ()
IMPORT_C void DoRevertL ()
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 void RefreshL ()
IMPORT_C CFileStore * ReplaceL ( RFs &, const TDesC &, TUint , TNewFunction )
IMPORT_C CFileStore * ReplaceLC ( RFs &, const TDesC &, TUint , TNewFunction )
void SetSizeL ( TInt )
IMPORT_C void SynchL ()
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 )
void ExternalizeL ( RWriteStream &)
void InternalizeL ( 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 TStreamExchange iHost
TUidType iType
Inherited Attributes
CPersistentStore::iRoot

Constructor & Destructor Documentation

CFileStore(RFile &)

IMPORT_C CFileStore ( 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,
TUint aFileMode,
TNewFunction aFunction
) [protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TNewFunction aFunction

Destruct()

IMPORT_C void Destruct ( ) [protected]

DoCommitL()

IMPORT_C void DoCommitL ( ) [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,
TNewFunction aFunction
) [private, static]

Parameters

RFile & aFile
TNewFunction aFunction

DoRevertL()

IMPORT_C void DoRevertL ( ) [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 &)

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

Parameters

RWriteStream & aStream

File()

RFile & File ( ) const [inline]

FromL(RFile &, TFileStoreFactoryFunction)

IMPORT_C CFileStore * FromL ( RFile & aFile,
TFileStoreFactoryFunction aFunction
) [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 & aFile A reference to the opened file.

FromLC(RFile &, const TFileStoreFactoryFunction)

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

Parameters

RFile & aFile
const TFileStoreFactoryFunction aFactory

FromLC(RFile &, TFileStoreFactoryFunction)

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

Parameters

RFile & aFile
TFileStoreFactoryFunction aFunction

Host()

TStreamExchange & Host ( ) const [protected, inline]

InternalizeL(RReadStream &)

void InternalizeL ( 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 void MarshalL ( )

NewL(RFile &, TNewFunction)

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

Parameters

RFile & aFile
TNewFunction aFunction

NewLC(RFile &, TNewFunction)

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

Parameters

RFile & aFile
TNewFunction aFunction

OpenL(RFs &, const TDesC &, TUint)

IMPORT_C CFileStore * OpenL ( RFs & aFs,
const TDesC & aName,
TUint aFileMode
) [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 & aFs Handle to a file server session.
const TDesC & aName The full path name of the file containing the store.
TUint aFileMode The 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,
TUint aFileMode,
const TFileStoreFactoryFunction aFactory
) [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,
TUint aFileMode,
TFileStoreFactoryFunction aFunction
) [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,
TUint aFileMode
) [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 & aFs Handle to a file server session.
const TDesC & aName The full path name of the file containing the store.
TUint aFileMode The 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,
TUint aFileMode,
const TFileStoreFactoryFunction aFactory
) [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,
TUint aFileMode,
TFileStoreFactoryFunction aFunction
) [protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TFileStoreFactoryFunction aFunction

Reattach(RFile &)

void Reattach ( 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 & aFile The file to be associated with this file store.

RefreshL()

IMPORT_C void RefreshL ( ) [protected]

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

IMPORT_C CFileStore * ReplaceL ( RFs & aFs,
const TDesC & aName,
TUint aFileMode,
TNewFunction aFunction
) [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,
TUint aFileMode,
TNewFunction aFunction
) [protected, static]

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode
TNewFunction aFunction

Reset()

void Reset ( ) [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)

void Reset ( TInt aSize ) [inline]

Parameters

TInt aSize

SetSizeL(TInt)

void SetSizeL ( TInt aSize ) [protected, inline]

Parameters

TInt aSize

SetTypeL(const TUidType &)

IMPORT_C void SetTypeL ( const TUidType & aType )

Parameters

const TUidType & aType

SynchL()

IMPORT_C void SynchL ( ) [protected]

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

IMPORT_C CFileStore * TempL ( RFs & aFs,
const TDesC & aPath,
TFileName & aName,
TUint aFileMode,
TNewFunction aFunction
) [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,
TUint aFileMode,
TNewFunction aFunction
) [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 TStreamExchange iHost [private]

TUidType iType

TUidType iType [private]