import/export config and factory reset

This commit is contained in:
tildearrow 2024-05-18 16:01:47 -05:00
parent 4086cd3fc5
commit 5e213256b6
5 changed files with 353 additions and 290 deletions

View file

@ -19,11 +19,13 @@
#include "engine.h"
#include "../ta-log.h"
#include "../fileutils.h"
#ifdef _WIN32
#include "winStuff.h"
#define CONFIG_FILE "\\furnace.cfg"
#define LOG_FILE "\\furnace.log"
#define LAYOUT_INI "\\layout.ini"
#else
#ifdef __HAIKU__
#include <support/SupportDefs.h>
@ -33,6 +35,8 @@
#include <pwd.h>
#include <sys/stat.h>
#define CONFIG_FILE "/furnace.cfg"
#define LOG_FILE "/furnace.log"
#define LAYOUT_INI "/layout.ini"
#endif
#ifdef IS_MOBILE
@ -172,3 +176,23 @@ bool DivEngine::hasConf(String key) {
DivConfig& DivEngine::getConfObject() {
return conf;
}
void DivEngine::factoryReset() {
conf.clear();
String confPath=configPath+String(CONFIG_FILE);
String layoutPath=configPath+String(LAYOUT_INI);
for (int i=0; i<10; i++) {
String path=confPath;
if (i>0) path+=fmt::sprintf(".%d",i);
deleteFile(path.c_str());
}
for (int i=0; i<10; i++) {
String path=layoutPath;
if (i>0) path+=fmt::sprintf(".%d",i);
deleteFile(path.c_str());
}
exit(0);
}

View file

@ -766,6 +766,9 @@ class DivEngine {
// get whether config value exists
bool hasConf(String key);
// reset all settings
void factoryReset();
// calculate base frequency/period
double calcBaseFreq(double clock, double divider, int note, bool period);