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 {
|
||||
wchar_t h[MAX_PATH];
|
||||
if(!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, h))) {
|
||||
_lastError = "SHGetFolderPathW() failed in MassBuilderManager::findSaveDirectory()";
|
||||
wchar_t* localappdata_path;
|
||||
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
|
||||
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
|
||||
{
|
||||
_lastError = "SHGetKnownFolderPath() failed in MassBuilderManager::findSaveDirectory()";
|
||||
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)) {
|
||||
_lastError = _saveDirectory + " wasn't found.";
|
||||
|
|
Loading…
Reference in a new issue