API published in: S60 3rd Ed FP 2
Link against: platformenv.lib
Required Capabilities
None
#include <driveinfo.h>
Platform Environment API provides interface for quering the drive information of the system. Methods provided by the API should be used instead of the hard coded drive identifiers. The API consist of the DriveInfo class, PathInfo class and system paths are defined in PathConfiguration.hrh. The PathInfo class is defined in PathInfo.h.
Usage:
#include <DriveInfo.h> // Get the drive identifier of the default removable mass storage. TInt drive; User::LeaveIfError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ) ); // 'drive' contains now the drive identifier of the default removable mass storage. // Get the drive status of the default removable mass storage. TUint status; User::LeaveIfError( DriveInfo::GetDriveStatus( fs, drive, status ) ); // 'status' contains now the drive status of the default removable mass storage. // Get all drives that are visible to the user in TDriveList. TDriveList driveList; TInt driveCount; User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveList, driveCount ) ); // 'driveList' contains now the user visible drives. // 'driveCount'contains now the drive count i.e. number of non zero items in driveList. // Access the drives stored in 'driveList' TInt driveListLen( driveList.Length() ); // The length of 'driveList' for( TInt i( 0 ); i < driveListLen; ++i ) { if ( driveList[ i ] ) // Non zero items are valid drives { // 'i' contains drive identifier specified by TDriveNumber // ... } } // Get all drives that are visible to the user in DriveInfo::TDriveArray. DriveInfo::TDriveArray driveArray; User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveArray ) ); // 'driveArray' contains now the user visible drives. // Access the drives stored in 'driveArray' driveCount = driveArray.Count() ); // The number of drives stored in 'driveArray' for( TInt i( 0 ); i < driveCount; ++i ) { TDriveNumber drive( driveArray[ i ] ); // The drive identifier at position 'i' TChar driveLetter( driveArray.LetterAt( i ) ); // The drive letter at position 'i' // ... }
Error handling:
System wide error codes are returned to indicate errors in methods that can fail.
Public Types | |
enum | TDefaultDrives { EDefaultRom = 0, EDefaultRam, EDefaultSystem, EDefaultPhoneMemory, EDefaultMassStorage, EDefaultRemovableMassStorage } |
Enumeration Default Drives to be used with GetDefaultDrive() method. More... | |
enum | TStatus { EDriveInternal = 0x1, EDriveRemovable = 0x2, EDriveRemote = 0x4, EDrivePresent = 0x8, EDriveLocked = 0x10, EDriveCorrupt = 0x20, EDriveInUse = 0x40, EDriveReadOnly = 0x80, EDriveSubsted = 0x100, EDriveUserVisible = 0x200, EDriveExternallyMountable = 0x400, EDriveSwEjectable = 0x800, EDriveRom = 0x1000, EDriveRam = 0x2000, EDriveFormatted = 0x4000, EDriveFormattable = 0x8000, EDriveLockable = 0x10000, EDriveHasPassword = 0x20000 } |
Enumeration bit mask Status used by GetDriveStatus() method. More... | |
Static Public Member Functions | |
static IMPORT_C TInt | GetDefaultDrive (TInt aDefaultDrive, TInt &aDrive) |
This method gets the default drive of requested type. | |
static IMPORT_C TInt | GetDefaultDrive (TInt aDefaultDrive, TChar &aDriveLetter) |
This method gets the default drive of requested type. | |
static IMPORT_C TInt | GetDriveStatus (RFs &aFs, TInt aDrive, TUint &aStatus) |
This method gets the drive status, a bit mask specified by TStatus. | |
static IMPORT_C TInt | GetUserVisibleDrives (RFs &aFs, TDriveList &aDriveList, TInt &aDriveCount) |
This method gets all the drives that are visible to the user. | |
static IMPORT_C TInt | GetUserVisibleDrives (RFs &aFs, TDriveList &aDriveList, TInt &aDriveCount, TUint aFlags) |
This method gets the user visible drives with specified file server drive attributes. | |
static IMPORT_C TInt | StripUserHiddenDrives (TDriveList &aDriveList) |
This method methods checks the given drive list and removes the drives hidden from the user. | |
static IMPORT_C TInt | DriveCount (const TDriveList &aDriveList) |
This method returns the number of drives in the given drive list. | |
static IMPORT_C TInt | GetUserVisibleDrives (RFs &aFs, TDriveArray &aDriveArray) |
This method gets all the drives that are visible to the user. | |
static IMPORT_C TInt | GetUserVisibleDrives (RFs &aFs, TDriveArray &aDriveArray, TUint aFlags) |
This method gets the user visible drives with specified file server drive attributes. | |
Data Structures | |
class | TDriveArray |
Class TDriveArray provides easy-to-use access to drive identifiers. More... |
|
Enumeration Default Drives to be used with GetDefaultDrive() method.
|
|
Enumeration bit mask Status used by GetDriveStatus() method.
|
|
This method returns the number of drives in the given drive list.
|
|
This method gets the default drive of requested type. If the device does not have the requested default drive, then KErrNotSupported is returned. This happens for example if device supports only internal drives and EDefaultRemovableMassStorage is requested.
|
|
This method gets the default drive of requested type. If the device does not have the requested default drive, then KErrNotSupported is returned. This happens for example if device supports only internal drives and EDefaultRemovableMassStorage is requested.
|
|
This method gets the drive status, a bit mask specified by TStatus.
|
|
This method gets the user visible drives with specified file server drive attributes. Note that file server drive attributes are not equal with TStatus definitions.
|
|
This method gets all the drives that are visible to the user.
|
|
This method gets the user visible drives with specified file server drive attributes. Note that file server drive attributes are not equal with TStatus definitions.
|
|
This method gets all the drives that are visible to the user.
|
|
This method methods checks the given drive list and removes the drives hidden from the user. It is intended to be used with the drive lists that are not read by using GetUserVisibleDrives() method e.g. the drive list has been got as a parameter elsewhere.
|