mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 17:52:35 +00:00
LittleFS recursive display and erase. Cause we got directories now, baby!
This commit is contained in:
@@ -1,22 +1,43 @@
|
||||
#include "configuration.h"
|
||||
#include "FSCommon.h"
|
||||
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels)
|
||||
#ifdef FSCom
|
||||
{
|
||||
File root = fs.open(dirname);
|
||||
if(!root){
|
||||
return;
|
||||
}
|
||||
if(!root.isDirectory()){
|
||||
return;
|
||||
}
|
||||
|
||||
File file = root.openNextFile();
|
||||
while(file){
|
||||
if(file.isDirectory()){
|
||||
if(levels){
|
||||
listDir(fs, file.name(), levels -1);
|
||||
}
|
||||
} else {
|
||||
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||
}
|
||||
file.close();
|
||||
file = root.openNextFile();
|
||||
}
|
||||
file.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
void fsInit()
|
||||
{
|
||||
#ifdef FSCom
|
||||
if (!FSBegin())
|
||||
{
|
||||
DEBUG_MSG("ERROR filesystem mount Failed\n");
|
||||
DEBUG_MSG("ERROR filesystem mount Failed. Formatting...\n");
|
||||
assert(0); // FIXME - report failure to phone
|
||||
}
|
||||
|
||||
DEBUG_MSG("Filesystem files:\n");
|
||||
File dir = FSCom.open("/");
|
||||
File f = dir.openNextFile();
|
||||
while (f) {
|
||||
DEBUG_MSG(" %s\n", f.name());
|
||||
f.close();
|
||||
f = dir.openNextFile();
|
||||
}
|
||||
listDir(FSCom, "/", 10);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user