worked on FAT stuff and tests
This commit is contained in:
25
ext/sd/fat32/UsedSpaceChecker.h
Normal file
25
ext/sd/fat32/UsedSpaceChecker.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* helper class to determine all clusters whice are used.
|
||||
* starts at cluster number 2 and then iterates over all subsequent clusters
|
||||
*/
|
||||
class UsedSpaceChecker {
|
||||
|
||||
public:
|
||||
|
||||
/** get the number of used clusters */
|
||||
static uint32_t getNumUsedClusters(const FS& fs) {
|
||||
|
||||
uint32_t numUsed = 0;
|
||||
|
||||
for (ClusterNr nr = 2; nr < fs.tmp.entriesPerFAT; ++nr) {
|
||||
ClusterNr next = fs.getNextCluster(nr);
|
||||
if (!next.isFree()) {++numUsed;}
|
||||
}
|
||||
|
||||
return numUsed;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user