Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <S32FILE.H>
Link against: estor.lib

Class CFileStore

class CFileStore : public CPersistentStore;

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 CFileStore::OpenL(RFs &,const TDesC &,TUint), CFileStore::OpenLC(RFs &,const TDesC &,TUint), CFileStore::FromL(RFile &) and CFileStore::FromLC(RFile &). New file stores, however, must be created using the appropriate member function of the concrete type.

Derivation

Members

Defined in CFileStore:

Inherited from CBase:

Inherited from CPersistentStore:

Inherited from CStreamStore:


Construction and destruction


~CFileStore()

IMPORT_C ~CFileStore();

Description

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


NewL(RFile &,TNewFunction)

protected: IMPORT_C static CFileStore* NewL(RFile &aFile, TNewFunction aFunction);

Description

Parameters

RFile &aFile

CFileStore::TNewFunction aFunction

Return value

CFileStore *


NewLC(RFile &,TNewFunction)

protected: IMPORT_C static CFileStore* NewLC(RFile &aFile, TNewFunction aFunction);

Description

Parameters

RFile &aFile

CFileStore::TNewFunction aFunction

Return value

CFileStore *


CFileStore(RFile &)

protected: IMPORT_C CFileStore(RFile &aFile);

Description

Parameters

RFile &aFile


CFileStore(RFileBuf &,const TUidType &)

protected: IMPORT_C CFileStore(RFileBuf &aBuf, const TUidType &aType);

Description

Parameters

RFileBuf &aBuf

const TUidType &aType

[Top]


Member functions


OpenL(RFs &,const TDesC &,TUint)

IMPORT_C static CFileStore* OpenL(RFs &aFs, const TDesC &aName, TUint aFileMode);

Description

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.

Parameters

RFs &aFs

Handle to a file server session.

const TDesC16 &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.

Return value

CFileStore *

A pointer to the new file store object.

See also:


OpenLC(RFs &,const TDesC &,TUint)

IMPORT_C static CFileStore* OpenLC(RFs &aFs, const TDesC &aName, TUint aFileMode);

Description

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.

Parameters

RFs &aFs

Handle to a file server session.

const TDesC16 &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.

Return value

CFileStore *

A pointer to the new file store object.

See also:


FromL(RFile &)

IMPORT_C static CFileStore* FromL(RFile &aFile);

Description

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:

Parameters

RFile &aFile

A reference to the opened file.

Return value

CFileStore *

A pointer to the new file store object.

See also:


FromLC(RFile &)

IMPORT_C static CFileStore* FromLC(RFile &aFile);

Description

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:

Parameters

RFile &aFile

A reference to the opened file.

Return value

CFileStore *

A pointer to the new file store object.

See also:


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

IMPORT_C static CFileStore* OpenL(RFs &aFs, const TDesC &aName, TUint aFileMode, const TFileStoreFactoryFunction aFactory[]);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

const TFileStoreFactoryFunction aFactory

Return value

CFileStore *


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

IMPORT_C static CFileStore* OpenLC(RFs &aFs, const TDesC &aName, TUint aFileMode, const TFileStoreFactoryFunction aFactory[]);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

const TFileStoreFactoryFunction aFactory

Return value

CFileStore *


FromL(RFile &,const TFileStoreFactoryFunction)

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

Description

Parameters

RFile &aFile

const TFileStoreFactoryFunction aFactory

Return value

CFileStore *


FromLC(RFile &,const TFileStoreFactoryFunction)

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

Description

Parameters

RFile &aFile

const TFileStoreFactoryFunction aFactory

Return value

CFileStore *


Type()const

inline const TUidType& Type() const;

Description

Gets the UID type of the file store.

Return value

const TUidType &

The UID type object containing the file store type.

See also:


SetTypeL(const TUidType &)

IMPORT_C void SetTypeL(const TUidType &aType);

Description

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()const, otherwise the function raises a STORE-File 9 panic.

Parameters

const TUidType &aType

The UID type object containing the file store type.

See also:


Layout()const

virtual TUid Layout() const=0;

Description

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.

Return value

TUid

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


Reset()

inline void Reset();

Description

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 CStreamStore::CommitL() or CStreamStore::RevertL().

See also:


Reset(TInt)

inline void Reset(TInt aSize);

Description

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 CStreamStore::CommitL() or CStreamStore::RevertL().

Parameters

TInt aSize

The size of future buffer space allocations.

See also:


Detach()

inline void Detach();

Description

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:


Reattach(RFile &)

inline void Reattach(RFile &aFile);

Description

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

Parameters

RFile &aFile

The file to be associated with this file store.

See also:


File()const

inline RFile& File() const;

Description

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

This function is called prior to detaching the file store.

Return value

RFile &

A reference to the associated file.

See also:


MarshalL()

IMPORT_C void MarshalL();

Description


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

protected: IMPORT_C static CFileStore* OpenL(RFs &aFs, const TDesC &aName, TUint aFileMode, TFileStoreFactoryFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

TFileStoreFactoryFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* OpenLC(RFs &aFs, const TDesC &aName, TUint aFileMode, TFileStoreFactoryFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

TFileStoreFactoryFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* CreateL(RFs &aFs, const TDesC &aName, TUint aFileMode, TNewFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

CFileStore::TNewFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* CreateLC(RFs &aFs, const TDesC &aName, TUint aFileMode, TNewFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

CFileStore::TNewFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* ReplaceL(RFs &aFs, const TDesC &aName, TUint aFileMode, TNewFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

CFileStore::TNewFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* ReplaceLC(RFs &aFs, const TDesC &aName, TUint aFileMode, TNewFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aName

TUint aFileMode

CFileStore::TNewFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* TempL(RFs &aFs, const TDesC &aPath, TFileName &aName, TUint aFileMode, TNewFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aPath

TBuf &aName

TUint aFileMode

CFileStore::TNewFunction aFunction

Return value

CFileStore *


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

protected: IMPORT_C static CFileStore* TempLC(RFs &aFs, const TDesC &aPath, TFileName &aName, TUint aFileMode, TNewFunction aFunction);

Description

Parameters

RFs &aFs

const TDesC16 &aPath

TBuf &aName

TUint aFileMode

CFileStore::TNewFunction aFunction

Return value

CFileStore *


FromL(RFile &,TFileStoreFactoryFunction)

protected: IMPORT_C static CFileStore* FromL(RFile &aFile, TFileStoreFactoryFunction aFunction);

Description

Parameters

RFile &aFile

TFileStoreFactoryFunction aFunction

Return value

CFileStore *


FromLC(RFile &,TFileStoreFactoryFunction)

protected: IMPORT_C static CFileStore* FromLC(RFile &aFile, TFileStoreFactoryFunction aFunction);

Description

Parameters

RFile &aFile

TFileStoreFactoryFunction aFunction

Return value

CFileStore *


Destruct()

protected: IMPORT_C void Destruct();

Description


Host()const

protected: inline TStreamExchange& Host() const;

Description

Return value

TStreamExchange &


IsHost(const MStreamBuf *)const

protected: inline TBool IsHost(const MStreamBuf *aBuf) const;

Description

Parameters

const MStreamBuf *aBuf

Return value

TBool


SynchL()

protected: IMPORT_C void SynchL();

Description


SetSizeL(TInt)

protected: inline void SetSizeL(TInt aSize);

Description

Parameters

TInt aSize


ChangedL()

protected: IMPORT_C void ChangedL();

Description


RefreshL()

protected: IMPORT_C void RefreshL();

Description


DoCommitL()

protected: IMPORT_C virtual void DoCommitL();

Description

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 CStreamStore::CommitL() function.


DoRevertL()

protected: IMPORT_C virtual void DoRevertL();

Description

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 CStreamStore::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 &)const

private: virtual void ExternalizeL(RWriteStream &aStream) const=0;

Description

Parameters

RWriteStream &aStream


InternalizeL(RReadStream &)

private: virtual void InternalizeL(RReadStream &aStream)=0;

Description

Parameters

RReadStream &aStream

[Top]


Member type definitions


Typedef TNewFunction

protected: typedef CFileStore*(* CFileStore::TNewFunction)(RFile& aFile);

Description