2
|
1 #ifdef _WIN32
|
|
2 #include <shlobj.h>
|
5
|
3 #elif defined(MACOSX)
|
|
4 #include "sys/osx/filesystem.h"
|
2
|
5 #endif
|
|
6 #include <filesystem>
|
|
7 #include <limits.h>
|
5
|
8 #include <QMessageBox>
|
2
|
9 #include "config.h"
|
|
10 #include "filesystem.h"
|
5
|
11 #include "string_utils.h"
|
2
|
12
|
|
13 std::filesystem::path get_config_path(void) {
|
|
14 std::filesystem::path cfg_path;
|
|
15 #ifdef _WIN32
|
|
16 char buf[PATH_MAX+1];
|
|
17 if (SHGetFolderPathAndSubDir(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, CONFIG_DIR, buf) == S_OK)
|
|
18 cfg_path = std::filesystem::path(buf) / CONFIG_NAME;
|
|
19 #elif defined(MACOSX)
|
|
20 /* hope and pray that std::filesystem can handle tildes... */
|
5
|
21 cfg_path = std::filesystem::path(StringUtils::Utf8ToWstr(osx::GetApplicationSupportDirectory())) / CONFIG_DIR / CONFIG_NAME;
|
2
|
22 #else // just assume POSIX
|
|
23 cfg_path = std::filesystem::path(getenv("HOME")) / ".config" / CONFIG_DIR / CONFIG_NAME;
|
|
24 #endif
|
|
25 return cfg_path;
|
|
26 }
|