Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cores/esp8266/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ void FS::end() {
}
}

bool FS::gc() {
if (!_impl) {
return false;
}
return _impl->gc();
}

bool FS::format() {
if (!_impl) {
return false;
Expand Down
6 changes: 4 additions & 2 deletions cores/esp8266/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class File : public Stream
File openNextFile();

String readString() override;

protected:
FileImplPtr _p;

Expand Down Expand Up @@ -181,7 +181,7 @@ class FS

bool begin();
void end();

bool format();
bool info(FSInfo& info);

Expand All @@ -206,6 +206,8 @@ class FS
bool rmdir(const char* path);
bool rmdir(const String& path);

bool gc();

protected:
FSImplPtr _impl;
};
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/FSImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class FSImpl {
virtual bool remove(const char* path) = 0;
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.
};

} // namespace fs
Expand Down
7 changes: 6 additions & 1 deletion cores/esp8266/spiffs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ class SPIFFSImpl : public FSImpl
return true;
}

bool gc() override
{
return SPIFFS_gc_quick( &_fs, 0 ) == SPIFFS_OK;
}

protected:
friend class SPIFFSFileImpl;
friend class SPIFFSDirImpl;
Expand Down Expand Up @@ -290,7 +295,7 @@ class SPIFFSImpl : public FSImpl
(void) report;
(void) arg1;
(void) arg2;

// TODO: spiffs doesn't pass any context pointer along with _check_cb,
// so we can't do anything useful here other than perhaps
// feeding the watchdog
Expand Down