File tree 4 files changed +18
-3
lines changed
4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,13 @@ void FS::end() {
262
262
}
263
263
}
264
264
265
+ bool FS::gc () {
266
+ if (!_impl) {
267
+ return false ;
268
+ }
269
+ return _impl->gc ();
270
+ }
271
+
265
272
bool FS::format () {
266
273
if (!_impl) {
267
274
return false ;
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ class File : public Stream
107
107
File openNextFile ();
108
108
109
109
String readString () override ;
110
-
110
+
111
111
protected:
112
112
FileImplPtr _p;
113
113
@@ -181,7 +181,7 @@ class FS
181
181
182
182
bool begin ();
183
183
void end ();
184
-
184
+
185
185
bool format ();
186
186
bool info (FSInfo& info);
187
187
@@ -206,6 +206,8 @@ class FS
206
206
bool rmdir (const char * path);
207
207
bool rmdir (const String& path);
208
208
209
+ bool gc ();
210
+
209
211
protected:
210
212
FSImplPtr _impl;
211
213
};
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ class FSImpl {
82
82
virtual bool remove (const char * path) = 0;
83
83
virtual bool mkdir (const char * path) = 0;
84
84
virtual bool rmdir (const char * path) = 0;
85
+ virtual bool gc () { return true ; } // May not be implemented in all file systems.
85
86
};
86
87
87
88
} // namespace fs
Original file line number Diff line number Diff line change @@ -208,6 +208,11 @@ class SPIFFSImpl : public FSImpl
208
208
return true ;
209
209
}
210
210
211
+ bool gc () override
212
+ {
213
+ return SPIFFS_gc_quick ( &_fs, 0 ) == SPIFFS_OK;
214
+ }
215
+
211
216
protected:
212
217
friend class SPIFFSFileImpl ;
213
218
friend class SPIFFSDirImpl ;
@@ -290,7 +295,7 @@ class SPIFFSImpl : public FSImpl
290
295
(void ) report;
291
296
(void ) arg1;
292
297
(void ) arg2;
293
-
298
+
294
299
// TODO: spiffs doesn't pass any context pointer along with _check_cb,
295
300
// so we can't do anything useful here other than perhaps
296
301
// feeding the watchdog
You can’t perform that action at this time.
0 commit comments