×
Namespaces

Variants
Actions
Revision as of 07:38, 30 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to get drive size

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: Den123 (26 Jun 2007)
Last edited: hamishwillee (30 May 2013)

Header:

#include <f32file.h>

Link against:

LIBRARY efsrv.lib

Capabilities:

CAPABILITY NONE


#include <e32base.h>
 
class ClassName
{
public:
static TInt GetDriveSizeInfoL(TChar aDriveChar, TInt64& aDriveTotalSize, TInt64& aDriveFreeSize);
};


#include <f32file.h>
 
TInt ClassName :: GetDriveSizeInfoL(TChar aDriveChar, TInt64& aDriveTotalSize, TInt64& aDriveFreeSize)
{
TInt err = KErrNone;
 
aDriveTotalSize = 0;
aDriveFreeSize = 0;
 
RFs fs;
User::LeaveIfError( fs.Connect() );
 
TInt driveIndex;
err = RFs :: CharToDrive( aDriveChar, driveIndex );
if(err == KErrNone)
{
TDriveInfo driveInfo;
err = fs.Drive( driveInfo, driveIndex );
if(err == KErrNone)
{
if(driveInfo.iMediaAtt & KMediaAttFormattable) // size defined only for formattable drives
{
TVolumeInfo volumeInfo;
err = fs.Volume(volumeInfo, driveIndex);
if(err == KErrNone)
{
// now we can get drive size info
aDriveTotalSize = volumeInfo.iSize;
aDriveFreeSize = volumeInfo.iFree;
}
}
else
err = KErrArgument;
}
else
err = KErrArgument;
}
fs.Close();
 
return err;
}


How to use:

TInt64 size, freeSize;
if(ClassName::GetDriveSizeInfoL('C', size, freeSize)==KErrNone)
{
....
}
This page was last modified on 30 May 2013, at 07:38.
47 page views in the last 30 days.
×