mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-18 01:33:58 +12:00
Merge pull request #100 from Wunkolo/config-fs-error-code
config: Use `error_code` prototype of `filesystem::exists`
This commit is contained in:
commit
86de7d8aa3
1 changed files with 11 additions and 4 deletions
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
void EmulatorConfig::load(const std::filesystem::path& path) {
|
void EmulatorConfig::load(const std::filesystem::path& path) {
|
||||||
// If the configuration file does not exist, create it and return
|
// If the configuration file does not exist, create it and return
|
||||||
if (!std::filesystem::exists(path)) {
|
std::error_code error;
|
||||||
|
if (!std::filesystem::exists(path, error)) {
|
||||||
save(path);
|
save(path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,13 +39,19 @@ void EmulatorConfig::load(const std::filesystem::path& path) {
|
||||||
void EmulatorConfig::save(const std::filesystem::path& path) {
|
void EmulatorConfig::save(const std::filesystem::path& path) {
|
||||||
toml::basic_value<toml::preserve_comments> data;
|
toml::basic_value<toml::preserve_comments> data;
|
||||||
|
|
||||||
if (std::filesystem::exists(path)) {
|
std::error_code error;
|
||||||
|
if (std::filesystem::exists(path, error)) {
|
||||||
try {
|
try {
|
||||||
data = toml::parse<toml::preserve_comments>(path);
|
data = toml::parse<toml::preserve_comments>(path);
|
||||||
} catch (std::exception& ex) {
|
} catch (std::exception& ex) {
|
||||||
Helpers::warn("Got exception trying to save config file. Exception: %s\n", ex.what());
|
Helpers::warn("Exception trying to parse config file. Exception: %s\n", ex.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (error) {
|
||||||
|
Helpers::warn("Filesystem error accessing %s (error: %s)\n", path.string().c_str(), error.message().c_str());
|
||||||
|
}
|
||||||
|
printf("Saving new configuration file %s\n", path.string().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
data["GPU"]["EnableShaderJIT"] = shaderJitEnabled;
|
data["GPU"]["EnableShaderJIT"] = shaderJitEnabled;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue