1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +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(); return _impl->fileName();
} }
size_t Dir::fileSize() {
if (!_impl) {
return 0;
}
return _impl->fileSize();
}
bool Dir::next() { bool Dir::next() {
if (!_impl) { if (!_impl) {
return false; return false;

View File

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

View File

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

View File

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