1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

Add a FS::check() optional method (#6340)

* Add a FS::check() optional method

Fixes #2634

Expose any low-level filesystem check operations for users, and add
documentation on this and the gc() methods.

* Update doc w/more gc() info and link
This commit is contained in:
Earle F. Philhower, III
2019-07-26 22:57:27 -07:00
committed by GitHub
parent d2fde8dee0
commit c6bfec900c
5 changed files with 40 additions and 0 deletions

View File

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

View File

@ -221,7 +221,9 @@ public:
bool rmdir(const char* path);
bool rmdir(const String& path);
// Low-level FS routines, not needed by most applications
bool gc();
bool check();
friend class ::SDClass; // More of a frenemy, but SD needs internal implementation to get private FAT bits
protected:

View File

@ -85,6 +85,7 @@ public:
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.
virtual bool check() { return true; } // May not be implemented in all file systems.
};
} // namespace fs

View File

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