33 lines
542 B
C++
33 lines
542 B
C++
#pragma once
|
|
|
|
/**
|
|
* helper class to iterate all free clusters of the Filesystem.
|
|
* starts at cluster number 2 and then iterates over all subsequent clusters
|
|
* stopping at the free ones
|
|
*/
|
|
class FreeClusterIterator {
|
|
|
|
FS& fs;
|
|
ClusterNr cur;
|
|
|
|
public:
|
|
|
|
FreeClusterIterator(FS& fs) : fs(fs), cur(2) {
|
|
|
|
}
|
|
|
|
/** get the next free cluster that is available */
|
|
ClusterNr next() {
|
|
|
|
// TODO: end of filesystem reached
|
|
|
|
while(true) {
|
|
const ClusterNr tmp = fs.getNextCluster(cur);
|
|
if (tmp.isFree()) {return cur;}
|
|
++cur;
|
|
}
|
|
|
|
}
|
|
|
|
};
|