Awoo-Installer/source/util/config.cpp

32 lines
1.6 KiB
C++
Raw Normal View History

2019-10-26 04:38:12 +00:00
#include <filesystem>
#include <unistd.h>
#include "util/INIReader.h"
#include "util/config.hpp"
2019-10-26 04:38:12 +00:00
namespace inst::config {
2019-10-26 04:38:12 +00:00
const std::string appDir = "sdmc:/switch/Awoo-Installer";
const std::string configPath = appDir + "/config.ini";
2019-11-03 21:23:27 +00:00
std::string sigPatchesUrl = "https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip";
2019-10-26 04:38:12 +00:00
bool ignoreReqVers = true;
bool deletePrompt = true;
2019-10-26 04:38:12 +00:00
bool gayMode = false;
void parseConfig() {
INIReader reader(inst::config::configPath);
inst::config::ignoreReqVers = reader.GetBoolean("settings", "ignoreReqVers", inst::config::ignoreReqVers);
inst::config::deletePrompt = reader.GetBoolean("settings", "deletePrompt", inst::config::deletePrompt);
inst::config::gayMode = reader.GetBoolean("settings", "gayMode", inst::config::gayMode);
inst::config::sigPatchesUrl = reader.GetString("settings", "sigPatchesUrl", inst::config::sigPatchesUrl);
2019-10-26 20:03:15 +00:00
return;
2019-10-26 04:38:12 +00:00
}
void setConfig() {
std::filesystem::remove(inst::config::configPath);
std::string data("[settings]\nignoreReqVers=" + std::to_string(inst::config::ignoreReqVers) + "\ndeletePrompt=" + std::to_string(inst::config::deletePrompt) + "\ngayMode=" + std::to_string(inst::config::gayMode) + "\nsigPatchesUrl=" + inst::config::sigPatchesUrl + "\n");
FILE * configFile = fopen(inst::config::configPath.c_str(), "w");
2019-10-26 04:38:12 +00:00
fwrite(data.c_str(), sizeof(char), data.size(), configFile);
fflush(configFile);
fsync(fileno(configFile));
fclose(configFile);
}
}