1
0
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:
Anonymous Maarten 2018-08-16 19:53:32 +02:00
parent 22437f9f25
commit 19a5a8e578

View File

@ -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