Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: eikfutil.h
Link against: eikcore.lib

Class EikFileUtils

EikFileUtils

Support

Supported from 6.0

Description

This class provides a set of drive, path and file utility functions.

Defined in EikFileUtils:
AbbreviateFileName(), AbbreviatePath(), CheckFolder(), CheckWhetherFullNameRefersToFolder(), CopyFile(), DeleteFile(), DiskIsReadOnly(), DriveAndPathFromFullName(), FolderExists(), FolderNameFromFullName(), IsFirstDriveForSocket(), IsFolder(), MostSignificantPartOfFullName(), Parse(), PathExists(), RemoveSystemDirectory(), RenameFile(), RootFolderPath(), SortByTable(), UidTypeMatches(), UpdateDiskListL(), ValidateFolderNameTypedByUserL()


Drive and path information


UpdateDiskListL()

void UpdateDiskListL(const RFs& aFs,CDesCArray& aArray,TBool aIncludeRom,TDriveNumber aDriveNumber);

Description

Updates the list of available drives.

Inserts a list of all available drives in aArray. The drive list consists of an array of 26 bytes. Array index zero corresponds to drive A, one equals B and so on. Each byte with a non zero value signifies that the corresponding drive contains recognised media.

Note that the local file system always reserves drive letters A through I. The internal RAM always uses drive letter C. Drive letter Z is always used for the ROM.

Parameters

const RFs& aFs

File server session.

CDesCArray& aArray

The array in which to insert the list of available drives.

TBool aIncludeRom

ETrue if the ROM is included as a drive, EFalse otherwise.

TDriveNumber aDriveNumber

Drive with which to begin the list.


IsFirstDriveForSocket()

TBool IsFirstDriveForSocket(TDriveUnit aDriveUnit);

Description

Tests whether the specified drive is the first drive for the socket.

Sockets provide a generic interface to communication protocols through communication end points known as sockets. EPOC sockets are similar in concept to Berkeley Software Distribution (BSD) sockets from the University of California at Berkeley. They provide a generic interface to network level communications protocols for common operations involved in network computing.

Parameters

TDriveUnit aDriveUnit

The drive to check.

Return value

TBool

ETrue if aDriveUnit is the first drive for the socket, EFalse otherwise.


DiskIsReadOnly()

TInt DiskIsReadOnly(const TDesC& aFullName, TBool& aIsReadOnly);

Description

Gets drive read only state.

Parameters

const TDesC& aFullName

The disk’s full name.

TBool& aIsReadOnly

ETrue to set the specified disk as being read-only. EFalse to set the specified disk as not being read-only.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


RootFolderPath()

TFileName RootFolderPath(const TBuf<1> aDriveLetter);

Description

Gets the full path for a drive.

Parameters

const TBuf<1> aDriveLetter

The drive’s letter, C for example.

Return value

TFileName

The full path for a drive, C:\ for example.


DriveAndPathFromFullName()

TFileName DriveAndPathFromFullName(const TDesC& aFullName);

Description

Parses the specified full path and file name to obtain the drive and path.

Parameters

const TDesC& aFullName

The full path and file name from which the drive and path will be obtained.

Return value

TFileName

The drive and path.


MostSignificantPartOfFullName()

TInt MostSignificantPartOfFullName(const TDesC& aFullName, TFileName& aMostSignificantPart);

Description

Gets the most significant part of the specified drive, path and file name.

Parameters

const TDesC& aFullName

The drive, path and file name.

TFileName& aMostSignificantPart

On return, the most significant part of aFullName.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


PathExists()

TBool PathExists(const TDesC& aPath);

Description

Tests whether a path exists.

Parameters

const TDesC& aPath

The path to check.

Return value

TBool

ETrue if the path exists, EFalse otherwise.

[Top]


Folder information


FolderNameFromFullName()

TFileName FolderNameFromFullName(const TDesC& aFullName);

Description

Gets a folder name from a path and file name.

Parameters

const TDesC& aFullName

The full path and file name from which the folder will be obtained.

Return value

TFileName

Folder name


CheckWhetherFullNameRefersToFolder()

TInt CheckWhetherFullNameRefersToFolder(const TDesC& aFullName, TBool& aIsFolder);

Description

Tests whether a file specification refers to a folder.

Parameters

const TDesC& aFullName

The complete file specification to check.

TBool& aIsFolder

ETrue if aFullName is a folder, EFalse otherwise.

Return value

TInt

KErrNone if aFullName is a folder, otherwise another of the system-wide error codes.


CheckFolder()

TInt CheckFolder(const TDesC& aFolderName);

Description

Checks whether the specified folder exists. This returns an error if the folder does not exist: see also FolderExists() which returns a boolean value.

Parameters

const TDesC& aFolderName

The folder’s name and path.

Return value

TInt

KErrNone if aFolderName exists, otherwise another of the system-wide error codes.


FolderExists()

TBool FolderExists(const TDesC& aFolderName);

Description

Checks whether the specified folder exists. This returns boolean value if the folder does not exist: see also CheckFolder() which returns an error.

Parameters

const TDesC& aFolderName

The folder’s name and path.

Return value

TBool

ETrue if the folder exists, EFalse otherwise.


IsFolder()

TInt IsFolder(const TDesC& aFullName, TBool& aIsFolder);

Description

Sets aFullName as a folder.

Parameters

const TDesC& aFullName

The drive and path to make into a folder.

TBool& aIsFolder

ETrue to set aFullName as a folder. EFalse otherwise.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


ValidateFolderNameTypedByUserL()

TFileName ValidateFolderNameTypedByUserL(const TDesC& aFolderNameTypedByUser, const TDesC& aCurrentPath);

Description

Checks whether a folder, the name of which is supplied by a user, exists.

Parameters

const TDesC& aFolderNameTypedByUser

The folder name typed by a user.

const TDesC& aCurrentPath

The current path.

Return value

TFileName

The folder name and full path to the folder.

[Top]


Parsing and abbreviation functions


Parse()

TInt Parse(const TDesC& aName);

Description

Parse the specified file name specification.

Parameters

const TDesC& aName

The file name specification you wish to parse.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


AbbreviateFileName()

void AbbreviateFileName(const TFileName& aOriginalFileName, TDes& aAbbreviatedFileName);

Description

Tests whether there is sufficient space to display the specified file name. If there is sufficient space then aOriginalFileName is the same as aAbbreviatedFileName. If there is not sufficient space, aOriginalFileName is abbreviated to fit the available space, prefixed with an ellipsis and the abbreviation is returned as aAbbreviatedFileName.

For example, if c:\home\letters\abcdef is the original file name and the destination buffer 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& aOriginalFileName

The file name to be displayed.

TDes& aAbbreviatedFileName

If there is insufficient space to display aOriginalFileName, this provides an abbreviation.


AbbreviatePath()

TFileName AbbreviatePath(TDesC& aPathName, const CFont& aFont, TInt aMaxWidthInPixels);

Description

Gets an abbreviated path.

Determines the space that is available to display aPathName according to the font size and available screen area. If there is sufficient space then aPathName is returned as TFileName. If there is not sufficient space, aPathName is abbreviated to fit the available space, prefixed with an ellipsis and the abbreviation is returned as TFileName.

Parameters

TDesC& aPathName

The full path name.

const CFont& aFont

The font used to display the path.

TInt aMaxWidthInPixels

The available display space in pixels.

Return value

TFileName

The path name. This is aPathName if there is sufficient space, otherwise an abbreviation.

[Top]


Sorting files


SortByTable()

TInt SortByTable(CDir& aDir,CBaflFileSortTable* aTable);

Description

Sorts the files in the given table into order. Any file with UID[2] matching an entry in the table will be sorted relative to others in the table and before any files with no matching UID.

Parameters

CDir& aDir

Array of directory entries that have been read into memory from the file system.

CBaflFileSortTable* aTable

The table in which the sorted directory entries are stored.

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

[Top]


UID type matching


UidTypeMatches()

TBool UidTypeMatches(const TUidType& aFileUid, const TUidType& aMatchUid);

Description

Tests whether two UID types match.

Parameters

const TUidType& aFileUid

The UID type to match.

const TUidType& aMatchUid

The UID type to match against.

Return value

TBool

ETrue if the UIDs match, EFalse otherwise.

[Top]


Copying, renaming and deleting


CopyFile()

TInt CopyFile(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch);

Description

Copies the specified file to a specified destination file. Optionally, aSwitch can be set for either recursive operation or to overwrite any files with the same name which exist in the target directory. 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.

Notes:

Parameters

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

Optional switch to specify overwriting or recursion. By default, this function operates with overwriting and non-recursively. Switch options are defined using the enum TSwitch. This is defined in f32file.h.

Return value

TInt

KErrNone if the copy is successful, otherwise another of the system-wide error codes.


RenameFile()

TInt RenameFile(const TDesC& aOldFullName, const TDesC& aNewFullName, TUint aSwitch);

Description

Renames or moves one or more files or directories. This can also be used to move one or more files by specifying different destination and source directories. 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 open files cannot be renamed or moved. Attempting to rename or move an open file will return an error for that file.

Parameters

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

Optional, determines whether files are overwritten on the target.

Return value

Tint

KErrNone if successful otherwise another of the system-wide error codes.


DeleteFile()

TInt DeleteFile(const TDesC& aSourceFullName, TUint aSwitch);

Description

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.

Read-only and open files cannot be deleted. Attempting to do so will return an error.

Parameters

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

Determines whether this function operates recursively. By default, this function operates non-recursively.

Return value

TInt

KErrNone if aSourceFullName is successfully deleted, otherwise another of the system-wide error codes.


RemoveSystemDirectory()

void RemoveSystemDirectory(CDir& aDir);

Description

Deletes a directory and all files and directories contained in the directory structure below it.

Parameters

CDir& aDir

The directory to be deleted.