mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-10 15:39:02 +00:00
bf42d20f98
Note that it works on my computer, but it *might* not work on older versions of windows.
76 lines
1.6 KiB
C++
76 lines
1.6 KiB
C++
#include "windowspath.hpp"
|
|
|
|
#if defined(_WIN32) || defined(__WINDOWS__)
|
|
|
|
#include <cstring>
|
|
|
|
#include <windows.h>
|
|
#include <shlobj.h>
|
|
#include <Shlwapi.h>
|
|
|
|
#pragma comment(lib, "Shlwapi.lib")
|
|
|
|
namespace Files
|
|
{
|
|
|
|
boost::filesystem::path WindowsPath::getLocalConfigPath() const
|
|
{
|
|
boost::filesystem::path localConfigPath(".");
|
|
boost::filesystem::path suffix("/");
|
|
|
|
TCHAR path[MAX_PATH];
|
|
memset(path, 0, sizeof(path));
|
|
|
|
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path)))
|
|
{
|
|
PathAppend(path, TEXT("My Games"));
|
|
localConfigPath = boost::filesystem::path(path);
|
|
}
|
|
|
|
localConfigPath /= suffix;
|
|
|
|
return localConfigPath;
|
|
}
|
|
|
|
boost::filesystem::path WindowsPath::getGlobalConfigPath() const
|
|
{
|
|
boost::filesystem::path globalConfigPath(".");
|
|
boost::filesystem::path suffix("/");
|
|
|
|
TCHAR path[MAX_PATH];
|
|
memset(path, 0, sizeof(path));
|
|
|
|
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, 0, path)))
|
|
{
|
|
globalConfigPath = boost::filesystem::path(path);
|
|
}
|
|
|
|
globalConfigPath /= suffix;
|
|
|
|
return globalConfigPath;
|
|
}
|
|
|
|
boost::filesystem::path WindowsPath::getRuntimeConfigPath() const
|
|
{
|
|
return boost::filesystem::path("./");
|
|
}
|
|
|
|
boost::filesystem::path WindowsPath::getLocalDataPath() const
|
|
{
|
|
return getLocalConfigPath();
|
|
}
|
|
|
|
boost::filesystem::path WindowsPath::getGlobalDataPath() const
|
|
{
|
|
return getGlobalConfigPath();
|
|
}
|
|
|
|
boost::filesystem::path WindowsPath::getRuntimeDataPath() const
|
|
{
|
|
return boost::filesystem::path("./data/");
|
|
}
|
|
|
|
} /* namespace Files */
|
|
|
|
#endif /* defined(_WIN32) || defined(__WINDOWS__) */
|