EikFileUtils Class Reference

class EikFileUtils

Provides a set of drive, path and file utility functions.

This class is essentially a thin layer over the BaflUtils class.

Constructor & Destructor Documentation

EikFileUtils()

EikFileUtils()[private]

Member Functions Documentation

AbbreviateFileName(const TFileName &, TDes &)

voidAbbreviateFileName(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.

Parameters

const TFileName & aOriginalFileNameOriginal file name.
TDes & aAbbreviatedFileNameOn return, the abbreviated file name.

AbbreviatePath(TDesC &, const CFont &, TInt)

IMPORT_C TFileNameAbbreviatePath(TDesC &aPathName,
const CFont &aFont,
TIntaMaxWidthInPixels
)[static]

Parameters

TDesC & aPathName
const CFont & aFont
TInt aMaxWidthInPixels

CheckFolder(const TDesC &)

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.

Parameters

const TDesC & aFolderNameThe folder's name and path.

CheckWhetherFullNameRefersToFolder(const TDesC &, TBool &)

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).

Parameters

const TDesC & aFullNameThe string to check.
TBool & aIsFolderTrue if aFullName is a valid folder name, otherwise false.

CopyFile(const TDesC &, const TDesC &, TUint)

TInt CopyFile(const TDesC &aSourceFullName,
const TDesC &aTargetFullName,
TUintaSwitch = 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.

Parameters

const TDesC & aSourceFullNamePath indicating the file(s) to be copied. Any path components which are not specified here will be taken from the session path.
const TDesC & aTargetFullNamePath indicating the directory into which the file(s) are to be copied.
TUint aSwitch = CFileMan::EOverWriteOptional 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.

DeleteFile(const TDesC &, TUint)

TInt DeleteFile(const TDesC &aSourceFullName,
TUintaSwitch = 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.

Parameters

const TDesC & aSourceFullNamePath 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 = 0Determines whether this function operates recursively. By default, this function operates non-recursively.

DiskIsReadOnly(const TDesC &, TBool &)

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.

Parameters

const TDesC & aFullNameFile name, including drive.
TBool & aIsReadOnlyOn return, true if the drive is read-only, otherwise false.

DriveAndPathFromFullName(const TDesC &)

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.

Parameters

const TDesC & aFullNameThe full path and file name from which the drive and path will be obtained.

FolderExists(const TDesC &)

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.

Parameters

const TDesC & aFolderNameThe folder's path.

FolderNameFromFullName(const TDesC &)

TFileName FolderNameFromFullName(const TDesC &aFullName)[static, inline]

Gets a folder name from a path and file name.

Folder name

Parameters

const TDesC & aFullNameThe full path and file name from which the folder will be obtained.

IsFirstDriveForSocket(TDriveUnit)

TBool IsFirstDriveForSocket(TDriveUnitaDriveUnit)[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.

Parameters

TDriveUnit aDriveUnitThe drive to check.

IsFolder(const TDesC &, TBool &)

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.

Parameters

const TDesC & aFullNameThe drive and path to test.
TBool & aIsFolderOn return, indicates whether aFullName is a folder.

MostSignificantPartOfFullName(const TDesC &, TFileName &)

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.

Parameters

const TDesC & aFullNameItem to parse.
TFileName & aMostSignificantPartOn return, the folder or file name.

Parse(const TDesC &)

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.

TParse

Parameters

const TDesC & aNameThe file name to parse.

PathExists(const TDesC &)

TBool PathExists(const TDesC &aPath)[static, inline]

Tests whether a path exists.

ETrue if the path exists, EFalse otherwise.

Parameters

const TDesC & aPathThe path to check.

RemoveSystemDirectory(CDir &)

voidRemoveSystemDirectory(CDir &aDir)[static, inline]

Removes the System directory from a list of directory entries.

Parameters

CDir & aDirArray of directory entries.

RenameFile(const TDesC &, const TDesC &, TUint)

TInt RenameFile(const TDesC &aOldFullName,
const TDesC &aNewFullName,
TUintaSwitch = 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.

Parameters

const TDesC & aOldFullNamePath specifying the file or directory to be renamed.
const TDesC & aNewFullNamePath 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::EOverWriteOptional, sets whether files are overwritten on the target.

RootFolderPath(const TBuf< 1 >)

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.

Parameters

const TBuf< 1 > aDriveLetterThe drive letter, C for example.

SortByTable(CDir &, CBaflFileSortTable *)

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.

Parameters

CDir & aDirThe array of files and directories to sort.
CBaflFileSortTable * aTableA sort order table containing the UIDs to use in the sort.

UidTypeMatches(const TUidType &, const TUidType &)

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.

Parameters

const TUidType & aFileUidThe UID type to match.
const TUidType & aMatchUidThe UID type to match against.

UpdateDiskListL(const RFs &, CDesCArray &, TBool, TDriveNumber)

voidUpdateDiskListL(const RFs &aFs,
CDesCArray &aArray,
TBoolaIncludeRom,
TDriveNumberaDriveNumber
)[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.

Parameters

const RFs & aFsA connected session with the file server.
CDesCArray & aArrayOn return, contains the drive letters that correspond to the available drives. The drive letters are uppercase and are in alphabetical order.
TBool aIncludeRomETrue if the ROM is included as a drive, EFalse otherwise.
TDriveNumber aDriveNumberThe drive to force into the list, e.g. the drive in the default path.

ValidateFolderNameTypedByUserL(const TDesC &, const TDesC &)

IMPORT_C TFileNameValidateFolderNameTypedByUserL(const TDesC &aFolderNameTypedByUser,
const TDesC &aCurrentPath
)[static]

Parameters

const TDesC & aFolderNameTypedByUser
const TDesC & aCurrentPath