DriveInfo Class Reference

API published in: S60 3rd Ed FP 2

Link against: platformenv.lib

Capability Information

Required Capabilities

None


#include <
driveinfo.h>

Detailed Description

Class holds the drive information of the system.

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.

Library PlatformEnv.dll
Since:
3.2

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

Member Enumeration Documentation

enum DriveInfo::TDefaultDrives
 

Enumeration Default Drives to be used with GetDefaultDrive() method.

Since:
3.2
Enumerator:
EDefaultRom  To get the default ROM drive.
EDefaultRam  To get the default RAM drive.
EDefaultSystem  To get the default system drive.

The default system drive is the preferred drive for system specific functionalities.

EDefaultPhoneMemory  To get the default phone memory like FLASH memory, internal memory card, hard drive etc.
EDefaultMassStorage  To get the default mass storage like any kind of memory card, hard drive, USB stick etc.

This definition should be always used, unless a removable mass storage is explicitly required. The default mass storage is the preferred drive for a large amount of user files.

EDefaultRemovableMassStorage  To get the default removable mass storage like memory card, USB stick etc.

This definition should be used only when explicitly removable mass storage is required.

enum DriveInfo::TStatus
 

Enumeration bit mask Status used by GetDriveStatus() method.

Since:
3.2
Enumerator:
EDriveInternal  To indicate that the drive is internal and cannot be physically removed.
EDriveRemovable  To indicate that the drive is physically removable.
EDriveRemote  To indicate that the drive is remote.
EDrivePresent  To indicate that the drive is present.
EDriveLocked  To indicate that the drive is locked.
EDriveCorrupt  To indicate that the drive is corrupt.
EDriveInUse  To indicate that the drive is in use i.e.

reserved for some exclusive usage.

EDriveReadOnly  To indicate that the drive is readonly.
EDriveSubsted  To indicate that the drive is substed.
EDriveUserVisible  To indicate that the drive is user visible.

The UI is allowed to show the drive to the user.

EDriveExternallyMountable  To indicate that the drive is externally mountable i.e.

can be mounted from PC or from other devices.

EDriveSwEjectable  To indicate that the drive is software ejectable.

The user can select software based eject from the UI for this drive.

EDriveRom  To indicate that the drive is ROM drive.
EDriveRam  To indicate that the drive is RAM drive.
EDriveFormatted  To indicate that the drive has been formatted.
EDriveFormattable  To indicate that the drive is formattable.
EDriveLockable  To indicate that the drive is lockable i.e.

password can be set.

EDriveHasPassword  To indicate that the drive is password protected.

Member Function Documentation

static IMPORT_C TInt DriveInfo::DriveCount const TDriveList &  aDriveList  )  [static]
 

This method returns the number of drives in the given drive list.

Since:
3.2
Parameters:
aDriveList A drive list where to count the number of drives.
Returns:
A drive count i.e. number of non zero items in the given drive list.
See also:
TDriveList
static IMPORT_C TInt DriveInfo::GetDefaultDrive TInt  aDefaultDrive,
TChar &  aDriveLetter
[static]
 

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.

Since:
3.2
Parameters:
aDefaultDrive A default drive identifier specified by TDefaultDrives
aDriveLetter Stores a drive letter
Returns:
A system wide error code.
See also:
TDefaultDrives
static IMPORT_C TInt DriveInfo::GetDefaultDrive TInt  aDefaultDrive,
TInt &  aDrive
[static]
 

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.

Since:
3.2
Parameters:
aDefaultDrive A default drive identifier specified by TDefaultDrives
aDrive Stores a drive identifier specified by TDriveNumber
Returns:
A system wide error code.
See also:
TDefaultDrives

TDriveNumber

static IMPORT_C TInt DriveInfo::GetDriveStatus RFs &  aFs,
TInt  aDrive,
TUint &  aStatus
[static]
 

This method gets the drive status, a bit mask specified by TStatus.

Since:
3.2
Parameters:
aFs An opened file server session
aDrive A drive identifier specified by TDriveNumber
aStatus Stores the drive status bit mask specified by TStatus
Returns:
A system wide error code.
See also:
RFs

TDriveNumber

TStatus

static IMPORT_C TInt DriveInfo::GetUserVisibleDrives RFs &  aFs,
TDriveArray aDriveArray,
TUint  aFlags
[static]
 

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.

Since:
3.2
Parameters:
aFs An opened file server session
aDriveArray Stores the user visible drives
aFlags The mask flags specified for RFs::DriveList() method.
Returns:
A system wide error code.
See also:
RFs

TDriveArray

static IMPORT_C TInt DriveInfo::GetUserVisibleDrives RFs &  aFs,
TDriveArray aDriveArray
[static]
 

This method gets all the drives that are visible to the user.

Since:
3.2
Parameters:
aFs An opened file server session
aDriveArray Stores the user visible drives
Returns:
A system wide error code.
See also:
RFs

TDriveArray

static IMPORT_C TInt DriveInfo::GetUserVisibleDrives RFs &  aFs,
TDriveList &  aDriveList,
TInt &  aDriveCount,
TUint  aFlags
[static]
 

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.

Since:
3.2
Parameters:
aFs An opened file server session
aDriveList Stores the user visible drives in the same format than RFs::DriveList() method.
aDriveCount Stores the drive count i.e. number of non zero items in aDriveList.
aFlags The mask flags specified for RFs::DriveList() method.
Returns:
A system wide error code.
See also:
RFs

TDriveList

static IMPORT_C TInt DriveInfo::GetUserVisibleDrives RFs &  aFs,
TDriveList &  aDriveList,
TInt &  aDriveCount
[static]
 

This method gets all the drives that are visible to the user.

Since:
3.2
Parameters:
aFs An opened file server session
aDriveList Stores the user visible drives in the same format than RFs::DriveList() method.
aDriveCount Stores the drive count i.e. number of non zero items in aDriveList.
Returns:
A system wide error code.
See also:
RFs

TDriveList

static IMPORT_C TInt DriveInfo::StripUserHiddenDrives TDriveList &  aDriveList  )  [static]
 

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.

Since:
3.2
Parameters:
aDriveList A drive list where to remove the drives hidden from the user.
Returns:
A drive count i.e. number of non zero items in the given drive list after removal.
See also:
TDriveList

The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2008
Back to top