1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

Make SPIFFS garbage collection publicly available (#5944)

Original issue: https://github.com/esp8266/Arduino/issues/2870
This commit is contained in:
Gijs Noorlander 2019-04-10 19:27:24 +02:00 committed by Earle F. Philhower, III
parent 9712170276
commit f950d53d82
4 changed files with 18 additions and 3 deletions

View File

@ -262,6 +262,13 @@ void FS::end() {
}
}
bool FS::gc() {
if (!_impl) {
return false;
}
return _impl->gc();
}
bool FS::format() {
if (!_impl) {
return false;

View File

@ -206,6 +206,8 @@ public:
bool rmdir(const char* path);
bool rmdir(const String& path);
bool gc();
protected:
FSImplPtr _impl;
};

View File

@ -82,6 +82,7 @@ public:
virtual bool remove(const char* path) = 0;
virtual bool mkdir(const char* path) = 0;
virtual bool rmdir(const char* path) = 0;
virtual bool gc() { return true; } // May not be implemented in all file systems.
};
} // namespace fs

View File

@ -208,6 +208,11 @@ public:
return true;
}
bool gc() override
{
return SPIFFS_gc_quick( &_fs, 0 ) == SPIFFS_OK;
}
protected:
friend class SPIFFSFileImpl;
friend class SPIFFSDirImpl;