mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-26 14:11:33 +00:00
Merge branch 'non-deprecated-known-folder-api' into 'master'
Use non-deprecated known folder API See merge request OpenMW/openmw!4603
This commit is contained in:
commit
3523ba564a
1 changed files with 17 additions and 10 deletions
|
@ -36,12 +36,14 @@ namespace Files
|
||||||
{
|
{
|
||||||
std::filesystem::path userPath = std::filesystem::current_path();
|
std::filesystem::path userPath = std::filesystem::current_path();
|
||||||
|
|
||||||
WCHAR path[MAX_PATH + 1] = {};
|
PWSTR cString;
|
||||||
|
HRESULT result = SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &cString);
|
||||||
|
if (SUCCEEDED(result))
|
||||||
|
userPath = std::filesystem::path(cString);
|
||||||
|
else
|
||||||
|
Log(Debug::Error) << "Error " << result << " when getting Documents path";
|
||||||
|
|
||||||
if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, nullptr, 0, path)))
|
CoTaskMemFree(cString);
|
||||||
{
|
|
||||||
userPath = std::filesystem::path(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPath / "My Games" / mName;
|
return userPath / "My Games" / mName;
|
||||||
}
|
}
|
||||||
|
@ -54,14 +56,19 @@ namespace Files
|
||||||
|
|
||||||
std::filesystem::path WindowsPath::getGlobalConfigPath() const
|
std::filesystem::path WindowsPath::getGlobalConfigPath() const
|
||||||
{
|
{
|
||||||
|
// The concept of a global config path is absurd on Windows.
|
||||||
|
// Always use local config instead.
|
||||||
|
// The virtual base class requires that we provide this, though.
|
||||||
std::filesystem::path globalPath = std::filesystem::current_path();
|
std::filesystem::path globalPath = std::filesystem::current_path();
|
||||||
|
|
||||||
WCHAR path[MAX_PATH + 1] = {};
|
PWSTR cString;
|
||||||
|
HRESULT result = SHGetKnownFolderPath(FOLDERID_ProgramFiles, 0, nullptr, &cString);
|
||||||
|
if (SUCCEEDED(result))
|
||||||
|
globalPath = std::filesystem::path(cString);
|
||||||
|
else
|
||||||
|
Log(Debug::Error) << "Error " << result << " when getting Program Files path";
|
||||||
|
|
||||||
if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, nullptr, 0, path)))
|
CoTaskMemFree(cString);
|
||||||
{
|
|
||||||
globalPath = std::filesystem::path(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return globalPath / mName;
|
return globalPath / mName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue