mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
rwgame: read the config file from OpenRW's AppData
This commit is contained in:
parent
22437f9f25
commit
19a5a8e578
@ -1,13 +1,20 @@
|
||||
#include "GameConfig.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
#include <rw/debug.hpp>
|
||||
#include <rw/filesystem.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
#ifdef RW_WINDOWS
|
||||
#include <Shlobj.h>
|
||||
#include <winerror.h>
|
||||
|
||||
#include <platform/RWWindows.hpp>
|
||||
#endif
|
||||
|
||||
const std::string kConfigDirectoryName("OpenRW");
|
||||
|
||||
void GameConfig::loadFile(const rwfs::path &path) {
|
||||
@ -44,9 +51,16 @@ rwfs::path GameConfig::getDefaultConfigPath() {
|
||||
#elif defined(RW_OSX)
|
||||
char *home = getenv("HOME");
|
||||
if (home)
|
||||
return rwfs::path(home) / "Library/Preferences/" /
|
||||
kConfigDirectoryName;
|
||||
return rwfs::path(home) / "Library/Preferences/" / kConfigDirectoryName;
|
||||
|
||||
#elif defined(RW_WINDOWS)
|
||||
wchar_t *widePath;
|
||||
auto res = SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DEFAULT,
|
||||
nullptr, &widePath);
|
||||
if (SUCCEEDED(res)) {
|
||||
auto utf8Path = wideStringToACP(widePath);
|
||||
return rwfs::path(utf8Path) / kConfigDirectoryName;
|
||||
}
|
||||
#else
|
||||
return rwfs::path();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user