CFileCB Class Reference

class CFileCB : public CFsDispatchObject

A file server interface class representing an open file.

An instance of this object is referred to as a file control block.

A file control block needs to be created for a specific file to be able to access that file within a directory.

A plug-in file system implements this class.

Public Member Functions
CFileCB ()
~CFileCB ()
TInt AddLock ( CFileShare *, TInt , TInt )
TInt AddLock64 ( CFileShare *, TInt64 , TInt64 )
IMPORT_C TInt Address ( TInt &)
TInt Att ()
TBool BadPower ()
TInt BlockMap ( SBlockMapInfo &, TInt64 &, TInt64 )
TInt64 CachedSize64 ()
TInt CancelAsyncReadRequest ( CFileShare *, TRequestStatus *)
TInt CheckLock ( CFileShare *, TInt , TInt )
TInt CheckLock64 ( CFileShare *, TInt64 , TInt64 )
TInt CheckMount ()
TDrive & CreatedDrive ()
TBool DeleteOnClose ()
TDrive & Drive ()
TBool ExtendedFileInterfaceSupported ()
TInt FairSchedulingLen ()
CFileCache * FileCache ()
TBool FileCorrupt ()
HBufC & FileName ()
HBufC & FileNameF ()
TInt FindLock ( TInt , TInt )
TInt FindLock64 ( TInt64 , TInt64 )
void FlushAllL ()
void FlushDataL ()
IMPORT_C void InitL ( TDrive *, TDrive *, HBufC *)
TBool LocalBufferSupport ()
TInt LocalDrive ( TBusLocalDrive *&)
TTime Modified ()
CMountCB & Mount ()
TUint32 NameHash ()
TBool NotifyAsyncReadersPending ()
void ReadL ( TInt64 , TInt &, TDes8 *, const RMessagePtr2 &, TInt )
void ReadL ( TInt , TInt &, const TAny *, const RMessagePtr2 &)
TInt RemoveLock ( CFileShare *, TInt , TInt )
TInt RemoveLock64 ( CFileShare *, TInt64 , TInt64 )
void RemoveLocks ( CFileShare *)
void RenameL (const TDesC &)
void ResetReadAhead ()
IMPORT_C void SetArchiveAttribute ()
void SetAtt ( TInt )
void SetBadPower ( TBool )
void SetCachedSize64 ( TInt64 )
void SetDeleteOnClose ()
void SetEntryL (const TTime &, TUint , TUint )
void SetFileCorrupt ( TBool )
void SetLocalBufferSupport ( TBool )
IMPORT_C void SetMaxSupportedSize ( TUint64 )
void SetModified ( TTime )
void SetMount ( CMountCB *)
void SetNotifyAsyncReadersPending ( TBool )
void SetShare ( TShare )
void SetSize ( TInt )
IMPORT_C void SetSize64 ( TInt64 , TBool )
void SetSizeL ( TInt64 )
void SetSizeL ( TInt )
TShare Share ()
TInt Size ()
IMPORT_C TInt64 Size64 ()
TInt UniqueID ()
void WriteL ( TInt64 , TInt &, const TDesC8 *, const RMessagePtr2 &, TInt )
void WriteL ( TInt , TInt &, const TAny *, const RMessagePtr2 &)
Protected Member Functions
TFileLocksArray & FileLocks ()
IMPORT_C TInt GetInterface ( TInt , TAny *&, TAny *)
TInt GetInterfaceTraced ( TInt , TAny *&, TAny *)
TUint64 MaxSupportedSize (void)
Private Member Functions
TInt AddAsyncReadRequest ( CFileShare *, TInt64 , TInt , CFsRequest *)
RArray < TAsyncReadRequest > & AsyncReadRequests ()
void DemoteShare ( CFileShare *)
void NotifyAsyncReaders ()
void PromoteShare ( CFileShare *)
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()
CFsDispatchObject::CFsDispatchObject()
CFsDispatchObject::Close()
CFsDispatchObject::Dispatch()
CFsDispatchObject::DoInitL(TInt)
CFsDispatchObject::DriveNumber()const
CFsDispatchObject::IsCorrectThread()
CFsDispatchObject::~CFsDispatchObject()
CFsObject::CFsObject()
CFsObject::Container()const
CFsObject::Dec()
CFsObject::DoClose()
CFsObject::Inc()
CFsObject::Name()const
CFsObject::Open()
CFsObject::SetName(const TDesC *)
CFsObject::~CFsObject()
Protected Member Enumerations
enum TInterfaceIds { EBlockMapInterface  = 0, EGetLocalDrive  = 1, EExtendedFileInterface }
Public Attributes
HBufC * iFileName
HBufC * iFileNameF
Protected Attributes
TInt iAtt
TBool iBadPower
TBool iFileCorrupt
TTime iModified
TShare iShare
TInt iSize
Private Attributes
CFileBody * iBody
TDrive * iCreatedDrive
TDrive * iDrive
TFileLocksArray * iFileLocks
CMountCB * iMount
TDblQueLink iMountLink
TUint32 iNameHash

Constructor & Destructor Documentation

CFileCB()

IMPORT_C CFileCB ( )

~CFileCB()

IMPORT_C ~CFileCB ( )

Member Functions Documentation

AddAsyncReadRequest(CFileShare *, TInt64, TInt, CFsRequest *)

TInt AddAsyncReadRequest ( CFileShare * aFileShareP,
TInt64 aPos,
TInt aLength,
CFsRequest * aRequestP
) [private]

Parameters

CFileShare * aFileShareP
TInt64 aPos
TInt aLength
CFsRequest * aRequestP

AddLock(CFileShare *, TInt, TInt)

TInt AddLock ( CFileShare * aFileShare,
TInt aPos,
TInt aLength
)

Parameters

CFileShare * aFileShare
TInt aPos
TInt aLength

AddLock64(CFileShare *, TInt64, TInt64)

TInt AddLock64 ( CFileShare * aFileShare,
TInt64 aPos,
TInt64 aLength
)

Parameters

CFileShare * aFileShare
TInt64 aPos
TInt64 aLength

Address(TInt &)

IMPORT_C TInt Address ( TInt & aPos ) const [virtual]

Parameters

TInt & aPos

AsyncReadRequests()

RArray < TAsyncReadRequest > & AsyncReadRequests ( ) [private]

Att()

TInt Att ( ) const [inline]

Gets the file's attributes.

BadPower()

TBool BadPower ( ) const [inline]

Gets the iBadPower value.

CFileCB::iBadPower

BlockMap(SBlockMapInfo &, TInt64 &, TInt64)

TInt BlockMap ( SBlockMapInfo & aInfo,
TInt64 & aStartPos,
TInt64 aEndPos = -1
) [inline]

Retrieves the BlockMap of a file.

Parameters

SBlockMapInfo & aInfo
TInt64 & aStartPos
TInt64 aEndPos = -1

CachedSize64()

TInt64 CachedSize64 ( ) const

CancelAsyncReadRequest(CFileShare *, TRequestStatus *)

TInt CancelAsyncReadRequest ( CFileShare * aShareP,
TRequestStatus * aStatusP
)

Parameters

CFileShare * aShareP
TRequestStatus * aStatusP

CheckLock(CFileShare *, TInt, TInt)

TInt CheckLock ( CFileShare * aFileShare,
TInt aPos,
TInt aLength
)

Parameters

CFileShare * aFileShare
TInt aPos
TInt aLength

CheckLock64(CFileShare *, TInt64, TInt64)

TInt CheckLock64 ( CFileShare * aFileShare,
TInt64 aPos,
TInt64 aLength
)

Parameters

CFileShare * aFileShare
TInt64 aPos
TInt64 aLength

CheckMount()

TInt CheckMount ( )

CreatedDrive()

TDrive & CreatedDrive ( ) const [inline]

Gets a reference to the object representing the drive on which the file was created.

The 'created drive' is only different from the 'drive', as returned by Drive() , if the 'drive' was a substitute for the 'created drive' in the file server session.

DeleteOnClose()

TBool DeleteOnClose ( ) const

DemoteShare(CFileShare *)

void DemoteShare ( CFileShare * aFileShare ) [private]

Parameters

CFileShare * aFileShare

Drive()

TDrive & Drive ( ) const [inline]

Gets a reference to the object representing the drive on which the file resides.

ExtendedFileInterfaceSupported()

TBool ExtendedFileInterfaceSupported ( )

Extended API support methods

FairSchedulingLen()

TInt FairSchedulingLen ( ) const

FileCache()

CFileCache * FileCache ( ) const

File caching support methods

FileCorrupt()

TBool FileCorrupt ( ) const [inline]

Tests whether the file is corrupt.

FileLocks()

TFileLocksArray & FileLocks ( ) [protected, inline]

Gets a reference to the file share locks array being used by the file.

FileName()

HBufC & FileName ( ) const [inline]

Gets a reference to a heap descriptor containing the full file name.

FileNameF()

HBufC & FileNameF ( ) const [inline]

Gets a reference to a heap descriptor containing the folded full file name.

FindLock(TInt, TInt)

TInt FindLock ( TInt aPosLow,
TInt aPosHigh
)

Parameters

TInt aPosLow
TInt aPosHigh

FindLock64(TInt64, TInt64)

TInt FindLock64 ( TInt64 aPosLow,
TInt64 aPosHigh
)

Parameters

TInt64 aPosLow
TInt64 aPosHigh

FlushAllL()

void FlushAllL ( ) [pure virtual]

Flushes, to disk, all cached file data (e.g. attributes, modification time, file size).

The modified bit in the file attributes mask should be cleared if the flush was successful.

The function should leave with a suitable error code on error detection.

FlushDataL()

void FlushDataL ( ) [pure virtual]

Flushes, to disk, the cached information necessary for the integrity of recently written data, such as the file size.

The function should leave with a suitable error code on error detection.

GetInterface(TInt, TAny *&, TAny *)

IMPORT_C TInt GetInterface ( TInt aInterfaceId,
TAny *& aInterface,
TAny * aInput
) [protected, virtual]

Return a pointer to a specified interface extension - to allow future extension of this class without breaking binary compatibility.

Parameters

TInt aInterfaceId Interface identifier of the interface to be retrieved.
TAny *& aInterface A reference to a pointer that retrieves the specified interface.
TAny * aInput An arbitrary input argument.

GetInterfaceTraced(TInt, TAny *&, TAny *)

TInt GetInterfaceTraced ( TInt aInterfaceId,
TAny *& aInterface,
TAny * aInput
) [protected]

Parameters

TInt aInterfaceId
TAny *& aInterface
TAny * aInput

InitL(TDrive *, TDrive *, HBufC *)

IMPORT_C void InitL ( TDrive * aDrive,
TDrive * aCreatedDrive,
HBufC * aName
)

Parameters

TDrive * aDrive
TDrive * aCreatedDrive
HBufC * aName

LocalBufferSupport()

TBool LocalBufferSupport ( ) const

LocalDrive(TBusLocalDrive *&)

TInt LocalDrive ( TBusLocalDrive *& aLocalDrive ) [inline]

Retrieves TBusLocalDrive object associated with an open file.

Parameters

TBusLocalDrive *& aLocalDrive

MaxSupportedSize(void)

TUint64 MaxSupportedSize ( void ) const [protected]

Parameters

void

Modified()

TTime Modified ( ) const [inline]

Gets the universal time when the file was last modified.

Mount()

CMountCB & Mount ( ) const [inline]

Gets a reference to the object representing the mount on which the file resides.

NameHash()

TUint32 NameHash ( ) const [inline]

Gets the hash of the folded filename

NotifyAsyncReaders()

void NotifyAsyncReaders ( ) [private]

NotifyAsyncReadersPending()

TBool NotifyAsyncReadersPending ( ) const

PromoteShare(CFileShare *)

void PromoteShare ( CFileShare * aFileShare ) [private]

Parameters

CFileShare * aFileShare

ReadL(TInt64, TInt &, TDes8 *, const RMessagePtr2 &, TInt)

void ReadL ( TInt64 aPos,
TInt & aLength,
TDes8 * aDes,
const RMessagePtr2 & aMessage,
TInt aOffset
)

Parameters

TInt64 aPos
TInt & aLength
TDes8 * aDes
const RMessagePtr2 & aMessage
TInt aOffset

ReadL(TInt, TInt &, const TAny *, const RMessagePtr2 &)

void ReadL ( TInt aPos,
TInt & aLength,
const TAny * aDes,
const RMessagePtr2 & aMessage
) [pure virtual]

Reads a specified number of bytes from the open file starting at the specified postition, and writes the result into a descriptor.

It can be assumed that aPos is inside the file and aLength > 0. The file should only be read up to its end regardless of the value of aPos + aLength. The number of bytes read should be stored in aLength on return.

If the function leaves before completion for any reason it should generate an appropriate error code, and in this situation, the arguments are not valid on return.

Parameters

TInt aPos Represents a position relative to the start of the file where ReadL() should start to read.
TInt & aLength On entry, specifies the number of bytes to be read from the file. On return, this should contain the number of bytes read, but this is not valid if the function leaves.
const TAny * aDes Pointer to a descriptor into which the data should be written.
const RMessagePtr2 & aMessage

RemoveLock(CFileShare *, TInt, TInt)

TInt RemoveLock ( CFileShare * aFileShare,
TInt aPos,
TInt aLength
)

Parameters

CFileShare * aFileShare
TInt aPos
TInt aLength

RemoveLock64(CFileShare *, TInt64, TInt64)

TInt RemoveLock64 ( CFileShare * aFileShare,
TInt64 aPos,
TInt64 aLength
)

Parameters

CFileShare * aFileShare
TInt64 aPos
TInt64 aLength

RemoveLocks(CFileShare *)

void RemoveLocks ( CFileShare * aFileShare )

Parameters

CFileShare * aFileShare

RenameL(const TDesC &)

void RenameL ( const TDesC & aNewName ) [pure virtual]

Renames the file with the full file name provided.

Because the full name of the file includes the path, the function can also be used to move the file.

It can be assumed that no other sub-session has access to the file: i.e. the file has not been opened in EFileShareAny share mode. It can also be assumed that the file has been opened for writing.

The function should leave with KErrAlreadyExists if aNewName already exists. An appropriate error code should also be generated if the function leaves before completion for any other reason.

CFileCB::iFileName

Parameters

const TDesC & aNewName The new full name of the file.

ResetReadAhead()

void ResetReadAhead ( )

SetArchiveAttribute()

IMPORT_C void SetArchiveAttribute ( )

SetAtt(TInt)

void SetAtt ( TInt aAtt ) [inline]

Sets the file's attributes.

Parameters

TInt aAtt The file attribute bit mask.

SetBadPower(TBool)

void SetBadPower ( TBool aBadPower ) [inline]

Sets the iBadPower value.

CFileCB::iBadPower

Parameters

TBool aBadPower ETrue, if an operation on the file has failed due to bad power; EFalse if power has been found to be good.

SetCachedSize64(TInt64)

void SetCachedSize64 ( TInt64 aSize )

Parameters

TInt64 aSize

SetDeleteOnClose()

void SetDeleteOnClose ( )

SetEntryL(const TTime &, TUint, TUint)

void SetEntryL ( const TTime & aTime,
TUint aMask,
TUint aVal
) [pure virtual]

Sets the attribute mask, iAtt, and the modified time of the file, iModified.

If aMask|aVal does not equal zero, then aMask should be OR'ed with iAtt, whilst the inverse of aVal should be AND'ed with iAtt. If the modified flag is set in aMask then iModified should be set to aTime.

The function should leave with a suitable error code on error detection.

CFileCB::iModified CFileCB::iAtt

Parameters

const TTime & aTime The new modified time, if the modified flag is set in aMask.
TUint aMask Bit mask containing bits set (to 1) that are to be set (to 1) in iAtt.
TUint aVal Bitmask containing bits set (to 1) that are to be unset (to 0) in iAtt.

SetFileCorrupt(TBool)

void SetFileCorrupt ( TBool aFileCorrupt ) [inline]

Sets whether the file is corrupt.

Parameters

TBool aFileCorrupt ETrue, if the file is corrupt; EFalse, otherwise.

SetLocalBufferSupport(TBool)

void SetLocalBufferSupport ( TBool aEnabled )

Parameters

TBool aEnabled

SetMaxSupportedSize(TUint64)

IMPORT_C void SetMaxSupportedSize ( TUint64 aMaxFileSize )

Parameters

TUint64 aMaxFileSize

SetModified(TTime)

void SetModified ( TTime aModified ) [inline]

Sets the universal time when the file was last modified.

Parameters

TTime aModified The universal time when the file was last modified.

SetMount(CMountCB *)

void SetMount ( CMountCB * aMount ) [inline]

Sets the mount associated with the file.

Parameters

CMountCB * aMount The mount.

SetNotifyAsyncReadersPending(TBool)

void SetNotifyAsyncReadersPending ( TBool aNotifyAsyncReadersPending )

Parameters

TBool aNotifyAsyncReadersPending

SetShare(TShare)

void SetShare ( TShare aShare ) [inline]

Sets the iShare value, which defines the level of access allowed to the file.

CFileCB::iShare

Parameters

TShare aShare The new value.

SetSize(TInt)

void SetSize ( TInt aSize ) [inline]

Sets the size of the file.

Parameters

TInt aSize The size of the file.

SetSize64(TInt64, TBool)

IMPORT_C void SetSize64 ( TInt64 aSize,
TBool aDriveLocked
)

Parameters

TInt64 aSize
TBool aDriveLocked

SetSizeL(TInt64)

void SetSizeL ( TInt64 aSize )

Parameters

TInt64 aSize

SetSizeL(TInt)

void SetSizeL ( TInt aSize ) [pure virtual]

Extends or truncates the file by re-setting the file size.

The function should not change iModified and iSize attributes of the file object: this is done by the file server. If the file is extended, nothing should be written in the extended area.

The function should leave with a suitable error code on error detection.

leave
KErrDiskFull The operation cannot be completed because the disk is full.
CFileCB::iModified CFileCB::iSize

Parameters

TInt aSize The new file size in number of bytes.

Share()

TShare Share ( ) const [inline]

Gets the iShare value, which defines the level of access allowed to the file.

CFileCB::iShare

Size()

TInt Size ( ) const [inline]

Gets the size of the file.

Size64()

IMPORT_C TInt64 Size64 ( ) const

UniqueID()

TInt UniqueID ( ) const [inline]

Gets the file object's unique ID, as returned by CObject::UniqueID() .

CObject

WriteL(TInt64, TInt &, const TDesC8 *, const RMessagePtr2 &, TInt)

void WriteL ( TInt64 aPos,
TInt & aLength,
const TDesC8 * aDes,
const RMessagePtr2 & aMessage,
TInt aOffset
)

Parameters

TInt64 aPos
TInt & aLength
const TDesC8 * aDes
const RMessagePtr2 & aMessage
TInt aOffset

WriteL(TInt, TInt &, const TAny *, const RMessagePtr2 &)

void WriteL ( TInt aPos,
TInt & aLength,
const TAny * aDes,
const RMessagePtr2 & aMessage
) [pure virtual]

Writes data to the open file.

iModified and iSize are set by the file server after this function has completed successfully.

It can be assumed that aPos is within the file range and aLength > 0. When aPos + aLength is greater than the file size then the file should be enlarged using SetSizeL() . The number of bytes written should be returned through the argument aLength.

If the function leaves before completion for any reason it should generate an appropriate error code, and in this situation the arguments are not valid on return.

CFileCB::iModified CFileCB::iSize CFileCB::SetSizeL
leave
KErrDiskFull The operation cannot be completed because the disk is full.

Parameters

TInt aPos Represents a position relative to the start of the file where WriteL() should start to write.
TInt & aLength Specifies the number of bytes to be written to the file. On return, the number of bytes written, but this is not valid if the function leaves.
const TAny * aDes Pointer to a descriptor containing the data to be written to the file.
const RMessagePtr2 & aMessage

Member Enumerations Documentation

Enum TInterfaceIds

Enumerators

EBlockMapInterface = 0
EGetLocalDrive = 1
EExtendedFileInterface

Member Data Documentation

TInt iAtt

TInt iAtt [protected]

The attributes of the file.

TBool iBadPower

TBool iBadPower [protected]

Indicates whether a recent access to the file that the object represents failed due to KErrBadPower.

CFileBody * iBody

CFileBody * iBody [private]

TDrive * iCreatedDrive

TDrive * iCreatedDrive [private]

TDrive * iDrive

TDrive * iDrive [private]

TBool iFileCorrupt

TBool iFileCorrupt [protected]

Indicates whether the file that the object represents is corrupt: true if it is corrupt, false otherwise.

TFileLocksArray * iFileLocks

TFileLocksArray * iFileLocks [private]

HBufC * iFileName

HBufC * iFileName

The full name of the file, including drive and extensions.

HBufC * iFileNameF

HBufC * iFileNameF

The full name of the file, including drive and extensions - Folded.

TTime iModified

TTime iModified [protected]

The universal time at which the file was last modified.

CMountCB * iMount

CMountCB * iMount [private]

TDblQueLink iMountLink

TDblQueLink iMountLink [private]

TUint32 iNameHash

TUint32 iNameHash [private]

TShare iShare

TShare iShare [protected]

Inititally, the mode that the file was opened with, which defines the level of access allowed to the file. Set by the TDrive object (representing the drive on which the file resides) when the file control block is created.

TInt iSize

TInt iSize [protected]

The size of the file. This is the low 32 bit part of the file size. The upper 32 bit part of the file size is saved on the file server side for File Systems supporting file size > 4GB - 1. File Systems supporting file size > 4GB - 1 shall use CFileCB::Size64() to query the file size and CFileCB::SetSize64() to set file size.