Don't use rmdir_r but roll our own version.

pull/1516/head
Thomas Göttgens 2022-06-15 17:52:37 +02:00
rodzic b127479961
commit 125f76d984
3 zmienionych plików z 32 dodań i 2 usunięć

Wyświetl plik

@ -28,6 +28,34 @@ void listDir(const char * dirname, uint8_t levels)
#endif
}
void rmDir(const char * dirname)
#ifdef FSCom
{
File root = FSCom.open(dirname);
if(!root){
return;
}
if(!root.isDirectory()){
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.close();
file = root.openNextFile();
}
file.close();
#endif
}
void fsInit()
{
#ifdef FSCom

Wyświetl plik

@ -26,4 +26,6 @@
using namespace Adafruit_LittleFS_Namespace;
#endif
void fsInit();
void fsInit();
void listDir(const char * dirname, uint8_t levels);
void rmDir(const char * dirname);

Wyświetl plik

@ -91,7 +91,7 @@ bool NodeDB::resetRadioConfig()
if (config.device.factory_reset) {
DEBUG_MSG("Performing factory reset!\n");
// first, remove the "/prefs" (this removes most prefs)
FSCom.rmdir_r("/prefs");
rmDir("/prefs");
// second, install default state (this will deal with the duplicate mac address issue)
installDefaultDeviceState();
// third, write to disk