File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -272,6 +272,13 @@ bool FS::gc() {
272272 return _impl->gc ();
273273}
274274
275+ bool FS::check () {
276+ if (!_impl) {
277+ return false ;
278+ }
279+ return _impl->check ();
280+ }
281+
275282bool FS::format () {
276283 if (!_impl) {
277284 return false ;
Original file line number Diff line number Diff line change @@ -221,7 +221,9 @@ class FS
221221 bool rmdir (const char * path);
222222 bool rmdir (const String& path);
223223
224+ // Low-level FS routines, not needed by most applications
224225 bool gc ();
226+ bool check ();
225227
226228 friend class ::SDClass; // More of a frenemy, but SD needs internal implementation to get private FAT bits
227229protected:
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class FSImpl {
8585 virtual bool mkdir (const char * path) = 0;
8686 virtual bool rmdir (const char * path) = 0;
8787 virtual bool gc () { return true ; } // May not be implemented in all file systems.
88+ virtual bool check () { return true ; } // May not be implemented in all file systems.
8889};
8990
9091} // namespace fs
Original file line number Diff line number Diff line change @@ -219,6 +219,11 @@ class SPIFFSImpl : public FSImpl
219219 return SPIFFS_gc_quick ( &_fs, 0 ) == SPIFFS_OK ;
220220 }
221221
222+ bool check () override
223+ {
224+ return SPIFFS_check (&_fs) == SPIFFS_OK ;
225+ }
226+
222227protected:
223228 friend class SPIFFSFileImpl ;
224229 friend class SPIFFSDirImpl ;
Original file line number Diff line number Diff line change @@ -402,6 +402,31 @@ block size - ``pageSize`` — filesystem logical page size - ``maxOpenFiles``
402402``maxPathLength `` — max file name length (including one byte for zero
403403termination)
404404
405+ gc
406+ ~~
407+
408+ .. code :: cpp
409+
410+ SPIFFS.gc()
411+
412+ Only implemented in SPIFFS. Performs a quick garbage collection operation on SPIFFS,
413+ possibly making writes perform faster/better in the future. On very full or very fragmented
414+ filesystems, using this call can avoid or reduce issues where SPIFFS reports free space
415+ but is unable to write additional data to a file. See `this discussion
416+ <https://github.com/esp8266/Arduino/pull/6340#discussion_r307042268> ` for more info.
417+
418+ check
419+ ~~~~~
420+
421+ .. code :: cpp
422+
423+ SPIFFS.begin();
424+ SPIFFS.check();
425+
426+ Only implemented in SPIFFS. Performs an in-depth check of the filesystem metadata and
427+ correct what is repairable. Not normally needed, and not guaranteed to actually fix
428+ anything should there be corruption.
429+
405430Directory object (Dir)
406431----------------------
407432
You can’t perform that action at this time.
0 commit comments