CFileMan Class Reference

class CFileMan : public CFileBase

Offers file management services which accept the use of wildcards; synchronous and asynchronous.

It also provides enquiry functions, which, like those provided by the base class CFileBase, may be used by an observer class object to provide the user with information about the progress of the operation.

All of the file management functions provided by this class accept the use of wildcards, and may operate either synchronously or asynchronously. When CFileMan is operating asynchronously, the operation takes place in a separate thread from the calling code.

A file notification observer (an instance of a class deriving from MFileManObserver) may optionally be used by CFileMan when operating synchronously or asynchronously. If provided, the appropriate notification function is called before or after each entry has been processed, or during a file copy or move. This notification can be used to provide information about the state of the operation, such as the number of bytes transferred during a large-scale file copy. It can also be used to allow the user to cancel, retry or continue processing an entry, or to abort the whole operation. If such notification is required, specify an object deriving from MFileManObserver class in the constructor, or call SetObserver(), defined in the base class, CFileBase.

All of the file manipulation functions except Rename() may operate recursively, and all can operate non-recursively. When operating recursively, these functions will act on all matching files located throughout the source directory s hierarchy. When operating non-recursively, these functions act upon files contained in the single top level source directory only. Recursion is set or unset using the switch parameter to these functions.

This class is not intended for user derivation.

Note:

To support wildcard, CFileMan needs to store the entire directory entry information. Therefore, in a extreme condition, if a directory contains a huge number of files (e.g. more than 15000 files with 10 characters' long file names), user may encounter KErrNoMemory errors. Developers who have a need to handle this rare case should increase the heap size limitation of their applications.

For more information about heap size configuration, please refer following section in Symbian Developer Library: Symbian OS build guide >> Build Tools Reference >> MMP file syntax >> epocheapsize

MFileManObserver

Inherits from

Public Member Functions
~CFileMan()
IMPORT_C TIntAttribs(const TDesC &, TUint, TUint, const TTime &, TUint)
IMPORT_C TIntAttribs(const TDesC &, TUint, TUint, const TTime &, TUint, TRequestStatus &)
IMPORT_C TIntBytesTransferredByCopyStep()
IMPORT_C TIntCopy(const TDesC &, const TDesC &, TUint)
IMPORT_C TIntCopy(const TDesC &, const TDesC &, TUint, TRequestStatus &)
IMPORT_C TIntCopy(const RFile &, const TDesC &, TUint)
IMPORT_C TIntCopy(const RFile &, const TDesC &, TUint, TRequestStatus &)
IMPORT_C TActionCurrentAction()
IMPORT_C TIntDelete(const TDesC &, TUint)
IMPORT_C TIntDelete(const TDesC &, TUint, TRequestStatus &)
IMPORT_C voidGetCurrentSource(TFileName &)
IMPORT_C voidGetCurrentTarget(TFileName &)
IMPORT_C TIntMove(const TDesC &, const TDesC &, TUint)
IMPORT_C TIntMove(const TDesC &, const TDesC &, TUint, TRequestStatus &)
IMPORT_C CFileMan *NewL(RFs &)
IMPORT_C CFileMan *NewL(RFs &, MFileManObserver *)
IMPORT_C TIntRename(const TDesC &, const TDesC &, TUint)
IMPORT_C TIntRename(const TDesC &, const TDesC &, TUint, TRequestStatus &)
IMPORT_C TIntRmDir(const TDesC &)
IMPORT_C TIntRmDir(const TDesC &, TRequestStatus &)
Protected Member Functions
CFileMan(RFs &)
TInt RenameInvalidEntry(const TDesC &, const TDesC &, TUint)
Private Member Functions
voidCheckForDirectory()
TInt CheckRenameAllowed(const TDesC &, const TDesC &)
voidCompleteOperationL()
voidDoAttribsL()
TInt DoCopy(const RFile &, RFile &, TInt &)
voidDoCopyFromHandleL()
voidDoCopyOrMoveL()
voidDoDeleteL()
voidDoOperationL()
voidDoRenameL()
voidDoRmDirL()
voidDoSynchronize(TInt)
voidGetSrcAndTrg(TParse &, TFileName &)
voidSetFlags(TBool, TBool, TBool, TBool)
TInt SetupDirectoryForMove(TBool &)
TInt SetupMoveAcrossDrives(TUint)
TInt SetupMoveOnSameDrive(TUint, TBool &)
TInt SetupTargetDirectory(TBool, TBool &)
TBool SrcTrgDrivesIdentical()
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()
CFileBase::AbbreviatedPath()
CFileBase::CFileBase(RFs &)
CFileBase::ConstructL()
CFileBase::CurrentEntry()
CFileBase::FullPath()
CFileBase::GetLastError()
CFileBase::GetMoreInfoAboutError()
CFileBase::RunInSeparateThreadL(TThreadFunction)
CFileBase::RunL()
CFileBase::SetObserver(MFileManObserver *)
CFileBase::~CFileBase()
Public Member Enumerations
enumTAction {
ENone, EAttribs, ECopy, EDelete, EMove, ERename, ERmDir, ERenameInvalidEntry, ECopyFromHandle
}
enumTSwitch { EOverWrite = 1, ERecurse = 2 }
Private Member Enumerations
enumTInternalAction {
EInternalNone, EInternalAttribs, EInternalCopy, EInternalDelete, EInternalCopyForMove, EInternalRenameForMove, EInternalRename, EInternalRmDir, EInternalRenameInvalidEntry, EInternalCopyFromHandle
}
Private Attributes
TInternalAction iAction
TInt iBytesTransferred
TUint iClearMask
TBool iMovingContents
TUint iSetMask
RFile iSrcFileHandle
TTime iTime
TEntry iTmpEntry
TFileName iTmpName1
TFileName iTmpName2
TParse iTmpParse
TParse iTrgFile
Inherited Attributes
CFileBase::iCurrentEntry
CFileBase::iDirList
CFileBase::iErrorInfo
CFileBase::iFManThread
CFileBase::iFs
CFileBase::iFsOld
CFileBase::iLastError
CFileBase::iMatchEntry
CFileBase::iNumberOfFilesProcessed
CFileBase::iObserver
CFileBase::iScanner
CFileBase::iSessionPath
CFileBase::iSrcFile
CFileBase::iStatus
CFileBase::iSwitches
CFileBase::iSynchronizer

Constructor & Destructor Documentation

CFileMan(RFs &)

CFileMan(RFs &aFs)[protected]

Parameters

RFs & aFs

~CFileMan()

~CFileMan()

Member Functions Documentation

Attribs(const TDesC &, TUint, TUint, const TTime &, TUint)

IMPORT_C TIntAttribs(const TDesC &aName,
TUintaSetMask,
TUintaClearMask,
const TTime &aTime,
TUintaSwitch = 0
)

Parameters

const TDesC & aName
TUint aSetMask
TUint aClearMask
const TTime & aTime
TUint aSwitch = 0

Attribs(const TDesC &, TUint, TUint, const TTime &, TUint, TRequestStatus &)

IMPORT_C TIntAttribs(const TDesC &aName,
TUintaSetMask,
TUintaClearMask,
const TTime &aTime,
TUintaSwitch,
TRequestStatus &aStatus
)

Parameters

const TDesC & aName
TUint aSetMask
TUint aClearMask
const TTime & aTime
TUint aSwitch
TRequestStatus & aStatus

BytesTransferredByCopyStep()

IMPORT_C TIntBytesTransferredByCopyStep()

CheckForDirectory()

voidCheckForDirectory()[private]

CheckRenameAllowed(const TDesC &, const TDesC &)

TInt CheckRenameAllowed(const TDesC &aSrcName,
const TDesC &aTrgName
)[private]

Parameters

const TDesC & aSrcName
const TDesC & aTrgName

CompleteOperationL()

voidCompleteOperationL()[private, virtual]

Called from RunL to perform tidy up after an operation.

CFileMan

CFileBase::RunL

Copy(const TDesC &, const TDesC &, TUint)

IMPORT_C TIntCopy(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch = EOverWrite
)

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch = EOverWrite

Copy(const TDesC &, const TDesC &, TUint, TRequestStatus &)

IMPORT_C TIntCopy(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch,
TRequestStatus &aStatus
)

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch
TRequestStatus & aStatus

Copy(const RFile &, const TDesC &, TUint)

IMPORT_C TIntCopy(const RFile &anOld,
const TDesC &aNew,
TUintaSwitches = EOverWrite
)

Parameters

const RFile & anOld
const TDesC & aNew
TUint aSwitches = EOverWrite

Copy(const RFile &, const TDesC &, TUint, TRequestStatus &)

IMPORT_C TIntCopy(const RFile &anOld,
const TDesC &aNew,
TUintaSwitches,
TRequestStatus &aStatus
)

Parameters

const RFile & anOld
const TDesC & aNew
TUint aSwitches
TRequestStatus & aStatus

CurrentAction()

IMPORT_C TActionCurrentAction()

Delete(const TDesC &, TUint)

IMPORT_C TIntDelete(const TDesC &aName,
TUintaSwitch = 0
)

Parameters

const TDesC & aName
TUint aSwitch = 0

Delete(const TDesC &, TUint, TRequestStatus &)

IMPORT_C TIntDelete(const TDesC &aName,
TUintaSwitch,
TRequestStatus &aStatus
)

Parameters

const TDesC & aName
TUint aSwitch
TRequestStatus & aStatus

DoAttribsL()

voidDoAttribsL()[private]

DoCopy(const RFile &, RFile &, TInt &)

TInt DoCopy(const RFile &aSrcFile,
RFile &aDstFile,
TInt &aRet
)[private]

Parameters

const RFile & aSrcFile
RFile & aDstFile
TInt & aRet

DoCopyFromHandleL()

voidDoCopyFromHandleL()[private]

DoCopyOrMoveL()

voidDoCopyOrMoveL()[private]

DoDeleteL()

voidDoDeleteL()[private]

DoOperationL()

voidDoOperationL()[private, virtual]

Called from RunL to perform the requested operation.

CFileMan

CFileBase::RunL

DoRenameL()

voidDoRenameL()[private]

DoRmDirL()

voidDoRmDirL()[private]

DoSynchronize(TInt)

voidDoSynchronize(TIntaRetVal)[private]

Parameters

TInt aRetVal

GetCurrentSource(TFileName &)

IMPORT_C voidGetCurrentSource(TFileName &aFile)

Parameters

TFileName & aFile

GetCurrentTarget(TFileName &)

IMPORT_C voidGetCurrentTarget(TFileName &aFile)

Parameters

TFileName & aFile

GetSrcAndTrg(TParse &, TFileName &)

voidGetSrcAndTrg(TParse &aSrcName,
TFileName &aTrgName
)[private]

Parameters

TParse & aSrcName
TFileName & aTrgName

Move(const TDesC &, const TDesC &, TUint)

IMPORT_C TIntMove(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch = EOverWrite
)

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch = EOverWrite

Move(const TDesC &, const TDesC &, TUint, TRequestStatus &)

IMPORT_C TIntMove(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch,
TRequestStatus &aStatus
)

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch
TRequestStatus & aStatus

NewL(RFs &)

IMPORT_C CFileMan *NewL(RFs &aFs)[static]

Parameters

RFs & aFs

NewL(RFs &, MFileManObserver *)

IMPORT_C CFileMan *NewL(RFs &aFs,
MFileManObserver *anObserver
)[static]

Parameters

RFs & aFs
MFileManObserver * anObserver

Rename(const TDesC &, const TDesC &, TUint)

IMPORT_C TIntRename(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch = EOverWrite
)

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch = EOverWrite

Rename(const TDesC &, const TDesC &, TUint, TRequestStatus &)

IMPORT_C TIntRename(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch,
TRequestStatus &aStatus
)

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch
TRequestStatus & aStatus

RenameInvalidEntry(const TDesC &, const TDesC &, TUint)

TInt RenameInvalidEntry(const TDesC &anOld,
const TDesC &aNew,
TUintaSwitch = EOverWrite
)[protected]

Parameters

const TDesC & anOld
const TDesC & aNew
TUint aSwitch = EOverWrite

RmDir(const TDesC &)

IMPORT_C TIntRmDir(const TDesC &aDirName)

Parameters

const TDesC & aDirName

RmDir(const TDesC &, TRequestStatus &)

IMPORT_C TIntRmDir(const TDesC &aDirName,
TRequestStatus &aStatus
)

Parameters

const TDesC & aDirName
TRequestStatus & aStatus

SetFlags(TBool, TBool, TBool, TBool)

voidSetFlags(TBoolaOverWrite,
TBoolaRecurse,
TBoolaScanDirection,
TBoolaMoveRename
)[private]

Parameters

TBool aOverWrite
TBool aRecurse
TBool aScanDirection
TBool aMoveRename

SetupDirectoryForMove(TBool &)

TInt SetupDirectoryForMove(TBool &aSrcIsDir)[private]

Parameters

TBool & aSrcIsDir

SetupMoveAcrossDrives(TUint)

TInt SetupMoveAcrossDrives(TUintaSwitches)[private]

Parameters

TUint aSwitches

SetupMoveOnSameDrive(TUint, TBool &)

TInt SetupMoveOnSameDrive(TUintaSwitches,
TBool &aComplete
)[private]

Parameters

TUint aSwitches
TBool & aComplete

SetupTargetDirectory(TBool, TBool &)

TInt SetupTargetDirectory(TBoolaOverWrite,
TBool &aComplete
)[private]

Parameters

TBool aOverWrite
TBool & aComplete

SrcTrgDrivesIdentical()

TBool SrcTrgDrivesIdentical()[private]

Member Enumerations Documentation

Enum TAction

An enumeration that identifies CFileMan tasks. This enumeration is used by CurrentAction() to identify which task currently being carried out.

CFileMan::CurrentAction

Enumerators

ENone

Inactive

EAttribs

Setting attributes

ECopy

Copying files

EDelete

Deleting files

EMove

Moving files

ERename

Renaming files

ERmDir

Deleting a directory and all contents

ERenameInvalidEntry

Renaming component to VFAT short name (guaranteed to be unique)

ECopyFromHandle

Copying file from open file handle

Enum TInternalAction

This is an internal enumeration for CFileMan implementation. THis enumeration is mapped into TAction when user wants to identify the current task of CFileMan by CurrentAction().

CFileMan::TAction

CFileMan::CurrentAction

Enumerators

EInternalNone

Internal indicator for None operation. This is mapped to CFileMan::ENone.

EInternalAttribs

Internal indicator for Attribs() operation. This is mapped to CFileMan::EAttribs.

EInternalCopy

Internal indicator for Copy() operation. This is mapped to CFileMan::ECopy.

EInternalDelete

Internal indicator for Delete() operation. This is mapped to CFileMan::EDelete.

EInternalCopyForMove

Internal indicator for Move() operation on different drives. This is mapped to CFileMan::Move.

EInternalRenameForMove

Internal indicator for Move() operation on the same drive. This is mapped to CFileMan::Rename. Note for compatibility reasons, it is not mapped to CFileMan::Move.

EInternalRename

Internal indicator for Rename() operation. This is mapped to CFileMan::ERename.

EInternalRmDir

Internal indicator for RmDir() operation. This is mapped to CFileMan::ERmDir.

EInternalRenameInvalidEntry

Internal indicator for RenameInvalidEntry() operation. This is mapped to CFileMan::ERenameInvalidEntry.

EInternalCopyFromHandle

Internal indicator for CopyFromHandle() operation. This is mapped to CFileMan::ECopyFromHandle.

Enum TSwitch

Overwriting and recursion switch.

Used in CFileMan functions to set whether operations are applied to the specified directory and all directories below it, or the specified directory only.

Enumerators

EOverWrite = 1

Any files in the destination directory that have the same name as the source files in a rename, move or copy operation, will be overwritten.

ERecurse = 2

Recursive operation.

Member Data Documentation

TInternalAction iAction

TInternalAction iAction[private]

TInt iBytesTransferred

TInt iBytesTransferred[private]

TUint iClearMask

TUint iClearMask[private]

TBool iMovingContents

TBool iMovingContents[private]

TUint iSetMask

TUint iSetMask[private]

RFile iSrcFileHandle

RFile iSrcFileHandle[private]

TTime iTime

TTime iTime[private]

TEntry iTmpEntry

TEntry iTmpEntry[private]

TFileName iTmpName1

TFileName iTmpName1[private]

TFileName iTmpName2

TFileName iTmpName2[private]

TParse iTmpParse

TParse iTmpParse[private]

TParse iTrgFile

TParse iTrgFile[private]