#pragma once #include #include struct filename_iterator: public std::iterator { 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; #ifdef ESP8266 Dir dir; #endif #ifdef ESP32 File dir; #endif };