Location:
bautils.h
Link against: bafl.lib
BaflUtils
Supported from 5.0
Provides simple-to-use file system utilities.
The functions listed in "Copying, renaming, and deleting files"
create and use a CFileMan
object. They are useful for one-off
calls, but for repeated use it is more efficient to use CFileMan
directly.
Note that there is a very similiar group of functions available in
EikFileUtils
, which may be easier to use in GUI applications, as
they do not require a file server session to be passed.
Defined in BaflUtils
:
AbbreviateFileName()
, CheckFolder()
, CheckWhetherFullNameRefersToFolder()
, CopyFile()
, CopyWithTruncation()
, DeleteFile()
, DiskIsReadOnly()
, DriveAndPathFromFullName()
, EnsurePathExistsL()
, ExtractAppNameFromFullName()
, FileExists()
, FolderExists()
, FolderNameFromFullName()
, GetSystemDrive()
, IsFirstDriveForSocket()
, IsFolder()
, MostSignificantPartOfFullName()
, NearestLanguageFile()
, Parse()
, PathExists()
, RemoveSystemDirectory()
, RenameFile()
, RootFolderPath()
, SortByTable()
, UidTypeMatches()
, UpdateDiskListL()
, ValidateFolderNameTypedByUserL()
static void EnsurePathExistsL(RFs& aFs,const TDesC& aFileName);
Makes one or more directories, if they do not already exist.
Any valid path component in the specified path that does not already exist is created as a directory.
|
|
static TBool FileExists(const RFs& aFs,const TDesC& aFileName);
Checks if the specified file exists.
|
|
static TBool FolderExists(RFs& aFs, const TDesC& aFolderName);
Supported from 5.1
Tests whether a folder exists.
The folder is specified in a path. The path can omit the drive letter, in which case the drive letter is taken from the session path.
If the path is badly formed, for instance if it contains illegal characters, or any directory name consists of a single or double dot, or any directory name includes wildcard characters, the function returns false.
A filename may be specified in the path, and is ignored, but note that if a filename is included in the path, its name must not contain any illegal characters — this is considered a badly formed path and causes the function to return false. If no filename is specified, the path should end in a backslash.
|
|
static TBool PathExists(RFs& aFs,const TDesC& aFileName);
Supported from 5.1
Tests whether a path exists.
The path should contain a drive letter and a directory, or false is returned. False is also returned if it contains a filename or filename extension.
If the path is badly formed, for instance if it contains illegal characters, or any directory name consists of a single or double dot, or any directory name includes wildcard characters, the function returns false.
|
|
static TInt CopyFile(RFs& aFs, const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch = CFileMan::EOverWrite);
Supported from 5.1
Copies one or more files.
For more details, see CFileMan::Copy()
.
|
|
static TInt DeleteFile(RFs& aFs, const TDesC& aSourceFullName, TUint aSwitch = 0);
Supported from 5.1
Deletes one or more files.
For more details, see CFileMan::Delete()
.
|
|
static TInt RenameFile(RFs& aFs, const TDesC& aOldFullName, const TDesC& aNewFullName, TUint aSwitch = CFileMan::EOverWrite);
Supported from 5.1
Renames or moves one or more files or directories.
It can be used to move one or more files by specifying different destination and source directories.
For more details, see CFileMan::Rename()
.
|
|
static void AbbreviateFileName(const TFileName& aOriginalFileName, TDes& aAbbreviatedFileName);
Supported from 5.1
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 so, then the left-most characters of
aOriginalFileName
are copied to aAbbreviatedFileName
,
up to aAbbreviatedFileName
's maximum length-1.
aAbbreviatedFileName
's first character is set to be an
ellipsis.
|
static TInt CheckWhetherFullNameRefersToFolder(const TDesC& aFullName, TBool& aIsFolder);
Supported from 5.1
Checks if a string is a valid folder name.
|
|
static void CopyWithTruncation(TDes& aDest,const TDesC& aSrc,TChar aTruncationSymbol=KBaflCharTruncation);
Copies a descriptor, abbreviating it to fit the destination descriptor.
If aSrc
is less than the maximum length of
aDest
, then the string is simply copied to
aDest
.
If this is not so, then the left-most characters of
aSrc
are copied to aDest
, up to aDest
's
maximum length-1. aDest
's final character is set to be
aTruncationSymbol
.
|
static TFileName DriveAndPathFromFullName(const TDesC& aFullName);
Supported from 5.1
Gets the drive letter and path from a file name.
This is in the form: drive-letter:\path\. The drive letter is
folded using class TCharF
.
|
|
static TFileName FolderNameFromFullName(const TDesC& aFullName);
Supported from 5.1
Gets the folder name from a path.
For example, if the path is "c:\documents\word\mydoc1", then "word" is returned.
|
|
static TInt MostSignificantPartOfFullName(const TDesC& aFullName, TFileName& aMostSignificantPart);
Supported from 5.1
Gets the folder name if the specified item is a valid folder name, otherwise gets the file name.
|
|
static TInt Parse(const TDesC& aName);
Supported from 5.1
Checks if a specified file name can be parsed.
|
|
static TFileName RootFolderPath(const TBuf<1> aDriveLetter);
Supported from 5.1
Gets the root folder for the specified drive.
This is simply the drive letter plus ":\".
|
|
static TInt ValidateFolderNameTypedByUserL(const RFs& aFs, const TDesC& aFolderNameTypedByUser, const TDesC& aCurrentPath, TFileName& aNewFolderFullName);
Supported from 5.1
Checks if a folder name (without drive or path) is valid and returns the full name of the folder.
|
|
static void RemoveSystemDirectory(CDir& aDir);
Supported from 5.1
Removes "System" from a list of directory entries.
|
static TInt CheckFolder(RFs& aFs, const TDesC& aFolderName);
Supported from 5.1
Checks that the specified folder can be opened.
|
|
static TInt DiskIsReadOnly(RFs& aFs, const TDesC& aFullName, TBool& aIsReadOnly);
Supported from 5.1
Checks if the specified drive is read-only.
|
|
static TPtrC ExtractAppNameFromFullName(const TFullName& aName);
Gets the application name from a full thread name.
|
|
static TBool IsFirstDriveForSocket(TDriveUnit aDriveUnit);
Supported from 5.1
Tests whether the specified drive corresponds to the primary partition in a removable media slot.
|
|
static TInt IsFolder(const RFs& aFs, const TDesC& aFullName, TBool& aIsFolder);
Supported from 5.1
Checks if the specified item is a folder.
|
|
static void NearestLanguageFile(const RFs& aFs,TFileName& aName);
Searches for the file with the correct language extension for the language of the current locale, or failing this, the best matching file.
Symbian defines two-digit language values that identify natural
languages. These values are enumerated by the TLanguage
enum. It
is suggested that files that have language-specific variants, such as resource
files, have extensions in which the last two digits are the language code. For
example, somefile.r01
and somefile.r02
would be the
English and French versions of the resource file somefile
. In a
system set to the English locale, this function would return
somefile.r01
; in a French locale,
somefile.r02
.
For each language, the search is conducted across all the
drives available on the device. The first drive searched is the system drive
(as returned by BaflUtils::GetSystemDrive()
), followed by the ROM
(z: drive), then all the other drives available on the device.
|
static TBool UidTypeMatches(const TUidType& aFileUid, const TUidType& aMatchUid);
Supported from 5.1
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
.
|
|
static TInt GetSystemDrive(TDriveNumber& aDriveNumber);
Supported from 6.1
Gets the value of the system drive, if one has been set.
The system drive can be set to one of the built-in read/write drives. Which drive is used is hardware-dependent. On some hardware, there may not be a system drive. The system drive is used as the drive on which localisable files are searched for.
|
|
static void UpdateDiskListL(const RFs& aFs,CDesCArray& aArray,TBool aIncludeRom,TDriveNumber aDriveNumber);
Retrieves 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.
|
static TInt SortByTable(CDir& aDir,CBaflFileSortTable* aTable);
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.
|
|