Skip to content

Commit e3518a5

Browse files
committed
Merge pull request #918 from luc-github/esp8266
Add SPIFFS wrapper for info function
2 parents e052b8c + 320a747 commit e3518a5

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

cores/esp8266/FS.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ bool FS::format() {
174174
return _impl->format();
175175
}
176176

177+
bool FS::info(uint32_t *total, uint32_t *used){
178+
if (!_impl) {
179+
return false;
180+
}
181+
return _impl->info(total,used);
182+
}
183+
177184
File FS::open(const String& path, const char* mode) {
178185
return open(path.c_str(), mode);
179186
}

cores/esp8266/FS.h

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class FS
9393
bool begin();
9494

9595
bool format();
96+
bool info(uint32_t *total, uint32_t *used);
9697

9798
File open(const char* path, const char* mode);
9899
File open(const String& path, const char* mode);

cores/esp8266/FSImpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class FSImpl {
6464
public:
6565
virtual bool begin() = 0;
6666
virtual bool format() = 0;
67+
virtual bool info(uint32_t *total, uint32_t *used) = 0;
6768
virtual FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) = 0;
6869
virtual bool exists(const char* path) = 0;
6970
virtual DirImplPtr openDir(const char* path) = 0;

cores/esp8266/spiffs_api.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ class SPIFFSImpl : public FSImpl {
7676
return true;
7777
}
7878

79+
bool info(uint32_t *total, uint32_t *used) override{
80+
auto rc = SPIFFS_info(&_fs, total, used);
81+
if (rc != SPIFFS_OK) {
82+
DEBUGV("SPIFFS_format: rc=%d, err=%d\r\n", rc, _fs.err_code);
83+
return false;
84+
}
85+
return true;
86+
}
87+
7988
bool remove(const char* path) override {
8089
char tmpName[SPIFFS_OBJ_NAME_LEN];
8190
strlcpy(tmpName, path, sizeof(tmpName));

0 commit comments

Comments
 (0)