sforkowany z mirror/meshtastic-firmware
Change recursive delete to be recursive
rodzic
bc47dd574b
commit
e7dfd14917
|
@ -2,8 +2,8 @@
|
|||
#include "FSCommon.h"
|
||||
|
||||
void listDir(const char * dirname, uint8_t levels)
|
||||
#ifdef FSCom
|
||||
{
|
||||
#ifdef FSCom
|
||||
File root = FSCom.open(dirname);
|
||||
if(!root){
|
||||
return;
|
||||
|
@ -29,29 +29,41 @@ void listDir(const char * dirname, uint8_t levels)
|
|||
}
|
||||
|
||||
void rmDir(const char * dirname)
|
||||
#ifdef FSCom
|
||||
{
|
||||
File root = FSCom.open(dirname);
|
||||
if(!root){
|
||||
#ifdef FSCom
|
||||
File file = FSCom.open(dirname);
|
||||
if(!file){
|
||||
return;
|
||||
}
|
||||
if(!root.isDirectory()){
|
||||
if(!file.isDirectory()){
|
||||
file.close();
|
||||
FSCom.remove(file.name());
|
||||
// DEBUG_MSG("Remove FILE %s\n", file.name());
|
||||
return;
|
||||
}
|
||||
|
||||
File file = root.openNextFile();
|
||||
while(file){
|
||||
if(file.isDirectory() && !String(file.name()).endsWith(".")) {
|
||||
file.close();
|
||||
rmDir(file.name());
|
||||
FSCom.rmdir(file.name());
|
||||
} else {
|
||||
file.close();
|
||||
FSCom.remove(file.name());
|
||||
file.rewindDirectory();
|
||||
while (true) {
|
||||
File entry = file.openNextFile();
|
||||
if (!entry) {
|
||||
break;
|
||||
}
|
||||
char dirpath[100]; // array to hold the result.
|
||||
strcpy(dirpath, dirname); // copy string one into the result.
|
||||
strcat(dirpath,"/"); // append string two to the result.
|
||||
strcat(dirpath,entry.name()); // append string two to the result.
|
||||
if(entry.isDirectory() && !String(entry.name()).endsWith(".")) {
|
||||
entry.close();
|
||||
// DEBUG_MSG("Descend DIR %s\n", dirpath);
|
||||
rmDir(dirpath);
|
||||
} else {
|
||||
entry.close();
|
||||
// DEBUG_MSG("Remove FILE %s\n", entry.name());
|
||||
FSCom.remove(entry.name());
|
||||
}
|
||||
file.close();
|
||||
file = root.openNextFile();
|
||||
}
|
||||
FSCom.rmdir(dirname);
|
||||
// DEBUG_MSG("Remove DIR %s\n", dirname);
|
||||
file.close();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -337,16 +337,16 @@ void NodeDB::loadFromDisk()
|
|||
DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version);
|
||||
installDefaultDeviceState();
|
||||
#ifndef NO_ESP32
|
||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||
nvs_flash_erase();
|
||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||
nvs_flash_erase();
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
Bluefruit.begin();
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
Bluefruit.begin();
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
#endif
|
||||
} else {
|
||||
DEBUG_MSG("Loaded saved devicestate version %d\n", devicestate.version);
|
||||
|
|
Ładowanie…
Reference in New Issue