Files
ESP8266lib/ext/sd/fat32/UsedSpaceChecker.h
2021-02-21 21:04:11 +01:00

26 lines
480 B
C++

#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;
}
};