File tree 5 files changed +40
-0
lines changed
5 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,13 @@ bool FS::gc() {
272
272
return _impl->gc ();
273
273
}
274
274
275
+ bool FS::check () {
276
+ if (!_impl) {
277
+ return false ;
278
+ }
279
+ return _impl->check ();
280
+ }
281
+
275
282
bool FS::format () {
276
283
if (!_impl) {
277
284
return false ;
Original file line number Diff line number Diff line change @@ -221,7 +221,9 @@ class FS
221
221
bool rmdir (const char * path);
222
222
bool rmdir (const String& path);
223
223
224
+ // Low-level FS routines, not needed by most applications
224
225
bool gc ();
226
+ bool check ();
225
227
226
228
friend class ::SDClass; // More of a frenemy, but SD needs internal implementation to get private FAT bits
227
229
protected:
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class FSImpl {
85
85
virtual bool mkdir (const char * path) = 0;
86
86
virtual bool rmdir (const char * path) = 0;
87
87
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.
88
89
};
89
90
90
91
} // namespace fs
Original file line number Diff line number Diff line change @@ -219,6 +219,11 @@ class SPIFFSImpl : public FSImpl
219
219
return SPIFFS_gc_quick ( &_fs, 0 ) == SPIFFS_OK;
220
220
}
221
221
222
+ bool check () override
223
+ {
224
+ return SPIFFS_check (&_fs) == SPIFFS_OK;
225
+ }
226
+
222
227
protected:
223
228
friend class SPIFFSFileImpl ;
224
229
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``
402
402
``maxPathLength `` — max file name length (including one byte for zero
403
403
termination)
404
404
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
+
405
430
Directory object (Dir)
406
431
----------------------
407
432
You can’t perform that action at this time.
0 commit comments