sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: // Class RFileBuf
sl@0: inline void RFileBuf::Reset(TInt aSize)
sl@0: /** Frees the intermediate buffer and changes the size of any future intermediate 
sl@0: buffer to the specified value.
sl@0: 
sl@0: The intermediate buffer must not contain any outstanding write data, otherwise 
sl@0: the function raises a STORE-File 6 panic.
sl@0: 
sl@0: @param aSize The size of any future intermediate buffer. */
sl@0: 	{Reset();iSize=aSize;}
sl@0: inline void RFileBuf::Detach()
sl@0: /** Detaches the file from this stream buffer.
sl@0: 
sl@0: The intermediate buffer's read and write marks are not changed, and the stream 
sl@0: positions are not changed. This means that the contents of the file should 
sl@0: not change while it is detached. 
sl@0: 
sl@0: @see Attach()
sl@0: @see Reattach() */
sl@0: 	{iFile=RFile();}
sl@0: inline void RFileBuf::Reattach(RFile& aFile)
sl@0: /** Re-attaches the specified file to this stream buffer.
sl@0: 
sl@0: The intermediate buffer's read and write marks are not changed, and the stream 
sl@0: positions are not changed.
sl@0: 
sl@0: The file should be the one that was detached using the Detach() function.
sl@0: 
sl@0: @param aFile The file to be re-attached.
sl@0: @see Attach()
sl@0: @see Detach() */
sl@0: 	{iFile=aFile;}
sl@0: inline RFile& RFileBuf::File() const
sl@0: /** Gets a reference to the file attached to this stream buffer.
sl@0: 
sl@0: @return The file attached to this stream buffer. */
sl@0: 	{return MUTABLE_CAST(RFile&,iFile);}
sl@0: 
sl@0: // Class RFileWriteStream
sl@0: inline RFileWriteStream::RFileWriteStream(const MExternalizer<TStreamRef>& anExter)
sl@0: 	: RWriteStream(anExter)
sl@0: 	{}
sl@0: 
sl@0: // Class CFileStore
sl@0: inline const TUidType& CFileStore::Type() const
sl@0: /** Gets the UID type of the file store.
sl@0: 
sl@0: @return The UID type object containing the file store type. 
sl@0: @see TUid */
sl@0: 	{return iType;}
sl@0: inline void CFileStore::Reset()
sl@0: /** Frees the file store’s buffer space.
sl@0: 
sl@0: The buffer space is automatically re-allocated when needed.
sl@0: 
sl@0: This function should only be used immediately after a successful call to CommitL() 
sl@0: or RevertL().
sl@0: 
sl@0: @see CStreamStore::CommitL()
sl@0: @see CStreamStore::RevertL() */
sl@0: 	{iBuf.Reset();}
sl@0: inline void CFileStore::Reset(TInt aSize)
sl@0: /** Frees the file store’s buffer space and changes the size of future buffer 
sl@0: space allocations.
sl@0: 
sl@0: The buffer space is automatically re-allocated when needed, using the new 
sl@0: size value.
sl@0: 
sl@0: This function should only be used immediately after a successful call to CommitL() 
sl@0: or RevertL().
sl@0: 
sl@0: @param aSize The size of future buffer space allocations. 
sl@0: @see CStreamStore::CommitL()
sl@0: @see CStreamStore::RevertL() */
sl@0: 	{iBuf.Reset(aSize);}
sl@0: inline void CFileStore::Detach()
sl@0: /** Detaches the file store from its associated file. 
sl@0: 
sl@0: In effect, the file store gives up ownership of the file.
sl@0: 
sl@0: Detaching is useful in cases where a file needs to be closed and later re-opened; 
sl@0: for example, to give up a write lock for backup purposes.
sl@0: 
sl@0: It is very important that the contents of the file should not change while 
sl@0: it is detached.
sl@0: 
sl@0: @see File()
sl@0: @see Reattach() */
sl@0: 	{iBuf.Detach();}
sl@0: inline void CFileStore::Reattach(RFile& aFile)
sl@0: /** Reattaches a file to the file store. The file should be the one that was detached 
sl@0: using the Detach() function.
sl@0: 
sl@0: @param aFile The file to be associated with this file store. 
sl@0: @see File() */
sl@0: 	{iBuf.Reattach(aFile);}
sl@0: inline RFile& CFileStore::File() const
sl@0: /** Gets a reference to the file associated with this file store.
sl@0: 
sl@0: This function is called prior to detaching the file store.
sl@0: 
sl@0: @return A reference to the associated file. 
sl@0: @see Detach() */
sl@0: 	{return iBuf.File();}
sl@0: inline TStreamExchange& CFileStore::Host() const
sl@0: 	{return MUTABLE_CAST(TStreamExchange&,iHost);}
sl@0: inline TBool CFileStore::IsHost(const MStreamBuf* aBuf) const
sl@0: 	{return aBuf==&iBuf;}
sl@0: inline void CFileStore::SetSizeL(TInt aSize)
sl@0: 	{iBuf.SetSizeL(aSize);}
sl@0: 
sl@0: // Class CDirectFileStore
sl@0: inline CDirectFileStore* CDirectFileStore::OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Opens a file containing a direct file store, and constructs a direct file store 
sl@0: object.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the file containing the store. 
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new direct file store object.
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::OpenL(aFs,aName,aFileMode,KDirectFileStoreFactoryFunction));}
sl@0: inline CDirectFileStore* CDirectFileStore::OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Opens a file containing a direct file store, constructs a direct file store 
sl@0: object, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aName The full path name of the file containing the store. 
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new direct file store object. 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::OpenLC(aFs,aName,aFileMode,KDirectFileStoreFactoryFunction));}
sl@0: inline CDirectFileStore* CDirectFileStore::CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a new file and constructs a new direct file store object to be associated 
sl@0: with this file.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aName The full path name of the new file. A file with this name must 
sl@0: not already exist, otherwise the function leaves.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type. 
sl@0: @return A pointer to the new direct file store object 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::CreateL(aFs,aName,aFileMode,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a new file and constructs a new direct file store object to be associated 
sl@0: with this file, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the new file. A file with this name must 
sl@0: not already exist, otherwise the function leaves.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type. 
sl@0: @return A pointer to the new direct file store object 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::CreateLC(aFs,aName,aFileMode,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a file and constructs a direct file store object to be associated with 
sl@0: it.
sl@0: 
sl@0: The file replaces any existing file of the same name.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the file to be replaced. 
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new direct file store object. 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::ReplaceL(aFs,aName,aFileMode,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a file, constructs a direct file store object to be associated with 
sl@0: it, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: The file replaces any existing file of the same name.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the file to be replaced.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new direct file store object. 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::ReplaceLC(aFs,aName,aFileMode,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
sl@0: /** Creates a temporary file and constructs a direct file store object to be associated 
sl@0: with it.
sl@0: 
sl@0: The new file is created in the specified path and a unique file name is generated 
sl@0: by the file server.
sl@0: 
sl@0: Note that the store framework does not delete a temporary file after it is 
sl@0: closed.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aPath The path where the new file is to be created. 
sl@0: @param aName On return, contains the full path name of the new file.
sl@0: @param aFileMode The mode in which the new file is to be accessed. The mode 
sl@0: is defined by the TFileMode type.
sl@0: @return A pointer to the new direct file store object. 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::TempL(aFs,aPath,aName,aFileMode,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
sl@0: /** Creates a temporary file, constructs a direct file store object to be associated 
sl@0: with it, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: The new file is created in the specified path and a unique file name is generated 
sl@0: by the file server.
sl@0: 
sl@0: Note that the store framework does not delete a temporary file after it is 
sl@0: closed.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aPath The path where the new file is to be created. 
sl@0: @param aName On return, contains the full path name of the new file.
sl@0: @param aFileMode The mode in which the new file is to be accessed. The mode 
sl@0: is defined by the TFileMode type.
sl@0: @return A pointer to the new direct file store object. 
sl@0: @see TFileMode */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::TempLC(aFs,aPath,aName,aFileMode,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::FromL(RFile& aFile)
sl@0: /** Constructs a direct file store object from an already opened file.
sl@0: 
sl@0: The file must already be open before calling this function.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid.
sl@0: 
sl@0: @param aFile A reference to the opened file.
sl@0: @return A pointer to the new direct file store object. */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::FromL(aFile,KDirectFileStoreFactoryFunction));}
sl@0: inline CDirectFileStore* CDirectFileStore::FromLC(RFile& aFile)
sl@0: /** Constructs a direct file store object from an already opened file, and places 
sl@0: the pointer onto the cleanup stack.
sl@0: 
sl@0: The file must already be open before calling this function.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid.
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new direct file store object. */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::FromLC(aFile,KDirectFileStoreFactoryFunction));}
sl@0: inline CDirectFileStore* CDirectFileStore::NewL(RFile& aFile)
sl@0: /** Constructs a new direct file store object in an already opened file.
sl@0: 
sl@0: The file must already be open before calling the function. The existing content 
sl@0: of the file is discarded.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid:
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new direct file store object. */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::NewL(aFile,&DoNewL));}
sl@0: inline CDirectFileStore* CDirectFileStore::NewLC(RFile& aFile)
sl@0: /** Constructs a new direct file store object in an already opened file and places 
sl@0: the pointer onto the cleanup stack.
sl@0: 
sl@0: The file must already be open before calling the function. The existing content 
sl@0: of the file is discarded.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid:
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new direct file store object. */
sl@0: 	{return STATIC_CAST(CDirectFileStore*,CFileStore::NewLC(aFile,&DoNewL));}
sl@0: 
sl@0: // Class CPermanentFileStore
sl@0: inline CPermanentFileStore* CPermanentFileStore::OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Opens a file containing a permanent file store, and constructs a permanent 
sl@0: file store object.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aName The full path name of the file containing the store. 
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type. 
sl@0: @return A pointer to the new permanent file store object.
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::OpenL(aFs,aName,aFileMode,KPermanentFileStoreFactoryFunction));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Opens a file containing a permanent file store, constructs a permanent file 
sl@0: store object, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the file containing the store. 
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type. 
sl@0: @return A pointer to the new permanent file store object.
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::OpenLC(aFs,aName,aFileMode,KPermanentFileStoreFactoryFunction));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a new file and constructs a new permanent file store object to be associated 
sl@0: with this file.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aName The full path name of the new file. A file with this name must 
sl@0: not already exist, otherwise the function leaves.
sl@0: @param aFileMode The mode in which the new file is to be accessed. This mode 
sl@0: is defined by the TFileMode type. 
sl@0: @return A pointer to the new permanent file store object.
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::CreateL(aFs,aName,aFileMode,&DoNewL));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a new file and constructs a new permanent file store object to be associated 
sl@0: with this file, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the new file. A file with this name must 
sl@0: not already exist, otherwise the function leaves.
sl@0: @param aFileMode The mode in which the new file is to be accessed. This mode 
sl@0: is defined by the TFileMode type. 
sl@0: @return A pointer to the new permanent file store object. 
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::CreateLC(aFs,aName,aFileMode,&DoNewL));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a file, constructs a permanent file store object to be associated with 
sl@0: it.
sl@0: 
sl@0: This file replaces any existing file of the same name.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the file to be replaced.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new permanent file store object.
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::ReplaceL(aFs,aName,aFileMode,&DoNewL));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a file, constructs a permanent file store object to be associated with 
sl@0: it, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: This file replaces any existing file of the same name.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aName The full path name of the file to be replaced.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new permanent file store object. 
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0:     
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::ReplaceLC(aFs,aName,aFileMode,&DoNewL));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
sl@0: /** Creates a temporary file and constructs a permanent file store object to be 
sl@0: associated with it.
sl@0: 
sl@0: The new file is created in the specified path and a unique file name is generated 
sl@0: by the file server.
sl@0: 
sl@0: Note that the store framework does not delete a temporary file after it is 
sl@0: closed.
sl@0: 
sl@0: @param aFs Handle to a file server session.
sl@0: @param aPath The path where the new file is to be created.
sl@0: @param aName On return, contains the full path name of the new file.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type.
sl@0: @return A pointer to the new permanent file store object.
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::TempL(aFs,aPath,aName,aFileMode,&DoNewL));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
sl@0: /** Creates a temporary file, constructs a permanent file store object to be associated 
sl@0: with it, and places the pointer onto the cleanup stack.
sl@0: 
sl@0: The new file is created in the specified path and a unique file name is generated 
sl@0: by the file server.
sl@0: 
sl@0: Note that the store framework does not delete a temporary file after it is 
sl@0: closed.
sl@0: 
sl@0: @param aFs Handle to a file server session. 
sl@0: @param aPath The path where the new file is to be created.
sl@0: @param aName On return, contains the full path name of the new file.
sl@0: @param aFileMode The mode in which the file is to be accessed. The mode is 
sl@0: defined by the TFileMode type. 
sl@0: @return A pointer to the new permanent file store object.
sl@0: @see TFileMode */
sl@0: 	{
sl@0: //  When the file server write caching is enabled, the order of file write operations is not guaranteed. This could cause data inconsistency in some circumstances,
sl@0: //  for example, when the power is lost in the middle of a database transaction. Therefore, the file write caching is disabled for this file to maintain integrity.
sl@0: 	
sl@0:     if ((aFileMode&EFileWrite) != 0)
sl@0:         {
sl@0:         aFileMode |= EFileWriteDirectIO;
sl@0:         aFileMode &= (~EFileWriteBuffered);
sl@0:         }
sl@0:     return STATIC_CAST(CPermanentFileStore*,CFileStore::TempLC(aFs,aPath,aName,aFileMode,&DoNewL));
sl@0: 	}
sl@0: inline CPermanentFileStore* CPermanentFileStore::FromL(RFile& aFile)
sl@0: /** Constructs a permanent file store object from an already opened file. It is strongly recommended to set EFileWriteDirectIO
sl@0: bit when opening the file. This is because that when the file server write caching is enabled, the
sl@0: order of file write operations is not guaranteed. This could cause data inconsistency in some
sl@0: circumstances, for example, when the power is lost in the middle of database transaction.
sl@0: Therefore, the file write caching should be switched off to maintain integrity.
sl@0:    
sl@0: 
sl@0: 
sl@0: The file must already be open before calling this function.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid.
sl@0: 
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new permanent file store object. */
sl@0: 	{return STATIC_CAST(CPermanentFileStore*,CFileStore::FromL(aFile,KPermanentFileStoreFactoryFunction));}
sl@0: inline CPermanentFileStore* CPermanentFileStore::FromLC(RFile& aFile)
sl@0: /** Constructs a permanent file store object from an already opened file, and places 
sl@0: the pointer onto the cleanup stack.
sl@0: 
sl@0: The file must already be open before calling this function. It is strongly recommended to set EFileWriteDirectIO
sl@0: bit when opening the file. This is because that when the file server write caching is enabled, the
sl@0: order of file write operations is not guaranteed. This could cause data inconsistency in some
sl@0: circumstances, for example, when the power is lost in the middle of database transaction.
sl@0: Therefore, the file write caching should be switched off to maintain integrity.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid.
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new permanent file store object. */
sl@0: 	{return STATIC_CAST(CPermanentFileStore*,CFileStore::FromLC(aFile,KPermanentFileStoreFactoryFunction));}
sl@0: inline CPermanentFileStore* CPermanentFileStore::NewL(RFile& aFile)
sl@0: /** Constructs a new permanent file store object in an already opened file.
sl@0: 
sl@0: The file must already be open before calling this function. The existing content 
sl@0: of the file is discarded. It is strongly recommended to set EFileWriteDirectIO
sl@0: bit when opening the file. It is because that when the file write caching in file server is on, the
sl@0: order of file writing is not guaranteed which could cause data inconsistency in some
sl@0: circumstances, for example, when the power is lost in the middle of data transaction.
sl@0: Therefore, the file write caching should be switched off to maintain the file integrity.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid.
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new permanent file store object. */
sl@0: 	{return STATIC_CAST(CPermanentFileStore*,CFileStore::NewL(aFile,&DoNewL));}
sl@0: inline CPermanentFileStore* CPermanentFileStore::NewLC(RFile& aFile)
sl@0: /** Constructs a new permanent file store object in an already opened file and 
sl@0: places the pointer onto the cleanup stack.
sl@0: 
sl@0: The file must already be open before calling this function.The existing content 
sl@0: of the file is discarded. It is strongly recommended to set EFileWriteDirectIO
sl@0: bit when opening the file. It is because that when the write caching in file server is on, the
sl@0: order of file writing is not guaranteed which could cause data inconsistency in some
sl@0: circumstances, for example, when the power is lost in the middle of data transaction.
sl@0: Therefore, the file write caching should be switched off to maintain the file integrity.
sl@0: 
sl@0: Note that ownership of the file passes to the store. The referenced RFile 
sl@0: is cleared and is no longer valid.
sl@0: 
sl@0: @param aFile A reference to the opened file. 
sl@0: @return A pointer to the new permanent file store object. */
sl@0: 	{return STATIC_CAST(CPermanentFileStore*,CFileStore::NewLC(aFile,&DoNewL));}
sl@0: 
sl@0: // Class RFilePagePool
sl@0: inline TInt RFilePagePool::Open(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Opens a file to use for the page pool.
sl@0: 
sl@0: @param aFs A file server session
sl@0: @param aName The name of the file
sl@0: @param aFileMode The mode in which the file is opened. For more information, 
sl@0: see the TFileMode enumeration. 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes.
sl@0: @see TFileMode */
sl@0: 	{return iFile.Open(aFs,aName,aFileMode);}
sl@0: inline TInt RFilePagePool::Create(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates a new file for the page pool.
sl@0: 
sl@0: @param aFs A file server session
sl@0: @param aName The name of the file. Any path components which are not specified 
sl@0: here are taken from the session path.
sl@0: @param aFileMode The mode in which the file is opened. For more information 
sl@0: see the TFileMode enumeration. 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes.
sl@0: @see TFileMode */
sl@0: 	{return iFile.Create(aFs,aName,aFileMode);}
sl@0: inline TInt RFilePagePool::Replace(RFs& aFs,const TDesC& aName,TUint aFileMode)
sl@0: /** Creates or opens a file for the page pool. 
sl@0: 
sl@0: If there is an existing file with the same name, this function overwrites 
sl@0: it. If the file does not already exist, it is created.
sl@0: 
sl@0: @param aFs A file server session.
sl@0: @param aName The name of the file. Any path components which are not specified 
sl@0: here are taken from the session path.
sl@0: @param aFileMode The mode in which the file is opened. For more information 
sl@0: see the TFileMode enumeration. 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes.
sl@0: @see TFileMode */
sl@0: 	{return iFile.Replace(aFs,aName,aFileMode);}
sl@0: inline TInt RFilePagePool::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
sl@0: /** Creates and opens a file for the page pool with a unique name.
sl@0: 
sl@0: @param aFs A file server session.
sl@0: @param aPath The directory in which the file should be created.
sl@0: @param aName On return, contains the full path and name of the file. The filename 
sl@0: is guaranteed to be unique within the directory specified by aPath.
sl@0: @param aFileMode The mode in which the file is opened. For more information 
sl@0: see the TFileMode enumeration.
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes. */
sl@0: 	{return iFile.Temp(aFs,aPath,aName,aFileMode);}
sl@0: inline void RFilePagePool::Attach(RFile& aFile)
sl@0: /** Sets an existing file to be used for the page pool.
sl@0: 
sl@0: @param aFile File to use for the page pool */
sl@0: 	{iFile=aFile;}
sl@0: inline void RFilePagePool::Detach()
sl@0: /** Ends the use of the file for the page pool, but does not close the file. */
sl@0: 	{iFile=RFile();}
sl@0: inline RFile& RFilePagePool::File() const
sl@0: 	{return MUTABLE_CAST(RFile&,iFile);}
sl@0: