|
|
|||
Location:
f32file.h
Link against: efsrv.lib
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 directorys 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.
Defined in CFileMan:
Attribs(), Attribs(), BytesTransferredByCopyStep(), Copy(), Copy(), Copy(), Copy(), CurrentAction(), Delete(), Delete(), EAttribs, ECopy, ECopyFromHandle, EDelete, EMove, ENone, EOverWrite, ERecurse, ERename, ERenameInvalidEntry, ERmDir, GetCurrentSource(), GetCurrentTarget(), Move(), Move(), NewL(), NewL(), Rename(), Rename(), RmDir(), RmDir(), TAction, TSwitch
Inherited from CBase:
Extension_(),
operator new()
Inherited from CFileBase:
AbbreviatedPath(),
CompleteOperationL(),
ConstructL(),
CurrentEntry(),
DoOperationL(),
FullPath(),
GetLastError(),
GetMoreInfoAboutError(),
RunInSeparateThreadL(),
RunL(),
SetObserver(),
iCurrentEntry,
iDirList,
iErrorInfo,
iFManThread,
iFs,
iFsOld,
iLastError,
iMatchEntry,
iNumberOfFilesProcessed,
iObserver,
iScanner,
iSessionPath,
iSrcFile,
iStatus,
iSwitches,
iSynchronizer
static IMPORT_C CFileMan *NewL(RFs &aFs);
Constructs and allocates memory for a new CFileMan object.
|
|
static IMPORT_C CFileMan *NewL(RFs &aFs, MFileManObserver *anObserver);
Constructs and allocates memory for a new CFileMan object with an observer.
|
|
IMPORT_C TAction CurrentAction();
Gets the action which CFileMan is currently carrying out.
|
IMPORT_C void GetCurrentTarget(TFileName &aFile);
Gets the name of the target file for the CFileMan operation currently being carried out.
This function is relevant when copying, moving or renaming files.
|
IMPORT_C void GetCurrentSource(TFileName &aFile);
Gets the name of the source file or directory for the CFileMan operation currently being carried out.
The source is the file or directory which is being copied, moved or deleted.
|
IMPORT_C TInt BytesTransferredByCopyStep();
Gets the number of bytes transferred during a copy or move operation.
Large files are copied and moved in stages. After each portion of the source file has been copied to the target, the number of bytes transferred is updated. This function may be called from MFileManObserver::NotifyFileManOperation() and may be used to support the increment of progress bars.
|
| Capability: | Dependent | If aName is /Sys then Tcb capability is required. If aName begins with /Private and does not match this process' SID then AllFiles capability is required. If aName is /Resource then Tcb capability is required. |
IMPORT_C TInt Attribs(const TDesC &aName, TUint aSetMask, TUint aClearMask, const TTime &aTime, TUint aSwitch=0);
Sets or clears attributes for one or more files using two bitmasks
This is a synchronous function.
The first bitmask specifies the attributes to be set. The second specifies the attributes to be cleared. The date and time of the files' last modification can also be changed.
The function can operate recursively or non-recursively. When operating non-recursively, only the matching files located in the directory specified in aName are affected. When operating recursively, all matching files in the directory hierarchy below the directory specified in aName will be affected.
Notes:
1. A panic is raised if any attribute is specified in both bitmasks.
2. Attempting to change the attributes for an open file results in an error for that file, as retrieved by CFileBase::GetLastError().
3. An attempt to set or clear the KEntryAttDir or KEntryAttVolume attribute for a file or directory will have no effect.
|
|
| Capability: | Dependent | If aName is /Sys then Tcb capability is required. If aName begins with /Private and does not match this process' SID then AllFiles capability is required. If aName is /Resource then Tcb capability is required. |
IMPORT_C TInt Attribs(const TDesC &aName, TUint aSetMask, TUint aClearMask, const TTime &aTime, TUint aSwitch, TRequestStatus &aStatus);
Sets or clears attributes for one or more files using two bitmasks.
This is an asycnhronous function. Its behaviour is the same as the synchronous overload.
|
|
| Capability: | Dependent | If the path for anOld begins with /Sys then Tcb capability is required. If the path for anOld begins with /Resource then Tcb capability is required. |
| Capability: | AllFiles |
IMPORT_C TInt Copy(const TDesC &anOld, const TDesC &aNew, TUint aSwitch=EOverWrite);
Copies one or more files.
This is a synchronous function.
Optionally, this function can be set to overwrite any files with the same name which exist in the target directory. If the flag is set for no overwriting, then any files with the same name will not be overwritten, and an error (KErrAlreadyExists) will be returned for that file. Error codes may be retrieved using CFileBase::GetLastError().
If recursive operation is set, all intermediate directories will be created, including any directories in the path specified by aNew which do not already exist.
If recursive operation is not set, only the matching files located in the single directory specified in anOld are copied. No intermediate directories will be created; if any directories in the destination path do not exist, no files will be copied, and this function will return KErrPathNotFound.
Notes:
1. Files can be copied across drives.
2. Open files can be copied if they have been opened using the EFileShareReadersOnly file share mode.
3. Read-only, hidden and system files can be copied and the source file's attributes are preserved in the target file.
|
|
CFileBase::GetLastError| Capability: | Dependent | If the path for aNew begins with /Sys then Tcb capability is required. If the path for aNew begins with /Resource then Tcb capability is required. |
| Capability: | AllFiles |
IMPORT_C TInt Copy(const TDesC &anOld, const TDesC &aNew, TUint aSwitch, TRequestStatus &aStatus);
Copies one or more files.
This is an asycnhronous function. Its behaviour is the same as the synchronous overload.
|
|
| Capability: | Dependent | If aName is /Sys then Tcb capability is required. If aName begins with /Private and does not match this process' SID then AllFiles capability is required. If aName is /Resource then Tcb capability is required. |
IMPORT_C TInt Delete(const TDesC &aName, TUint aSwitch=0);
Deletes one or more files.
This is a synchronous function.
This function can operate recursively or non-recursively. When operating non-recursively, only the matching files located in the directory specified in aName are affected. When operating recursively, all matching files in the directory hierarchy below the directory specified in aName will be deleted.
Note that read-only and open files may not be deleted. Attempting to do so will return an error for that file. Error codes may be retrieved using CFileBase::GetLastError().
|
|
CFileBase::GetLastError| Capability: | Dependent | If aName is /Sys then Tcb capability is required. If aName begins with /Private and does not match this process' SID then AllFiles capability is required. If aName is /Resource then Tcb capability is required. |
IMPORT_C TInt Delete(const TDesC &aName, TUint aSwitch, TRequestStatus &aStatus);
Deletes one or more files.
This is an asycnhronous function. Its behaviour is the same as the synchronous overload.
|
|
| Capability: | Dependent | If the path in aNew starts with /Sys then capability Tcb is required If the path in aNew starts with /Resource then capability Tcb is required If the path in anOld starts with /Sys then Tcb capability is required. If the path in anOld starts with /Resource then Tcb capability is required. |
| Capability: | AllFiles |
IMPORT_C TInt Move(const TDesC &anOld, const TDesC &aNew, TUint aSwitch=EOverWrite);
Moves one or more files.
This is a synchronous function.
Optionally, this function can be set to overwrite any files with the same name which exist in the target directory. If the flag is set for no overwriting, then any files with the same name will not be overwritten, and an error (KErrAlreadyExists) will be returned for that file. Error codes may be retrieved using CFileBase::GetLastError(). By default, when the function is operating synchronously, files are overwritten.
When this function is operating recursively, all intermediate directories will be created, including all directories in the destination path specified by aNew which do not already exist.
If recursive operation is not set, only the matching files located in the single directory specified in anOld are moved. No intermediate directories will be created; if any directories in the destination path do not exist, no files will be moved, and this function will return KErrPathNotFound.
Notes:
1. Read-only, hidden and system files can be moved and the source file's attributes are preserved in the target file, but open files cannot be moved. Attempting to move an open file will return an error for that file, as retrieved by CFileBase::GetLastError().
|
|
CFileBase::GetLastError| Capability: | Dependent | If the path in aNew starts with /Sys then capability Tcb is required If the path in aNew starts with /Resource then capability Tcb is required If the path in anOld starts with /Sys then Tcb capability is required. If the path in anOld starts with /Resource then Tcb capability is required. |
| Capability: | AllFiles |
IMPORT_C TInt Move(const TDesC &anOld, const TDesC &aNew, TUint aSwitch, TRequestStatus &aStatus);
Moves one or more files.
This is an asycnhronous function. Its behaviour is the same as the synchronous overload.
|
|
| Capability: | Dependent | If either aName or aNewName is /Sys then Tcb capability is required. If either aName or aNewName begins with /Private and does not match this process' SID then AllFiles capability is required. If either aName or aNewName is /Resource then Tcb capability is required. |
IMPORT_C TInt Rename(const TDesC &anOld, const TDesC &aNew, TUint aSwitch=EOverWrite);
Renames one or more files.
This is a synchronous function.
The function can also be used to move files by specifying different destination and source directories. Note that the destination and source directories must be on the same drive.
If this function is being used to move files, an option is provided to allow the user to overwrite any files with the same name which may exist in the target directory. If the flag is set for no overwriting, any files with the same name will not be overwritten, and an error (KErrAlreadyExists) will be returned for that file, as retrieved by CFileBase::GetLastError().
This function can only operate non-recursively, so that only the matching files located in the single directory specified by anOld may be renamed.
Notes:
1. Read-only, hidden and system files can be moved and the source file's attributes are preserved in the target file, but open files cannot be moved. Attempting to move an open file will return an error for that file, as retrieved by CFileBase::GetLastError().
|
|
CFileBase::GetLastError| Capability: | Dependent | If either aName or aNewName is /Sys then Tcb capability is required. If either aName or aNewName begins with /Private and does not match this process' SID then AllFiles capability is required. If either aName or aNewName is /Resource then Tcb capability is required. |
IMPORT_C TInt Rename(const TDesC &anOld, const TDesC &aNew, TUint aSwitch, TRequestStatus &aStatus);
Renames one or more files.
This is an asycnhronous function. Its behaviour is the same as the synchronous overload.
|
|
| Capability: | Dependent | If aDirName starts with /Sys then Tcb capability is required. If aDirName begins with /Private and does not match this process' SID then AllFiles capability is required. If aDirName starts with /Resource then Tcb capability is required. |
IMPORT_C TInt RmDir(const TDesC &aDirName);
Deletes a directory and all files and directories contained in the directory structure below it.
This is a synchronous function.
The function cannot be used non-recursively. For a non-recursive directory deletion, use RFs::RmDir().
Note:
1. All files in the directory hierarchy to be deleted must be closed and none may have the read-only attribute. Otherwise, not all of the hierarchy will be deleted, and this function will return KErrInUse.
|
|
| Capability: | Dependent | If aDirName starts with /Sys then Tcb capability is required. If aDirName begins with /Private and does not match this process' SID then AllFiles capability is required. If aDirName starts with /Resource then Tcb capability is required. |
IMPORT_C TInt RmDir(const TDesC &aDirName, TRequestStatus &aStatus);
Deletes a directory and all files and directories contained in the directory structure below it.
Other than being asynchronous, the behaviour of this function is the same as is documented in its synchronous overload.
|
|
| Capability: | Dependent | If the path for aNew begins with /Sys then Tcb capability is required. If the path for aNew begins with /Private and does not match this process' SID then AllFiles capability is required. If the path for aNew begins with /Resource then Tcb capability is required. |
IMPORT_C TInt Copy(const RFile &anOld, const TDesC &aNew, TUint aSwitches=EOverWrite);
Copies from an open file handle to a destination file name.
This is a synchronous function.
Optionally, this function can be set to overwrite the target file. If the flag is set for no overwriting and the target file already exists, then the target file will not be overwritten, and an error (KErrAlreadyExists) will be returned. Error codes may be retrieved using CFileBase::GetLastError().
Notes:
1. The file can be copied across drives.
2. Read-only, hidden and system files can be copied and the source file's attributes are preserved in the target file.
|
|
CFileBase::GetLastError| Capability: | Dependent | If the path for aNew begins with /Sys then Tcb capability is required. If the path for aNew begins with /Private and does not match this process' SID then AllFiles capability is required. If the path for aNew begins with /Resource then Tcb capability is required. |
IMPORT_C TInt Copy(const RFile &anOld, const TDesC &aNew, TUint aSwitches, TRequestStatus &aStatus);
Copies from an open file handle to a destination file name.
This is an asycnhronous function. Its behaviour is the same as the synchronous overload.
|
|
CFileBase::GetLastErrorTAction
An enumeration that identifies CFileMan tasks. This enumeration is used by CurrentAction() to identify which task currently being carried out.
CFileMan::CurrentAction
|
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.
|