2019-10-26 04:38:12 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "util/INIReader.h"
|
|
|
|
#include "config.hpp"
|
|
|
|
|
2019-10-26 05:58:32 +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";
|
|
|
|
bool ignoreReqVers = true;
|
|
|
|
bool gayMode = false;
|
|
|
|
|
|
|
|
void parseConfig() {
|
2019-10-26 05:58:32 +00:00
|
|
|
INIReader reader(inst::config::configPath);
|
|
|
|
inst::config::ignoreReqVers = reader.GetBoolean("settings", "ignoreReqVers", true);
|
|
|
|
inst::config::gayMode = reader.GetBoolean("settings", "gayMode", false);
|
2019-10-26 20:03:15 +00:00
|
|
|
return;
|
2019-10-26 04:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setConfig() {
|
2019-10-26 05:58:32 +00:00
|
|
|
std::filesystem::remove(inst::config::configPath);
|
|
|
|
std::string data("[settings]\nignoreReqVers=" + std::to_string(inst::config::ignoreReqVers) + "\ngayMode=" + std::to_string(inst::config::gayMode) + "\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);
|
|
|
|
}
|
|
|
|
}
|