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: /** sl@0: Returns the start position of the write area within the sl@0: intermediate buffer taking into account seeks. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: sl@0: */ sl@0: inline TUint8* RFileBuf::Limit(TWrite) const sl@0: { sl@0: return iWLim; sl@0: } sl@0: /** Sets the start position of the write area within the sl@0: intermediate buffer taking into account seeks. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: @param aPtr The start point to set the limit to. sl@0: */ sl@0: inline void RFileBuf::SetLimit(TWrite,TUint8* aLimit) sl@0: { sl@0: iWLim=aLimit; sl@0: } sl@0: /** Sets the read position of the stream to the specified offset within the file. sl@0: sl@0: @param The enumerator indicates we are setting a read buffer. sl@0: @param aPos The offset within the file to which the read stream position sl@0: is set. By default this is zero. sl@0: @see MStreamBuf::TRead */ sl@0: inline void RFileBuf::SetPos(TRead,TInt aPos) sl@0: { sl@0: iRPos=aPos; sl@0: } sl@0: /** Sets the write position of the stream to the specified offset within the file. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: @param aPos The offset within the file to which the write stream position sl@0: is set. By default this is zero. sl@0: @see MStreamBuf::TWrite */ sl@0: inline void RFileBuf::SetPos(TWrite,TInt aPos) sl@0: { sl@0: iWPos=aPos; sl@0: } sl@0: /** Returns the read stream position. sl@0: sl@0: @param The enumerator indicates we are setting a read buffer. sl@0: @see MStreamBuf::TRead */ sl@0: inline TInt RFileBuf::Pos(TRead) const sl@0: { sl@0: return iRPos; sl@0: } sl@0: /** Returns the write stream position. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: @see MStreamBuf::TWrite */ sl@0: inline TInt RFileBuf::Pos(TWrite) const sl@0: { sl@0: return iWPos; sl@0: } sl@0: /** Moves the file offset to which the read stream position is set. sl@0: sl@0: @param The enumerator indicates we are setting a read buffer. sl@0: @param The number of bytes to move by. sl@0: @see MStreamBuf::TRead */ sl@0: inline TInt RFileBuf::MovePos(TRead,TInt anOffset) sl@0: { sl@0: return iRPos+=anOffset; sl@0: } sl@0: /** Moves the file offset to which the write stream position is set. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: @param The number of bytes to move by. sl@0: @see MStreamBuf::TWrite */ sl@0: inline TInt RFileBuf::MovePos(TWrite,TInt anOffset) sl@0: { sl@0: return iWPos+=anOffset; sl@0: } sl@0: /** Returns the number of bytes that are/were in the read area of the sl@0: intermediate buffer yet to be passed to the user. sl@0: sl@0: @param The enumerator indicates we are setting a read buffer. sl@0: @see MStreamBuf::TRead */ sl@0: inline TInt RFileBuf::Lag(TRead) const sl@0: { sl@0: return Ptr(ERead)-End(ERead); sl@0: } sl@0: /** Returns the number of bytes that are/were in the write area of the sl@0: intermediate buffer yet to be written to the file. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: @see MStreamBuf::TWrite */ sl@0: inline TInt RFileBuf::Lag(TWrite) const sl@0: { sl@0: return Ptr(EWrite)-iBase; sl@0: } sl@0: /** Returns the number of bytes of outstanding data in the intermediate sl@0: buffer that is yet to be written, taking into account any changes brought sl@0: about by seeks. sl@0: sl@0: @param The enumerator indicates we are using a write buffer. sl@0: @see MStreamBuf::TWrite */ sl@0: inline TInt RFileBuf::Span(TWrite) const sl@0: { sl@0: return Max(Ptr(EWrite),Limit(EWrite))-iBase; sl@0: } sl@0: /** Gets the the read position within the stream taking sl@0: into account the data in the intermediate buffer not yet passed up sl@0: to the user. sl@0: sl@0: @param The enumerator indicates we are using a read buffer. sl@0: @see MStreamBuf::TRead */ sl@0: inline TInt RFileBuf::Mark(TRead) const sl@0: { sl@0: return Pos(ERead)+Lag(ERead); sl@0: } sl@0: /** Gets the write position within the stream taking sl@0: into account data in the intermediate buffer not yet written. sl@0: sl@0: @param The enumerator indicates we are using a write buffer. sl@0: @see MStreamBuf::TWrite */ sl@0: inline TInt RFileBuf::Mark(TWrite) const sl@0: { sl@0: return Pos(EWrite)+Lag(EWrite); sl@0: } sl@0: /** Returns the possible end position of the write position in the stream sl@0: should the current data in the intermediate buffer be written. sl@0: sl@0: @param The enumerator indicates we are using a write buffer. sl@0: @see MStreamBuf::TWrite */ sl@0: inline TInt RFileBuf::Reach(TWrite) const sl@0: { sl@0: return Pos(EWrite)+Span(EWrite); sl@0: } sl@0: /** Sets the start and end points of the read area within the intermediate buffer. sl@0: sl@0: @param The enumerator indicates we are setting a read buffer. sl@0: @param aPtr The start point. sl@0: @param anEnd The end point. sl@0: @see MStreamBuf::TRead sl@0: @see TStreamBuf::SetBuf sl@0: */ sl@0: inline void RFileBuf::SetBuf(TRead,TUint8* aPtr,TUint8* anEnd) sl@0: { sl@0: TStreamBuf::SetBuf(ERead,aPtr,anEnd); sl@0: } sl@0: /** Sets the start and end points of the read area within the intermediate buffer. sl@0: sl@0: @param The enumerator indicates we are setting a write buffer. sl@0: @param aPtr The start point. sl@0: @param anEnd The end point. sl@0: @see MStreamBuf::TWrite sl@0: @see TStreamBuf::SetBuf sl@0: */ sl@0: inline void RFileBuf::SetBuf(TWrite,TUint8* aPtr,TUint8* anEnd) sl@0: { sl@0: TStreamBuf::SetBuf(EWrite,aPtr,anEnd); sl@0: SetLimit(EWrite,aPtr); sl@0: } sl@0: /** Sets the start and end points of the read area within the intermediate buffer. sl@0: sl@0: @param The enumerator indicates we are setting a read buffer. ??? sl@0: @param aPtr The start point. sl@0: @param anEnd The end point. sl@0: @see MStreamBuf::TArea sl@0: @see TStreamBuf::SetBuf sl@0: */ sl@0: inline void RFileBuf::SetBuf(TArea anArea,TUint8* aPtr,TUint8* anEnd) sl@0: { sl@0: TStreamBuf::SetBuf(anArea,aPtr,anEnd); sl@0: if (anArea&EWrite) { sl@0: SetLimit(EWrite,aPtr); sl@0: } sl@0: } sl@0: sl@0: /** Returns a pointer to the CPermanentStoreCoord object. sl@0: sl@0: @see CPermanentStoreCoord */ sl@0: inline CPermanentStoreCoord& CPermanentFileStore::Coord() const sl@0: { sl@0: __ASSERT_DEBUG(iCoord!=NULL,User::Invariant()); sl@0: return *iCoord; sl@0: } sl@0: