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]); }
}
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); }
}
RFs::Drive()
returns a TDriveInfo object. That class includes drive and media
attributes, media type, and the battery state
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);
}
RFs::Volume()
is used in a similar manner to RFs::Drive(). To test whether a
volume is present in the drive, use the return value from
Volume(). A value of KErrNotReady indicates that
there is no volume
present.