×
Namespaces

Variants
Actions

How to check free space on memory card

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): N78
Compatibility
Platform(s): S60 3rd,3rd FP1, 3rd Fp2
Platform Security
Signing Required: Self Signed
Article
Keywords: keywords=TDriveInfo,TDriveInfo::Drive(),TDriveInfo::Volume()
Created: lming (01 Nov 2008)
Last edited: hamishwillee (22 Nov 2011)

This snippet shows how the application can check whether there is enough free space on a memory card before attempting to save a file.

Source file

//necessary library
LIBRARY efsrv.lib
//necessary header file
#include <f32file.h>
 
RFs fileSession;
TVolumeInfo volumeInfo;
 
//open RFs session
fileSession.Connect();
 
//freeSpace will store number of free memory card in Bytes
TBuf<64> freeSpace;
TInt64 freeKBytes;
//Contains drive information.
TDriveInfo driveInfo;
 
//check all drives from A to Z
for (TInt driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++)
{
//Gets information of this drive
fileSession.Drive(driveInfo,driveNumber);
 
//if this drive is EMediaNANDFlash,we find drive of Memory card
// also reported my DiBo Members that on some devices it can be EMediaHardDisk
// ref: [http://www.developer.nokia.com/Community/Discussion/showthread.php?156990-Free-system-memory]
if(driveInfo.iType == EMediaNANDFlash)
{
//recode its free space in bytes
fileSession.Volume(volumeInfo,driveNumber);
freeKBytes = volumeInfo.iFree/1024;
freeSpace.Num(freeKBytes);
break;
}
}
 
....
//close RFs session
fileSession.Close();

Postconditions

The freeSpace variable the free memory space in bytes, on the memory card.


Internal Links:

This page was last modified on 22 November 2011, at 09:45.
64 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×