2023-12-20 08:19:37 +00:00
|
|
|
#pragma once
|
|
|
|
#include <iterator>
|
|
|
|
|
|
|
|
#include <LittleFS.h>
|
|
|
|
|
|
|
|
struct filename_iterator: public std::iterator<std::input_iterator_tag, const char*> {
|
|
|
|
public:
|
|
|
|
filename_iterator();
|
|
|
|
filename_iterator(const char* path, const char* suffix);
|
|
|
|
void next();
|
|
|
|
filename_iterator& operator++();
|
|
|
|
filename_iterator& operator++(int) {filename_iterator ret = *this; ++(*this); return ret;}
|
|
|
|
bool operator==(const filename_iterator &other) const { return valid == other.valid;}
|
|
|
|
bool operator!=(const filename_iterator &other) const { return !(*this == other); }
|
|
|
|
const char* operator*() const {
|
|
|
|
if (!valid) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return ret.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
String ret;
|
|
|
|
bool valid;
|
|
|
|
const char* suffix;
|
|
|
|
|
2023-12-20 09:47:26 +00:00
|
|
|
#ifdef ESP8266
|
2023-12-20 08:19:37 +00:00
|
|
|
Dir dir;
|
|
|
|
#endif
|
2023-12-20 09:47:26 +00:00
|
|
|
#ifdef ESP32
|
2023-12-20 08:19:37 +00:00
|
|
|
File dir;
|
|
|
|
#endif
|
|
|
|
};
|