1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-04 18:03:20 +03:00

add fileSize() method to Dir object

This commit is contained in:
Martin Ayotte 2015-08-12 22:12:22 -04:00
parent 1cd99391c3
commit 568c48b065
4 changed files with 17 additions and 0 deletions

View File

@ -144,6 +144,14 @@ String Dir::fileName() {
return _impl->fileName();
}
size_t Dir::fileSize() {
if (!_impl) {
return 0;
}
return _impl->fileSize();
}
bool Dir::next() {
if (!_impl) {
return false;

View File

@ -78,6 +78,7 @@ public:
File openFile(const char* mode);
String fileName();
size_t fileSize();
bool next();
protected:

View File

@ -56,6 +56,7 @@ public:
virtual ~DirImpl() { }
virtual FileImplPtr openFile(OpenMode openMode, AccessMode accessMode) = 0;
virtual const char* fileName() = 0;
virtual size_t fileSize() = 0;
virtual bool next() = 0;
};

View File

@ -308,6 +308,13 @@ public:
return (const char*) _dirent.name;
}
size_t fileSize() override {
if (!_valid)
return 0;
return _dirent.size;
}
bool next() override {
spiffs_dirent* result = SPIFFS_readdir(&_dir, &_dirent);
_valid = (result != nullptr);