File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,13 @@ void FS::end() {
262262 }
263263}
264264
265+ bool FS::gc () {
266+ if (!_impl) {
267+ return false ;
268+ }
269+ return _impl->gc ();
270+ }
271+
265272bool FS::format () {
266273 if (!_impl) {
267274 return false ;
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ class File : public Stream
107107 File openNextFile ();
108108
109109 String readString () override ;
110-
110+
111111protected:
112112 FileImplPtr _p;
113113
@@ -181,7 +181,7 @@ class FS
181181
182182 bool begin ();
183183 void end ();
184-
184+
185185 bool format ();
186186 bool info (FSInfo& info);
187187
@@ -206,6 +206,8 @@ class FS
206206 bool rmdir (const char * path);
207207 bool rmdir (const String& path);
208208
209+ bool gc ();
210+
209211protected:
210212 FSImplPtr _impl;
211213};
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ class FSImpl {
8282 virtual bool remove (const char * path) = 0;
8383 virtual bool mkdir (const char * path) = 0;
8484 virtual bool rmdir (const char * path) = 0;
85+ virtual bool gc () { return true ; } // May not be implemented in all file systems.
8586};
8687
8788} // namespace fs
Original file line number Diff line number Diff line change @@ -208,6 +208,11 @@ class SPIFFSImpl : public FSImpl
208208 return true ;
209209 }
210210
211+ bool gc () override
212+ {
213+ return SPIFFS_gc_quick ( &_fs, 0 ) == SPIFFS_OK;
214+ }
215+
211216protected:
212217 friend class SPIFFSFileImpl ;
213218 friend class SPIFFSDirImpl ;
@@ -290,7 +295,7 @@ class SPIFFSImpl : public FSImpl
290295 (void ) report;
291296 (void ) arg1;
292297 (void ) arg2;
293-
298+
294299 // TODO: spiffs doesn't pass any context pointer along with _check_cb,
295300 // so we can't do anything useful here other than perhaps
296301 // feeding the watchdog
You can’t perform that action at this time.
0 commit comments