1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 10:36:42 +00:00

fix windows unicode path handling

This commit is contained in:
greye 2014-01-14 17:20:41 +04:00
parent 12dc5cf4ea
commit 584c121f33

View file

@ -10,8 +10,12 @@
#pragma comment(lib, "Shlwapi.lib") #pragma comment(lib, "Shlwapi.lib")
#include <boost/locale.hpp>
namespace bconv = boost::locale::conv;
/** /**
* FIXME: Someone with Windows system should check this and correct if necessary * FIXME: Someone with Windows system should check this and correct if necessary
* FIXME: MAX_PATH is irrelevant for extended-length paths, i.e. \\?\...
*/ */
/** /**
@ -29,16 +33,15 @@ boost::filesystem::path WindowsPath::getUserConfigPath() const
{ {
boost::filesystem::path userPath("."); boost::filesystem::path userPath(".");
TCHAR path[MAX_PATH]; WCHAR path[MAX_PATH + 1];
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path)))
{ {
PathAppend(path, TEXT("My Games")); userPath = boost::filesystem::path(bconv::utf_to_utf<char>(path));
userPath = boost::filesystem::path(path);
} }
return userPath / mName; return userPath / "MyGames" / mName;
} }
boost::filesystem::path WindowsPath::getUserDataPath() const boost::filesystem::path WindowsPath::getUserDataPath() const
@ -51,12 +54,12 @@ boost::filesystem::path WindowsPath::getGlobalConfigPath() const
{ {
boost::filesystem::path globalPath("."); boost::filesystem::path globalPath(".");
TCHAR path[MAX_PATH]; WCHAR path[MAX_PATH + 1];
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, 0, path))) if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, 0, path)))
{ {
globalPath = boost::filesystem::path(path); globalPath = boost::filesystem::path(bconv::utf_to_utf<char>(path));
} }
return globalPath / mName; return globalPath / mName;