Skip to content

Add SPIFFS wrapper for info function #918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2015
Merged
Show file tree
Hide file tree
Changes from all 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 hardware/esp8266com/esp8266/cores/esp8266/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ bool FS::format() {
return _impl->format();
}

bool FS::info(uint32_t *total, uint32_t *used){
if (!_impl) {
return false;
}
return _impl->info(total,used);
}

File FS::open(const String& path, const char* mode) {
return open(path.c_str(), mode);
}
Expand Down
1 change: 1 addition & 0 deletions hardware/esp8266com/esp8266/cores/esp8266/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class FS
bool begin();

bool format();
bool info(uint32_t *total, uint32_t *used);

File open(const char* path, const char* mode);
File open(const String& path, const char* mode);
Expand Down
1 change: 1 addition & 0 deletions hardware/esp8266com/esp8266/cores/esp8266/FSImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class FSImpl {
public:
virtual bool begin() = 0;
virtual bool format() = 0;
virtual bool info(uint32_t *total, uint32_t *used) = 0;
virtual FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) = 0;
virtual bool exists(const char* path) = 0;
virtual DirImplPtr openDir(const char* path) = 0;
Expand Down
9 changes: 9 additions & 0 deletions hardware/esp8266com/esp8266/cores/esp8266/spiffs_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ class SPIFFSImpl : public FSImpl {
return true;
}

bool info(uint32_t *total, uint32_t *used) override{
auto rc = SPIFFS_info(&_fs, total, used);
if (rc != SPIFFS_OK) {
DEBUGV("SPIFFS_format: rc=%d, err=%d\r\n", rc, _fs.err_code);
return false;
}
return true;
}

bool remove(const char* path) override {
char tmpName[SPIFFS_OBJ_NAME_LEN];
strlcpy(tmpName, path, sizeof(tmpName));
Expand Down