openmw-tes3coop/components/files/windowspath.cpp
Lukasz Gromanowski 7c24ae9ac7 Issue #168 - Configuration cleanup - WIP
This is "work in progress" commit, it shall not be merged alone,
without succeeding commits (it's not fully functional).

Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
2012-01-21 01:31:20 +01:00

57 lines
1.2 KiB
C++

#include "windowspath.hpp"
#if defined(_WIN32) || defined(__WINDOWS__)
#include <cstring>
#include <windows.h>
#include <shobj.h>
namespace Files
{
boost::filesystem::path WindowsPath::getUserPath() const
{
boost::filesystem::path userPath(".");
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"));
userPath = boost::filesystem::path(path);
}
userPath /= suffix;
return userPath;
}
boost::filesystem::path WindowsPath::getGlobalPath() const
{
boost::filesystem::path globalPath(".");
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)))
{
globalPath = boost::filesystem::path(path);
}
globalPath /= suffix;
return globalPath;
}
boost::filesystem::path WindowsPath::getLocalPath() const
{
return boost::filesystem::path("./");
}
} /* namespace Files */
#endif /* defined(_WIN32) || defined(__WINDOWS__) */