Symbian
 Developer Library

UIQ 3 SDK

UIQ developer portal

FEEDBACK 

[Index] [Spacer] [Previous] [Next]



Location: f32file.h

Class RFs

class RFs : public RSessionBase;

Description

A handle to a file server session.

A program or thread may have arbitrarily many sessions open simultaneously.

Use this class for all file system manipulation, including:

1. adding, removing, moving and renaming files and directories

2. inspecting and changing file attributes and directory entry details. These include the time and date when the file or directory was last written to, its size and various attribute flags such as read-only, hidden, archive or system.

3. finding a file’s real name; if the file system on which it is stored has to "mangle" the name into a shorter format

4. getting directory listings

5. maintaining a default path; unlike some other systems, there is a single system default path, rather than one for each drive: the default path consists of a drive and a path specification.

6. performing context-sensitive parses using TParse objects, and the session path

7. obtaining information on drives and volumes

8. formatting and labelling volumes

9. obtaining a list of valid drives

10. emulating the DOS subst command, which allows any directory to appear as if it were a separate drive

11. requesting notification of when significant change occurs. This can be used for programs which maintain file lists, but must update those lists when change occurs.

12. finding the version number of the file server

13. resource counting to ensure that all resources are closed when the session terminates.

This class is not intended for user derivation.

The following restrictions apply when a path is specified:

1. its total length must not exceed 256 characters

2. wildcards cannot be used in the drive or in any directory name, although they may be allowed in the filename and extension.

3. double backslashes are not allowed in the path.

4. the following characters must not be included anywhere in the path: < > " / |

5. a colon may only be included between the drive and path

6. no directory name or filename plus extension may consist solely of space characters, or of a single or double dot.

7. spaces between the drive, if specified, and the first directory in the path are illegal, although there may be spaces between other path components, for instance between directories.

Derivation

Members

Defined in RFs:
AddExtension(), AddFileSystem(), AllowDismount(), Att(), CharToDrive(), CheckDisk(), ClearPassword(), Connect(), ControlIo(), ControlIo(), ControlIo(), ControlIo(), CreatePrivatePath(), DebugNotify(), Delete(), DismountExtension(), DismountFileSystem(), Drive(), DriveList(), DriveToChar(), Entry(), ErasePassword(), ExtensionName(), FileSystemName(), FinaliseDrives(), GetDir(), GetDir(), GetDir(), GetDriveName(), GetLongName(), GetMediaSerialNumber(), GetNotifyUser(), GetReserveAccess(), GetShortName(), IsFileInRom(), IsFileOpen(), IsRomAddress(), IsValidDrive(), IsValidName(), IsValidName(), LoaderHeapFunction(), LockDrive(), MkDir(), MkDirAll(), Modified(), MountExtension(), MountFileSystem(), MountFileSystem(), MountFileSystem(), MountFileSystem(), MountFileSystemAndScan(), MountFileSystemAndScan(), NotifyChange(), NotifyChange(), NotifyChangeCancel(), NotifyChangeCancel(), NotifyDiskSpace(), NotifyDiskSpaceCancel(), NotifyDiskSpaceCancel(), NotifyDismount(), NotifyDismountCancel(), NotifyDismountCancel(), Parse(), Parse(), PrivatePath(), ReadFileSection(), RealName(), ReleaseReserveAccess(), RemountDrive(), RemoveExtension(), RemoveFileSystem(), Rename(), Replace(), ReserveDriveSpace(), ResourceCount(), ResourceCountMarkEnd(), ResourceCountMarkStart(), RmDir(), ScanDrive(), SessionPath(), SetAllocFailure(), SetAtt(), SetDebugRegister(), SetDriveName(), SetEntry(), SetErrorCondition(), SetLocalDriveMapping(), SetModified(), SetNotifyUser(), SetSessionPath(), SetSessionToPrivate(), SetStartupConfiguration(), SetSubst(), SetVolumeLabel(), StartupInitComplete(), Subst(), SwapFileSystem(), UnlockDrive(), Version(), Volume()

Inherited from RHandleBase:
Attributes(), Close(), Duplicate(), FullName(), Handle(), HandleInfo(), Name(), SetHandle(), SetHandleNC(), iHandle

Inherited from RSessionBase:
CreateSession(), EAutoAttach, EExplicitAttach, Open(), Send(), SendReceive(), SetReturnedHandle(), ShareAuto(), ShareProtected(), TAttachMode


Member functions


Connect()

IMPORT_C TInt Connect(TInt aMessageSlots=KFileServerDefaultMessageSlots);

Description

Connects a client to the file server.

To end the file server session, use Close().

Parameters

TInt aMessageSlots

The number of message slots required. The default value of KFileServerDefaultMessageSlots indicates that message slots will be acquired dynamically from the system wide pool. Override this value with a fixed number, if a fixed number of slots are to be allocated to the session. If overriding, note that the number of message slots represents the number of operations, such as reads and writes, that can be outstanding at once; always remember to provide a spare slot for the cancel operation.

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide error codes.


Version()

IMPORT_C TVersion Version() const;

Description

Gets the client side version number.

Return value

TVersion

The client side version number.


AddFileSystem()

Capability: DiskAdmin

IMPORT_C TInt AddFileSystem(const TDesC &aFileName) const;

Description

Adds a file system to the file server.

After calling this function, use MountFileSystem() to mount the file system on a drive.

Parameters

const TDesC &aFileName

The name of the file system .FSY to install. Its full path can be specified.

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide error codes.

See also:


MountFileSystem()

Capability: DiskAdmin

IMPORT_C TInt MountFileSystem(const TDesC &aFileSystemName, TInt aDrive) const;

Description

Mounts a file system on a drive.

The file system must first have been added to the file server, using AddFileSystem().

The operation is asynchronous, i.e other concurrent file server operations can continue.

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName().

TInt aDrive

The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


MountFileSystem()

Capability: DiskAdmin

IMPORT_C TInt MountFileSystem(const TDesC &aFileSystemName, TInt aDrive, TBool aIsSync) const;

Description

Mounts a file system on a drive.

The file system must first have been added to the file server, using AddFileSystem().

The operation can be synchronous or asynchronous. Synchronous means that other concurrent file server operations are locked until the mount operation is complete. Asynchronous means that other concurrent file server operations can continue.

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName().

TInt aDrive

The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.

TBool aIsSync

ETrue, All subsequent file server operations on this drive will occur synchronously; EFalse, All subsequent file server operations on this drive will occur asynchronously

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


MountFileSystemAndScan()

Capability: DiskAdmin

IMPORT_C TInt MountFileSystemAndScan(const TDesC &aFileSystemName, TInt aDrive, TBool &aIsMountSuccess) const;

Description

Mounts a file system on a drive, and performs a scan on that drive.

The file system must first have been added to the file server, using AddFileSystem().

Note that the scan is done only if the mount is successful.

The file system will be marked as asynchronous. i.e. all subsequent file server operations on this drive will occur asynchronously;

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName().

TInt aDrive

The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.

TBool &aIsMountSuccess

On return, set to: ETrue, if the if the mount is successful, set to EFalse otherwise.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes, reflecting the failure of the mount operation.

See also:


MountFileSystem()

Capability: DiskAdmin

IMPORT_C TInt MountFileSystem(const TDesC &aFileSystemName, const TDesC &aExtensionName, TInt aDrive);

Description

Mounts a file system on a drive, and the specified extension.

The file system must first have been added to the file server, using AddFileSystem().

The operation is asynchronous, i.e other concurrent file server operations can continue.

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName().

const TDesC &aExtensionName

The filename of the extension.

TInt aDrive

The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


MountFileSystem()

Capability: DiskAdmin

IMPORT_C TInt MountFileSystem(const TDesC &aFileSystemName, const TDesC &aExtensionName, TInt aDrive, TBool aIsSync);

Description

Mounts a file system on a drive, and the specified extension.

The file system must first have been added to the file server, using AddFileSystem().

The operation can be synchronous or asynchronous. Synchronous means that other concurrent file server operations are locked until the mount operation is complete. Asynchronous means that other concurrent file server operations can continue.

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName().

const TDesC &aExtensionName

The filename of the extension.

TInt aDrive

The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.

TBool aIsSync

ETrue, All subsequent file server operations on this drive will occur synchronously; EFalse, All subsequent file server operations on this drive will occur asynchronously

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


MountFileSystemAndScan()

Interface status: protoype

IMPORT_C TInt MountFileSystemAndScan(const TDesC &aFileSystemName, const TDesC &aExtensionName, TInt aDrive, TBool &aIsMountSuccess) const;

Description

Parameters

const TDesC &aFileSystemName

const TDesC &aExtensionName

TInt aDrive

TBool &aIsMountSuccess

Return value

TInt


DismountFileSystem()

Capability: DiskAdmin

IMPORT_C TInt DismountFileSystem(const TDesC &aFileSystemName, TInt aDrive) const;

Description

Dismounts the file system from the specified drive.

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName().

TInt aDrive

The drive from which the file system is to be dismounted.

Return value

TInt

KErrNone, if successful; KErrNotFound, if aFileSystemName is not found, or the drive does not have a file system mounted on it; KErrInUse, if the drive has a resource open on it; KErrAccessDenied, if there is an attempt to dismount a ROM file system, a substituted drive, or the drive which is the default drive; KErrArgument, if the specified drive value is outsdide of the valid range.

See also:


RemoveFileSystem()

Capability: DiskAdmin

IMPORT_C TInt RemoveFileSystem(const TDesC &aFileSystemName) const;

Description

Removes the specified file system.

Parameters

const TDesC &aFileSystemName

The fullname of the file system, as returned from a call to FileSystemName(), to be removed.

Return value

TInt

KErrNone, if successful; KErrNotFound, if aFileSystemName is not found; otrherwise one of the other system-wide error codes.


FileSystemName()

IMPORT_C TInt FileSystemName(TDes &aName, TInt aDrive) const;

Description

Gets the name of the file system mounted on the specified drive.

The function can be called before calling DismountFileSystem().

Parameters

TDes &aName

On successful return, contains the name of the file system.

TInt aDrive

The drive for which the file system name is required.

Return value

TInt

KErrNone, if successful; KErrNotFound if aFileSystemName is not found, or the drive does not have a file system mounted on it; KErrArgument, if the drive value is outside the valid range, i.e. zero to KMaxDrives-1 inclusive.

See also:


AddExtension()

IMPORT_C TInt AddExtension(const TDesC &aFileName);

Description

Loads the specified extension.

Parameters

const TDesC &aFileName

The file name of the extension

Return value

TInt

KErrNone, if successful; otherwise one of the other system wide error codes.


MountExtension()

IMPORT_C TInt MountExtension(const TDesC &aExtensionName, TInt aDrive);

Description

Mounts the the specified extension.

The extension must first have been loaded using AddExtension().

Parameters

const TDesC &aExtensionName

The fullname of the extension, as returned from a call to ExtensionName().

TInt aDrive

The drive on which the extension is to be mounted;

Return value

TInt

KErrNone if successful; KErrNotFound, if the extension cannot be found; otherwise one of the other system-wide error codes.

See also:


DismountExtension()

IMPORT_C TInt DismountExtension(const TDesC &aExtensionName, TInt aDrive);

Description

Dismounts the specified extension.

Parameters

const TDesC &aExtensionName

The fullname of the extension, as returned from a call to ExtensionName().

TInt aDrive

The drive on which the extension is to be mounted;

Return value

TInt

KErrNone if successful; KErrNotFound, if the extension cannot be found; otherwise one of the other system-wide error codes.

See also:


RemoveExtension()

IMPORT_C TInt RemoveExtension(const TDesC &aExtensionName);

Description

Removes the specified extension.

Parameters

const TDesC &aExtensionName

The fullname of the extension, as returned from a call to ExtensionName().

Return value

TInt

KErrNone, if successful; KErrNotFound, if aExtensionName is not found; otrherwise one of the other system-wide error codes.


ExtensionName()

IMPORT_C TInt ExtensionName(TDes &aExtensionName, TInt aDrive, TInt aPos);

Description

Gets the name of the extension on the specified drive at the specified position in the extension hierarchy.

Parameters

TDes &aExtensionName

On successful return, contains the name of the extension.

TInt aDrive

The drive for which the extension name is required.

TInt aPos

The position of the extension in the extension hierarchy.

Return value

TInt

KErrNone, if successful; KErrNotFound if the extension name is not found;


RemountDrive()

IMPORT_C TInt RemountDrive(TInt aDrive, const TDesC8 *aMountInfo=0,TUint aFlags=0);

Description

Forces a remount of the specified drive.

Parameters

TInt aDrive

The drive for which a remount is to be forced.

const TDesC8 *aMountInfo

Information passed down to the media driver. The meaning of this information depends on the media driver, for example, keys for secure areas.

TUint aFlags

Reserved for future use.

Return value

TInt

KErrNone if successful, otherwise one of the other system wide error codes.


NotifyChange()

Capability: AllFiles

IMPORT_C void NotifyChange(TNotifyType aType, TRequestStatus &aStat);

Description

Requests a notification of change to files or directories.

Changes are notified either:

1. following any change in the file system

or

2. only following the addition or deletion of a directory entry, or after a disk has been formatted or changed.

Such notification is useful for programs that maintain displays of file lists which must be dynamically updated. The alternative is to do no updating, or to perform periodic monitoring for change, which is inefficient.

This is an asynchronous request and, as such, results in precisely one signal to the request status passed as a parameter. To avoid missing any change, this request should be issued before the first file list is constructed. When the request completes, a new request should be issued before the next file list is constructed. When the file server session is closed, this request is implicitly cancelled.

Call NotifyChangeCancel() to explicitly cancel a notification request.

Parameters

TNotifyType aType

Indicates the kind of change that should result in notification. For example: ENotifyEntry causes notification only when an entry is added or deleted, or when a disk is formatted or changed; ENotifyAll causes notification following any type of change, such as when a file is written to, or when a file's attributes are changed.

TRequestStatus &aStat

The request status. This is set to KErrNone on completion, otherwise one of the other system-wide error codes.


NotifyChange()

Capability: AllFiles

IMPORT_C void NotifyChange(TNotifyType aType, TRequestStatus &aStat, const TDesC &aPathName);

Description

Requests a notification of change to files or directories, allowing a directory/file path to be specified.

Changes are notified either:

1. following any change in the file system

or

2. only following the addition or deletion of a directory entry, or after a disk has been formatted or changed.

Such notification is useful for programs that maintain displays of file lists which must be dynamically updated. The alternative is to do no updating, or to perform periodic monitoring for change, which is inefficient.

This is an asynchronous request and, as such, results in precisely one signal to the request status passed as a parameter. To avoid missing any change, this request should be issued before the first file list is constructed. When the request completes, a new request should be issued before the next file list is constructed. When the file server session is closed, this request is implicitly cancelled.

Call NotifyChangeCancel() to explicitly cancel a notification request.

Parameters

TNotifyType aType

Indicates the kind of change that should result in notification. For example: ENotifyEntry causes notification only when an entry is added or deleted, or when a disk is formatted or changed; ENotifyAll causes notification following any type of change, such as when a file is written to, or when a file's attributes are changed.

TRequestStatus &aStat

The request status. This is set to KErrNone on completion, otherwise one of the other system-wide error codes.

const TDesC &aPathName

The directory or file for which notification is required. By specifying a drive as a wildcard, for example "?:\\Resource\\apps", or "*:\\Resource\\apps", a client can ask to be notified of changes to a given directory on any drive.


NotifyChangeCancel()

Capability: AllFiles

IMPORT_C void NotifyChangeCancel();

Description

Cancels all outstanding requests for notification of change to files or directories.

All outstanding requests complete with KErrCancel.

Note that this is a synchronous function.


NotifyChangeCancel()

Capability: AllFiles

IMPORT_C void NotifyChangeCancel(TRequestStatus &aStat);

Description

Cancels the specific request for notification of change to files or directories.

The outstanding request completes with KErrCancel.

Note that this is an asynchronous function.

Parameters

TRequestStatus &aStat

The request status object associated with the request to be cancelled. Note that the function does not change this parameter.


NotifyDiskSpace()

IMPORT_C void NotifyDiskSpace(TInt64 aThreshold, TInt aDrive, TRequestStatus &aStat);

Description

Requests notification when the free disk space on the specified drive crosses the specified threshold value.

The threshold is crossed if free disk space increases to a value above the threshold value or decreases to a value below the threshold value.

This is an asynchronous request that completes if any of the following events occur:

1. the threshold is crossed

2. any drive is formatted

3. there is a media change on any socket

4. power up

5. the scandrive utility is run on any drive

5. the specified threshold value is outside its limits

7. the outstanding request is cancelled.

Note that free disk space notification is not supported for drives using remote file systems.

Parameters

TInt64 aThreshold

The threshold value. This must be greater than zero and less than the total size of the disk.

TInt aDrive

The drive number. This is an explicit drive defined by one of the TDriveNumber enum values or the value KDefaultDrive. If KDefaultDrive is specified, then the drive monitored is the session path drive.

TRequestStatus &aStat

The request status object. On request completion, contains: KErrNone, if the threshold value is crossed, if any drive is formatted, if there is a media change on any socket, if there is a power up or if the scandrive utility is run on any drive; KErrCancel, if the outstanding request is cancelled by a call to NotifyDiskSpaceCancel(); KErrArgument, if the threshold value is outside its limits.

See also:


NotifyDiskSpaceCancel()

IMPORT_C void NotifyDiskSpaceCancel(TRequestStatus &aStat);

Description

Cancels a specific outstanding request for free disk space notification.

The outstanding request completes with KErrCancel.

Parameters

TRequestStatus &aStat

The request status object identified with the original notification request.


NotifyDiskSpaceCancel()

IMPORT_C void NotifyDiskSpaceCancel();

Description

Cancels all outstanding requests for free disk space notification.

Outstanding requests complete with KErrCancel.


DriveList()

IMPORT_C TInt DriveList(TDriveList &aList) const;

Description

Gets a list of the available drives.

The drive list consists of an array of 26 bytes. Array index zero corresponds to drive A, index one equals B etc.

Each byte with a non zero value signifies that the corresponding drive is available to the system. In the case of removable media, RFs::Drive should be used to determine wether the media is inserted or not.

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 which means that letters J through Y are available to be used by SetSubst() or for redirecting.

Parameters

TDriveList &aList

On return, contains a list of available drives.

Return value

TInt

KErrNone, successful, otherwise one of the other system-wide error codes.


Drive()

IMPORT_C TInt Drive(TDriveInfo &anInfo, TInt aDrive=KDefaultDrive) const;

Description

Gets information about a drive and the medium mounted on it.

Note that Volume() can also be used to give information about the drive and the volume mounted on it. These two functions are separate because, while the characteristics of a drive cannot change, those of a volume can, by mounting different media, reformatting etc.

Parameters

TDriveInfo &anInfo

On return, contains information describing the drive and the medium mounted on it. The value of TDriveInfo::iType shows whether the drive contains media.

TInt aDrive

The drive for which information is requested. Specify KDefaultDrive for the session default drive. Specify a drive in the range EDriveA to EDriveZ for drives A to Z respectively.

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide error codes.

See also:


Volume()

IMPORT_C TInt Volume(TVolumeInfo &aVol, TInt aDrive=KDefaultDrive) const;

Description

Gets volume information for a formatted device.

This function provides additional information to that given by Drive(), including the volume label, if set, and the amount of free space on the disk.

Note, use Drive() to get information about the drive without reference to a volume. These two functions are separate because, while the characteristics of a drive cannot change, those of a volume can, by mounting different media, reformatting etc. A volume may not even be present if the media is removable.

Parameters

TVolumeInfo &aVol

On return, contains the volume information.

TInt aDrive

The drive which contains the media for which volume information is to be displayed. Specify a drive in the range EDriveA to EDriveZ for drives A to Z respectively. The default drive is the session default drive KDefaultDrive.

Return value

TInt

KErrNone, if successful; KErrNotReady, if the drive contains no media; otherwise one of the other system-wide error codes.

See also:


SetVolumeLabel()

Capability: DiskAdmin

IMPORT_C TInt SetVolumeLabel(const TDesC &aName, TInt aDrive=KDefaultDrive);

Description

Sets the label for a volume.

Parameters

const TDesC &aName

The volume label.

TInt aDrive

The drive containing the media whose label is to be set. Specify a drive in the range EDriveA to EDriveZ for drives A to Z. The default drive is the session default drive KDefaultDrive.

Return value

TInt

KErrNone, if successful; KErrNotReady, if the drive contains no media; otherwise one of the other system-wide error codes.

See also:


Subst()

IMPORT_C TInt Subst(TDes &aPath, TInt aDrive=KDefaultDrive) const;

Description

Gets the path assigned to a drive letter by an earlier call to SetSubst().

To find out whether a drive letter has been substituted, first get the drive information, using Drive(), and then test the value of the KDriveAttSubsted bit provided by TDriveInfo::iDriveAtt.

Parameters

TDes &aPath

On return, contains the path which has been assigned to the drive. If the drive letter has not been substituted, this argument returns an empty descriptor.

TInt aDrive

The drive which is the subject of the enquiry. Specify a number in the range 0 (EDriveA) to 25 (>EDriveZ) for drives A to Z. The default drive is the session default drive KDefaultDrive.

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide error codes.

See also:


SetSubst()

Capability: DependentIf aPath is /Sys then Tcb capability is required. If aPath begins with /Private and does not match this process' SID then AllFiles capability is required.
Capability: DiskAdmin

IMPORT_C TInt SetSubst(const TDesC &aPath, TInt aDrive=KDefaultDrive);

Description

Assigns a path to a drive letter.

Whenever that drive letter is used, it will be translated into a reference to the path specified here. To clear a drive substitution, specify an empty descriptor for aPath.

Note that the substituted path is text-only. Its components need not be syntactically correct, nor must they be valid at the time the substitution is set. Any component may be deleted, removed or unmounted while the substitution is set.

Parameters

const TDesC &aPath

The path to be assigned to the drive letter. If a drive letter is specified in the path, it must not itself be substituted or redirected, or the function will return an error. If no drive is specified, the drive contained in the default session path is used, and if no path is specified, the default session path is used. If a filename or extension is included in the path, the function will return an error. Therefore, the final component in the path must have a trailing backslash to indicate that it is a directory.

TInt aDrive

The drive to which a path is to be assigned. Specify a number in the range 0 (EDriveA) to 25 (EDriveZ) for drives A to Z. Must not be local, ROM, or redirected, otherwise an error is returned. May be substituted, but only if the function is being used to clear the substitution. If the same drive is specified in the path, the function will return an error. The default drive is the session default drive KDefaultDrive.

Return value

TInt

KErrNone, if successful; otherwise one of the other system-wide error codes.


RealName()

Capability: DependentIf aName is /Sys then AllFiles capability is required. If aName begins with /Private and does not match this process' SID then AllFiles capability is required.

IMPORT_C TInt RealName(const TDesC &aName, TDes &aResult) const;

Description

Gets the real name of a file.

This is used in circumstances where a file system needs to mangle Symbian OS natural names so that it can store them on that file system.

Parameters

const TDesC &aName

Contains the name by which the file is normally referred.

TDes &aResult

On return, contains the real name of the file, comprising the full path, including the drive letter.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


GetMediaSerialNumber()

IMPORT_C TInt GetMediaSerialNumber(TMediaSerialNumber &aSerialNum, TInt aDrive);

Description

Gets the serial number of media.

Only local drive is allowed. Substed drive number will return KErrNotSupported.

Parameters

TMediaSerialNumber &aSerialNum

Contains serial number on successful return.

TInt aDrive

Drive number.

Return value

TInt

KErrNone, if successful; KErrNotSupported, if media doesn't support serial number; KErrBadName, if drive number is invalid; otherwise one of system-wide error codes.

See also:


SessionPath()

IMPORT_C TInt SessionPath(TDes &aPath) const;

Description

Gets the session path.

When a client connects to the file server, its session path is initialised to the system default path. The session path of an existing client can only be changed by this function.

Parameters

TDes &aPath

On return, contains the session path, including a trailing backslash.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


SetSessionPath()

Capability: DependentIf aPath is /Sys then AllFiles capability is required. If aPath begins with /Private and does not match this process' SID then AllFiles capability is required.

IMPORT_C TInt SetSessionPath(const TDesC &aPath);

Description

Sets the session path for the current file server client.

When the client first connects to the file server, its session path is initialised to the system default path.

Note that the session path is text-only. It does not cause any locking. Thus, although the path must be syntactically correct, its components do not need to be valid at the time the path is set, and any component may be deleted, removed or unmounted while the path is set.

Parameters

const TDesC &aPath

The new session path. Consists of a drive and path. Normally, a drive should be specified, but if not, the drive specified in the existing session path is preserved. If a file is specified, then the function fails and returns an error code. Therefore, the final component in the path must have a trailing backslash to indicate that it is a directory. All components of the path must be syntactically correct, for example, wildcard characters and double backslashes are not allowed in any part of it.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


Parse()

IMPORT_C TInt Parse(const TDesC &aName, TParse &aParse) const;

Description

Parses a filename specification.

Parsing is done with wildcard resolution, using the session path as the default. You can then use TParse's getter functions to extract individual components of the resulting name. All the path components that are included in aName are put into the resulting filename. Any components that are still missing are taken from the session path.

Specifying:

TParse fp;

fs.Parse(name,fp);

is equivalent to

TParse fp;

fp.Set(name,NULL,&fs.SessionPath());

Note that the function does not check for illegal characters, or for illegal path components in either of the paths specified.

Parameters

const TDesC &aName

The file name to be parsed, using the session path to provide the missing components.

TParse &aParse

A TParse objct that provides functions for extracting individual components of the resulting file name.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


Parse()

IMPORT_C TInt Parse(const TDesC &aName, const TDesC &aRelated, TParse &aParse) const;

Description

Parses a filename specification, specifying related file path components.

Parsing is done with wildcard resolution, using the session path as the default. You can then use TParse's getter functions to extract individual components of the resulting name. All the path components that are included in aName are put into the resulting filename. Any missing components are taken from the optional aRelated argument, which has the next order of precedence. Finally, any components that are still missing are taken from the session path.

Specifying:

TParse fp;

fs.Parse(name,related,fp);

is equivalent to

TParse fp;

fp.Set(name,related,&fs.SessionPath());

Note that the function does not check for illegal characters, or for illegal path components in any of the paths specified.

Parameters

const TDesC &aName

The file name to be parsed, using the session path and the related path to provide the missing components.

const TDesC &aRelated

The related file specification.

TParse &aParse

A TParse objct that provides functions for extracting individual components of the resulting file name.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.


MkDir()

Capability: DependentIf aPath is /Sys then Tcb capability is required. If aPath begins with /Private and does not match this process' SID then AllFiles capability is required. If aPath is /Resource then Tcb capability is required.

IMPORT_C TInt MkDir(const TDesC &aPath);

Description

Makes a directory.

It should be a sub-directory of an existing directory and its name should be unique within its parent directory, otherwise the function returns an error.

Note that if a filename is specified in the argument, it is ignored. Therefore, there should be a trailing backslash after the final directory name in the argument to indicate that it is a directory, not a filename.

Note also that because this method can return an error code (eg. because the disk is full) before checking whether the path already exists, it is not appropriate to use it just to work out whether a path exists or not.

See MkDirAll(), which may also create intermediate directories.

Parameters

const TDesC &aPath

The name of the new directory. Any path components which are not specified here will be taken from the session path.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes. Even if another error code is returned, (for example, if the disk is full) it is still possible that the path may already exist.

See also:


MkDirAll()

Capability: DependentIf aPath is /Sys then Tcb capability is required. If aPath begins with /Private and does not match this process' SID then AllFiles capability is required. If aPath is /Resource then Tcb capability is required.

IMPORT_C TInt MkDirAll(const TDesC &aPath);

Description

Makes one or more directories.

Any valid path component specified in aPath which does not already exist is created as a directory.

Note that if a filename is specified in the argument, it is ignored. Therefore, there should be a trailing backslash after the final directory name in the argument to indicate that it is a directory, not a filename.

Note also that because this method can return an error code (eg. because the disk is full) before checking whether the path already exists, it is not appropriate to use it just to work out whether a path exists or not.

See MkDir(), which creates only a single new directory.

Parameters

const TDesC &aPath

The path name specifiying the directory or directories to create. If the function completes successfully, this path identifies a valid directory. Any path components which are not specified here are taken from the session path.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes. Even if another error code is returned, (for example, if the disk is full) it is still possible that the path may already exist.

See also:


RmDir()

Capability: DependentIf aPath is /Sys then Tcb capability is required. If aPath begins with /Private and does not match this process' SID then AllFiles capability is required. If aPath is /Resource then Tcb capability is required.

IMPORT_C TInt RmDir(const TDesC &aPath);

Description

Removes a directory.

The directory must be empty and cannot be the root directory.

Note that if a filename is specified in the argument, it is ignored. Therefore, there should be a trailing backslash after the final directory name in the argument to indicate that it is a directory, not a filename.

See class CFileMan for information on deleting a non-empty directory and all of its contents.

Parameters

const TDesC &aPath

The path name of the directory to be removed. Any path components which are not specified here are taken from the session path. Only the lowest-level directory identified is removed.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


GetDir()

IMPORT_C TInt GetDir(const TDesC &aName, TUint anEntryAttMask, TUint anEntrySortKey, CDir *&anEntryList) const;

Description

Gets a filtered list of a directory's contents.

The bitmask determines which file and directory entry types should be listed. The sort key determines the order in which they are listed.

Notes:

1. If sorting by UID (as indicated when the ESortByUid bit is OR'ed with the sort key), then UID information will be included in the listing whether or not KEntryAttAllowUid is specified in anAttMask.

2. The function sets aFileList to NULL, and then allocates memory for it before appending entries to the list. Therefore, aFileList should have no memory allocated to it before this function is called, otherwise this memory will become orphaned.

3. The caller of this function is responsible for deleting aFileList after the function has returned.

Parameters

const TDesC &aName

The name of the directory for which a listing is required. Wildcards may be used to specify particular files.

TUint anEntryAttMask

Bitmask indicating the attributes of interest. Only files and directories whose attributes match those specified here can be included in the listing. For more information, see KEntryAttMatchMask and the other directory entry details. Also see KEntryAttNormal and the other file or directory attributes.

TUint anEntrySortKey

The sort key. This is a set of flags indicating the order in which the entries are to be sorted. These flags are defined by TEntryKey.

CDir *&anEntryList

On return contains a filtered list of directory and file entries.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


GetDir()

IMPORT_C TInt GetDir(const TDesC &aName, TUint anEntryAttMask, TUint anEntrySortKey, CDir *&anEntryList, CDir *&aDirList) const;

Description

Gets a filtered list of the directory and file entries contained in a directory, and a list of the directory entries only.

The bitmask determines which file and directory entry types should be listed in aFileList. The contents of the second list, aDirList are not affected by the bitmask; it returns all directory entries contained in directory aName. The sort key determines the order in which both lists are sorted.

Notes:

1. If sorting by UID (as indicated when the ESortByUid bit is OR'ed with the sort key), then UID information will be included in the listing whether or not KEntryAttAllowUid is specified in anAttMask.

2. The function sets both aFileList and aDirList to NULL, and then allocates memory to them before appending entries to the lists. Therefore, aFileList and aDirList should have no memory allocated to them before this function is called, otherwise the allocated memory will become orphaned.

3. The caller of this function is responsible for deleting aFileList and aDirList after the function has returned.

Parameters

const TDesC &aName

The name of the directory for which a listing is required. Wildcards may be used to specify particular files.

TUint anEntryAttMask

Bitmask indicating the attributes of interest. Only files and directories whose attributes match those specified here can be included in aFileList. aDirList is unaffected by this mask. For more information, see KEntryAttMatchMask and the other directory entry details. Also see KEntryAttNormal and the other file or directory attributes.

TUint anEntrySortKey

The sort key. This is a set of flags indicating the order in which the entries in both lists are to be sorted. These flags are defined by TEntryKey.

CDir *&anEntryList

On return contains a filtered list of directory and file entries.

CDir *&aDirList

On return contains a filtered list of directory entries only.

Return value

TInt

KErrNone if successful, otherwise one of the other system-wide error codes.

See also:


GetDir()

IMPORT_C TInt GetDir(const TDesC &aName, const TUidType &anEntryUid, TUint anEntrySortKey, CDir *&aFileList) const;

Description

Gets a filtered list of a directory's contents by UID type.

The aUidType parameter determines which file entry types should be listed. The sort key determines the order in which they are listed.

Notes:

1. The function sets aFileList to NULL, and then allocates memory for it before appending entries to the list. Therefore, aFileList should have no memory allocated to it before this function is called, otherwise this memory will become orphaned.

2. The caller of this function is responsible for deleting aFileList after the function has returned.

Parameters

const TDesC &aName

The name of the directory for which a listing is required. Wildcards may be used to specify particular files.

const TUidType &anEntryUid

Only those files whose UIDs match those specified within this UID type will be included in the file list. Any, or all, of the three UIDs within the UID type may be omitted. Any UID which is omitted acts in a similar manner to a wildcard character, matching to all UIDs