Fix configuration file path on Android

This commit is contained in:
wheremyfoodat 2023-11-28 12:08:25 +02:00
parent 7a78b2cf20
commit 070d5b1c6d
5 changed files with 41 additions and 13 deletions

View file

@ -11,13 +11,15 @@
// We are legally allowed, as per the author's wish, to use the above code without any licensing restrictions
// However we still want to follow the license as closely as possible and offer the proper attributions.
EmulatorConfig::EmulatorConfig(const std::filesystem::path& path) { load(path); }
EmulatorConfig::EmulatorConfig(const std::filesystem::path& path) : filePath(path) { load(); }
void EmulatorConfig::load() {
const std::filesystem::path& path = filePath;
void EmulatorConfig::load(const std::filesystem::path& path) {
// If the configuration file does not exist, create it and return
std::error_code error;
if (!std::filesystem::exists(path, error)) {
save(path);
save();
return;
}
@ -84,8 +86,9 @@ void EmulatorConfig::load(const std::filesystem::path& path) {
}
}
void EmulatorConfig::save(const std::filesystem::path& path) {
void EmulatorConfig::save() {
toml::basic_value<toml::preserve_comments> data;
const std::filesystem::path& path = filePath;
std::error_code error;
if (std::filesystem::exists(path, error)) {