From d24b780b7a4c4196c89d4ed310d024e5ab8b17af Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 26 Dec 2024 21:57:12 +0100 Subject: [PATCH] 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. --- src/config.cpp | 1 + src/emulator.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index bfe84193..9b262744 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -27,6 +27,7 @@ void EmulatorConfig::load() { return; } + printf("Loading existing configuration file %s\n", path.string().c_str()); toml::value data; try { diff --git a/src/emulator.cpp b/src/emulator.cpp index 86adbf22..a0693fd4 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -105,7 +105,11 @@ std::filesystem::path Emulator::getConfigPath() { if constexpr (Helpers::isAndroid()) { return getAndroidAppPath() / "config.toml"; } else { - return std::filesystem::current_path() / "config.toml"; + if (std::filesystem::exists(std::filesystem::current_path() / "config.toml")) { + return std::filesystem::current_path() / "config.toml"; + } else { + return getAppDataRoot() / "config.toml"; + } } } #endif