CFileStore Class Reference

#include <s32file.h>

class CFileStore : public CPersistentStore

Inherits from

Protected Member Type Definitions
typedef CFileStore *(* TNewFunction
Public Member Functions
~CFileStore()
voidDetach()
RFile &File()
IMPORT_C CFileStore *FromL(RFile &)
IMPORT_C CFileStore *FromL(RFile &, const TFileStoreFactoryFunction)
IMPORT_C CFileStore *FromLC(RFile &)
IMPORT_C CFileStore *FromLC(RFile &, const TFileStoreFactoryFunction)
pure virtual 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 &)
CFileStore(RFileBuf &, const TUidType &)
IMPORT_C voidChangedL()
IMPORT_C CFileStore *CreateL(RFs &, const TDesC &, TUint, TNewFunction)
IMPORT_C CFileStore *CreateLC(RFs &, const TDesC &, TUint, TNewFunction)
IMPORT_C voidDestruct()
virtual IMPORT_C voidDoCommitL()
virtual 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)
Inherited Attributes
CPersistentStore::iRoot
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()

Detailed Description

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.

Member Type Definition Documentation

Typedef TNewFunction

typedef CFileStore *(*TNewFunction[protected]

Constructor & Destructor Documentation

CFileStore ( RFile & )

IMPORT_CCFileStore(RFile &aFile)[protected]

CFileStore ( RFileBuf &, const TUidType & )

IMPORT_CCFileStore(RFileBuf &aBuf,
const TUidType &aType
)[protected]

~CFileStore ( )

IMPORT_C~CFileStore()

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

Member Function Documentation

ChangedL ( )

IMPORT_C voidChangedL()[protected]

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

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

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

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

Destruct ( )

IMPORT_C voidDestruct()[protected]

Detach ( )

voidDetach()[inline]

Detaches the file store from its associated file.

In effect, the file store gives up ownership of the file.

Detaching is useful in cases where a file needs to be closed and later re-opened; for example, to give up a write lock for backup purposes.

It is very important that the contents of the file should not change while it is detached.

See also: File() Reattach()

DoCommitL ( )

IMPORT_C voidDoCommitL()[protected, virtual]

Reimplemented from CStreamStore::DoCommitL()

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.

DoRevertL ( )

IMPORT_C voidDoRevertL()[protected, virtual]

Reimplemented from CStreamStore::DoRevertL()

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.

File ( )

RFile &File()const [inline]

Gets a reference to the file associated with this file store.

This function is called prior to detaching the file store.

See also: Detach()

Returns: A reference to the associated file.

FromL ( RFile & )

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

Constructs a file store object from an opened file.

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:

See also: CFileStore::Layout()

ParameterDescription
aFileA reference to the opened file.

Returns: A pointer to the new file store object.

FromL ( RFile &, const TFileStoreFactoryFunction )

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

FromL ( RFile &, TFileStoreFactoryFunction )

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

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:

See also: CFileStore::Layout()

ParameterDescription
aFileA reference to the opened file.

Returns: A pointer to the new file store object.

FromLC ( RFile &, const TFileStoreFactoryFunction )

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

FromLC ( RFile &, TFileStoreFactoryFunction )

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

Host ( )

TStreamExchange &Host()const [protected, inline]

IsHost ( const MStreamBuf * )

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

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.

See also: KDirectFileStoreLayoutUid KPermanentFileStoreLayoutUid

Returns: The UID that uniquely identifies the specific type of file store.

MarshalL ( )

IMPORT_C voidMarshalL()

NewL ( RFile &, TNewFunction )

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

NewLC ( RFile &, TNewFunction )

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

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.

See also: TFileMode CFileStore::Layout()

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

Returns: A pointer to the new file store object.

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

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

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

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

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.

See also: TFileMode CFileStore::Layout()

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

Returns: A pointer to the new file store object.

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

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

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

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

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.

See also: File()

ParameterDescription
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]

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

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

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().

See also: CStreamStore::CommitL() CStreamStore::RevertL()

Reset ( TInt )

voidReset(TIntaSize)[inline]

Frees the file store s buffer space and changes the size of future buffer space allocations.

The buffer space is automatically re-allocated when needed, using the new size value.

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

See also: CStreamStore::CommitL() CStreamStore::RevertL()

ParameterDescription
aSizeThe size of future buffer space allocations.

SetSizeL ( TInt )

voidSetSizeL(TIntaSize)[protected, inline]

SetTypeL ( const TUidType & )

IMPORT_C voidSetTypeL(const TUidType &aType)

Sets the UID type of the file store.

The first UID, i.e. the first TUid component, of the TUidType must be the file store type as returned by CFileStore::Layout(), otherwise the function raises a STORE-File 9 panic.

See also: TUid

ParameterDescription
aTypeThe UID type object containing the file store type.

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]

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

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

Type ( )

const TUidType &Type()const [inline]

Gets the UID type of the file store.

See also: TUid

Returns: The UID type object containing the file store type.