Skip to content

Commit a973941

Browse files
committed
added function in SDClass to request card size
1 parent b4222b1 commit a973941

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/SD.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
5151
*/
5252

53-
#include "SD.h"
53+
#include <SD.h>
5454

5555
namespace SDLib {
5656

@@ -366,6 +366,19 @@ namespace SDLib {
366366
root.openRoot(volume);
367367
}
368368

369+
/**
370+
Get information about the volume size
371+
372+
@return Returns the volume size in kB of the first volume/partition
373+
*/
374+
uint32_t SDClass::getvolumesize()
375+
{
376+
uint32_t volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
377+
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
378+
volumesize /= 2;
379+
return (volumesize); //2 blocks make 1kB
380+
}
381+
369382
//call this when a card is removed. It will allow you to insert and initialise a new card.
370383
void SDClass::end() {
371384
root.close();

src/SD.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ namespace SDLib {
106106
return rmdir(filepath.c_str());
107107
}
108108

109+
uint32_t getvolumesize();
110+
109111
private:
110112

111113
// This is used to determine the mode used to open a file

0 commit comments

Comments
 (0)