Windows: Use a more modern API for determining the save directory.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2019-12-22 22:41:13 -04:00
parent bc12312f0f
commit 453063e20f
+13 -2
View File
@@ -37,6 +37,8 @@
#ifdef LOVE_WINDOWS
# include <windows.h>
# include <direct.h>
# include <initguid.h>
# include <Shlobj.h>
#else
# include <sys/param.h>
# include <unistd.h>
@@ -497,8 +499,17 @@ std::string Filesystem::getAppdataDirectory()
#ifdef LOVE_WINDOWS_UWP
appdata = getUserDirectory();
#elif defined(LOVE_WINDOWS)
wchar_t *w_appdata = _wgetenv(L"APPDATA");
appdata = to_utf8(w_appdata);
PWSTR path = nullptr;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &path)))
{
appdata = to_utf8(path);
CoTaskMemFree(path);
}
else
{
wchar_t *w_appdata = _wgetenv(L"APPDATA");
appdata = to_utf8(w_appdata);
}
replace_char(appdata, '\\', '/');
#elif defined(LOVE_MACOS)
appdata = normalize(love::macos::getAppdataDirectory());