16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 03:09:18 +02:00

refactor: extract user_config_path() helper

Consolidates platform-specific config-directory logic (APPDATA on Windows,
~/Library/Application Support on macOS, ~/.config on Linux) into a single
user_config_path(filename) function in utilities/utilities.{cpp,h}, removing
copy-pasted #ifdef blocks from application.cpp, editor/editorSettings.cpp,
input/{keyboard,gamepad,drivermouse,uart}input.cpp.
This commit is contained in:
Mateusz Włodarczyk
2026-06-30 21:30:36 +02:00
parent 7c88907f6b
commit fe603f15eb
8 changed files with 38 additions and 78 deletions

View File

@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "editor/editorSettings.hpp"
#include "utilities/Logs.h"
#include "utilities/utilities.h"
#include <cstdlib>
#include <filesystem>
@@ -23,14 +24,8 @@ namespace fs = std::filesystem;
fs::path settings_path()
{
#ifdef _WIN32
if (const char *appdata = std::getenv("APPDATA"))
return fs::path(appdata) / "MaSzyna" / "eu07_editor.ini";
#else
if (const char *home = std::getenv("HOME"))
return fs::path(home) / ".config" / "MaSzyna" / "eu07_editor.ini";
#endif
return fs::path("eu07_editor.ini");
fs::path p = user_config_path("eu07_editor.ini");
return p.empty() ? fs::path("eu07_editor.ini") : p;
}
const char *scheme_to_string(editorSettings::movement_scheme scheme)