Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



How to retrieve drive and volume information

RFs provides a number of functions to extract information about drives and volumes.


Retrieving drive information using DriveList()

You can use RFs::DriveList() to retrieve an array of drives. The drive list consists of an array of 26 bytes. Array index zero corresponds to drive A, one equals B etc. The array member value is a bitmap of drive attributes, or 0 if there is no such drive.

The following code prints each drive in the drive list as a letter, followed by the hex value of the integer indicating the drive's attributes.

TDriveList drivelist;
TChar driveLetter; TInt driveNumber=EDriveA; _LIT(KDrive,"%c: %02x ");
User::LeaveIfError(fsSession.DriveList(drivelist)); for
(;driveNumber<=EDriveZ;driveNumber++) { if (drivelist[driveNumber]) {
User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter));
console->Printf(KDrive, TUint(driveLetter), drivelist[driveNumber]); }
}

[Top]


Retrieving drive information using Drive()

You can also use RFs::Drive() to retrieve a specified drive's attributes.

The following example loops through all possible drives, a-z, and prints a message if a drive is flash-based.

TChar
driveLetter; TDriveInfo driveInfo; _LIT(KFlash,"Drive %c is flash\n"); for
(driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++) {
fsSession.Drive(driveInfo,driveNumber); if (driveInfo.iDriveAtt ==
KDriveAbsent) continue; if (driveInfo.iType == EMediaFlash) {
User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter));
console->Printf(KFlash,driveLetter); }
}


Notes

[Top]


Volume information

You can get volume information comprising all the information provided by TDriveInfo, which additionally gives the volume name, its ID, its size and the amount of free space.

Use RFs::Volume() to get a TVolumeInfo object.

The following example prints out the names of volumes:

TVolumeInfo volumeInfo; _LIT(KVolName,"Volume name:
%S\n"); for (driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++) {
TInt err=fsSession.Volume(volumeInfo,driveNumber); if (err != KErrNone)
continue; User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter);
console->Printf(KVolInfo,&aVolumeInfo.iName);
}


Note