Skip to content

Commit

Permalink
Store configuration file in AppData root if not in working directory (#…
Browse files Browse the repository at this point in the history
…693)

* Store configuration file in AppData root if not in working directory

This fixes MacOS app bundles, as the emulator cannot write the config
file into the app bundle.

* Remove duplicate fs calls

* I'm an idiot sandwich

---------

Co-authored-by: wheremyfoodat <[email protected]>
  • Loading branch information
twvd and wheremyfoodat authored Dec 26, 2024
1 parent 8cc9bfb commit e8c0b7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void EmulatorConfig::load() {
return;
}

printf("Loading existing configuration file %s\n", path.string().c_str());
toml::value data;

try {
Expand Down
10 changes: 8 additions & 2 deletions src/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ std::filesystem::path Emulator::getConfigPath() {
if constexpr (Helpers::isAndroid()) {
return getAndroidAppPath() / "config.toml";
} else {
return std::filesystem::current_path() / "config.toml";
std::filesystem::path localPath = std::filesystem::current_path() / "config.toml";

if (std::filesystem::exists(localPath)) {
return localPath;
} else {
return getAppDataRoot() / "config.toml";
}
}
}
#endif
Expand Down Expand Up @@ -468,4 +474,4 @@ void Emulator::reloadSettings() {
}
}
#endif
}
}

0 comments on commit e8c0b7f

Please sign in to comment.