MassBuilderManager: use the Known Folders WinAPI.
According to the MS docs, it's supposedly better, so even though CSIDLs are probably not gonna go away because of Microsoft's strong stance on backwards compatibility, might as well use the "better" stuff.
This commit is contained in:
parent
92cab050ad
commit
045aaa8dad
1 changed files with 6 additions and 4 deletions
|
@ -68,13 +68,15 @@ auto MassBuilderManager::gameState() -> GameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MassBuilderManager::findSaveDirectory() -> bool {
|
auto MassBuilderManager::findSaveDirectory() -> bool {
|
||||||
wchar_t h[MAX_PATH];
|
wchar_t* localappdata_path;
|
||||||
if(!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, h))) {
|
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
|
||||||
_lastError = "SHGetFolderPathW() failed in MassBuilderManager::findSaveDirectory()";
|
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
|
||||||
|
{
|
||||||
|
_lastError = "SHGetKnownFolderPath() failed in MassBuilderManager::findSaveDirectory()";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveDirectory = Utility::Directory::join(Utility::Directory::fromNativeSeparators(Utility::Unicode::narrow(h)), "MASS_Builder");
|
_saveDirectory = Utility::Directory::join(Utility::Directory::fromNativeSeparators(Utility::Unicode::narrow(localappdata_path)), "MASS_Builder");
|
||||||
|
|
||||||
if(!Utility::Directory::exists(_saveDirectory)) {
|
if(!Utility::Directory::exists(_saveDirectory)) {
|
||||||
_lastError = _saveDirectory + " wasn't found.";
|
_lastError = _saveDirectory + " wasn't found.";
|
||||||
|
|
Loading…
Reference in a new issue