class EikFileUtils |
Provides a set of drive, path and file utility functions.
This class is essentially a thin layer over the BaflUtils class.
Private Member Functions | |
---|---|
EikFileUtils() |
void | AbbreviateFileName | ( | const TFileName & | aOriginalFileName, |
TDes & | aAbbreviatedFileName | |||
) | [static, inline] |
Abbreviates a file name.
If aOriginalFileName is less than the maximum length of aAbbreviatedFileName, then the name is simply copied to aAbbreviatedFileName.
If this is not the case, then the left-most characters of aOriginalFileName are copied to aAbbreviatedFileName, up to aAbbreviatedFileName's maximum length-1 and aAbbreviatedFileName's first character is set to be an ellipsis.
For example, if c:\home\letters\abcdef is the original file name and aAbbreviatedFileName allows only 7 characters, the abbreviated file name will be ...abcdef. This can be used to display a file or folder name in an error or progress dialog.
IMPORT_C TFileName | AbbreviatePath | ( | TDesC & | aPathName, |
const CFont & | aFont, | |||
TInt | aMaxWidthInPixels | |||
) | [static] |
TInt | CheckFolder | ( | const TDesC & | aFolderName | ) | [static, inline] |
Tests whether the specified folder exists and can be opened.
This returns an error code if the folder does not exist: see also FolderExists() which returns a boolean value.
KErrNone if aFolderName exists, otherwise another of the system-wide error codes.
const TDesC & aFolderName | The folder's name and path. |
TInt | CheckWhetherFullNameRefersToFolder | ( | const TDesC & | aFullName, |
TBool & | aIsFolder | |||
) | [static, inline] |
Tests whether a file specification is a valid folder name.
KErrNone if successful, otherwise another of the system-wide error codes (probably because aFullName cannot be parsed).
TInt | CopyFile | ( | const TDesC & | aSourceFullName, |
const TDesC & | aTargetFullName, | |||
TUint | aSwitch = CFileMan::EOverWrite | |||
) | [static, inline] |
Copies the specified file.
Notes:
files can be copied across drives
open files can be copied only if they have been opened using the EFileShareReadersOnly file share mode
the source file's attributes are preserved in the target file
KErrNone if the copy is successful, otherwise another of the system-wide error codes.
const TDesC & aSourceFullName | Path indicating the file(s) to be copied. Any path components which are not specified here will be taken from the session path. |
const TDesC & aTargetFullName | Path indicating the directory into which the file(s) are to be copied. |
TUint aSwitch = CFileMan::EOverWrite | Optional switch to allow overwriting files with the same name in the target directory, or recursion. By default, this function operates with overwriting and non-recursively. Switch options are defined using the enum TSwitch. If recursive operation is set, any intermediate directories are created. If no overwriting is set, any files with the same name are not overwritten, and an error is returned for that file. |
TInt | DeleteFile | ( | const TDesC & | aSourceFullName, |
TUint | aSwitch = 0 | |||
) | [static, inline] |
Deletes one or more files.
This function may operate recursively or non-recursively. When operating non-recursively, only the matching files located in the directory specified in aSourceFullName are affected. When operating recursively, all matching files in the directory hierarchy below the directory specified in aSourceFullName are deleted.
Attempting to delete read-only or open files returns an error.
KErrNone if aSourceFullName is successfully deleted, otherwise another of the system-wide error codes.
const TDesC & aSourceFullName | Path indicating the file(s) to be deleted. This can either be a full path, or a path relative to the session path. Use wildcards to specify more than one file. |
TUint aSwitch = 0 | Determines whether this function operates recursively. By default, this function operates non-recursively. |
TInt | DiskIsReadOnly | ( | const TDesC & | aFullName, |
TBool & | aIsReadOnly | |||
) | [static, inline] |
Tests whether the specified drive is read-only.
KErrNone if successful otherwise another of the system-wide error codes.
TFileName | DriveAndPathFromFullName | ( | const TDesC & | aFullName | ) | [static, inline] |
Parses the specified full path and file name to obtain the drive and path.
The drive and path.
const TDesC & aFullName | The full path and file name from which the drive and path will be obtained. |
TBool | FolderExists | ( | const TDesC & | aFolderName | ) | [static, inline] |
Tests whether a specified folder exists.
This returns a boolean value indicating whether the folder exists: see also CheckFolder() which returns an error code instead.
ETrue if the folder exists, EFalse if not.
const TDesC & aFolderName | The folder's path. |
TFileName | FolderNameFromFullName | ( | const TDesC & | aFullName | ) | [static, inline] |
Gets a folder name from a path and file name.
Folder name
const TDesC & aFullName | The full path and file name from which the folder will be obtained. |
TBool | IsFirstDriveForSocket | ( | TDriveUnit | aDriveUnit | ) | [static, inline] |
Tests whether the specified drive corresponds to the primary partition in a removable media slot.
Note that the function assumes that the D: drive corresponds to the primary partition on socket 0, and that the E: drive corresponds to the primary partition on socket 1 (a socket is a slot for removable media). This mapping may not always be the case because it is set up in the variant layer of Symbian OS.
True if the drive is the primary partition in a removable media slot. True is also returned if the drive is C:. False is returned otherwise.
TDriveUnit aDriveUnit | The drive to check. |
TInt | IsFolder | ( | const TDesC & | aFullName, |
TBool & | aIsFolder | |||
) | [static, inline] |
Tests whether aFullName is a folder.
KErrNone if successful otherwise another of the system-wide error codes.
TInt | MostSignificantPartOfFullName | ( | const TDesC & | aFullName, |
TFileName & | aMostSignificantPart | |||
) | [static, inline] |
Gets the folder name if the specified item is a valid folder name, otherwise gets the file name.
KErrNone if successful otherwise another of the system-wide error codes.
TInt | Parse | ( | const TDesC & | aName | ) | [static, inline] |
Tests whether a specified file name can be parsed.
KErrNone if the filename can be parsed, otherwise one of the system-wide error codes.
const TDesC & aName | The file name to parse. |
TBool | PathExists | ( | const TDesC & | aPath | ) | [static, inline] |
Tests whether a path exists.
ETrue if the path exists, EFalse otherwise.
const TDesC & aPath | The path to check. |
void | RemoveSystemDirectory | ( | CDir & | aDir | ) | [static, inline] |
Removes the System directory from a list of directory entries.
CDir & aDir | Array of directory entries. |
TInt | RenameFile | ( | const TDesC & | aOldFullName, |
const TDesC & | aNewFullName, | |||
TUint | aSwitch = CFileMan::EOverWrite | |||
) | [static, inline] |
Renames one or more files or directories.
This can also be used to move files by specifying different destination and source directories, but note that the destination and source directories must be on the same drive.
If moving files, you can set aSwitch so that any files with the same name that exist in the target directory are overwritten. If aSwitch is set for no overwriting, any files with the same name are not overwritten, and an error (KErrAlreadyExists) is returned for that file.
This function can only operate non-recursively, so that only the matching files located in the single directory specified by aOldFullName may be renamed.
Read-only, system and hidden files may be renamed or moved, and the source file's attributes are preserved in the target file, but attempting to rename or move an open file will return an error for that file.
KErrNone if successful otherwise another of the system-wide error codes.
const TDesC & aOldFullName | Path specifying the file or directory to be renamed. |
const TDesC & aNewFullName | Path specifying the new name for the file or directory. Any directories specified in this path which do not exist will be created. |
TUint aSwitch = CFileMan::EOverWrite | Optional, sets whether files are overwritten on the target. |
TFileName | RootFolderPath | ( | const TBuf< 1 > | aDriveLetter | ) | [static, inline] |
Gets the root folder for the specified drive.
The root folder for the drive, C:\ for example.
const TBuf< 1 > aDriveLetter | The drive letter, C for example. |
TInt | SortByTable | ( | CDir & | aDir, |
CBaflFileSortTable * | aTable | |||
) | [static, inline] |
Sorts files by UID.
The caller supplies a table which specifies the order in which files are to be sorted. The files whose UID3 is the first UID in the table appear first. The files whose UID3 is the UID specified second appear next, and so on. Files whose UID3 is not specified in the table, and directories, appear at the end of the list, with directories preceding the files, and with files sorted in ascending order of UID3.
This function is used for customising how lists of application files are sorted.
KErrNone if successful otherwise another of the system-wide error codes.
CDir & aDir | The array of files and directories to sort. |
CBaflFileSortTable * aTable | A sort order table containing the UIDs to use in the sort. |
TBool | UidTypeMatches | ( | const TUidType & | aFileUid, |
const TUidType & | aMatchUid | |||
) | [static, inline] |
Tests whether two UID types match.
A match is made if each UID in aMatchUid is either identical to the corresponding one in aFileUid, or is KNullUid.
ETrue if the UIDs match, EFalse if not.
void | UpdateDiskListL | ( | const RFs & | aFs, |
CDesCArray & | aArray, | |||
TBool | aIncludeRom, | |||
TDriveNumber | aDriveNumber | |||
) | [static, inline] |
Gets a list of all drives present on the system.
The file server is interrogated for a list of the drive letters for all available drives. The drive letter that corresponds to aDriveNumber is added to the list regardless of whether it is present, or is corrupt. Also, the C: drive and the primary partitions on removable media slots are forced onto the list, even if corrupt or not present.
const RFs & aFs | A connected session with the file server. |
CDesCArray & aArray | On return, contains the drive letters that correspond to the available drives. The drive letters are uppercase and are in alphabetical order. |
TBool aIncludeRom | ETrue if the ROM is included as a drive, EFalse otherwise. |
TDriveNumber aDriveNumber | The drive to force into the list, e.g. the drive in the default path. |