diff options
Diffstat (limited to 'backends/saves/windows/windows-saves.cpp')
-rw-r--r-- | backends/saves/windows/windows-saves.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/backends/saves/windows/windows-saves.cpp b/backends/saves/windows/windows-saves.cpp index b84ab1312d..967f0d8301 100644 --- a/backends/saves/windows/windows-saves.cpp +++ b/backends/saves/windows/windows-saves.cpp @@ -32,37 +32,22 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... +#if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) +// required for SHGFP_TYPE_CURRENT in shlobj.h +#define _WIN32_IE 0x500 +#endif +#include <shlobj.h> #include "common/config-manager.h" #include "common/savefile.h" +#include "backends/platform/sdl/win32/win32_wrapper.h" WindowsSaveFileManager::WindowsSaveFileManager() { char defaultSavepath[MAXPATHLEN]; - OSVERSIONINFO win32OsVersion; - ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); - win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&win32OsVersion); - // Check for non-9X version of Windows. - if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { - // Use the Application Data directory of the user profile. - if (win32OsVersion.dwMajorVersion >= 5) { - if (!GetEnvironmentVariable("APPDATA", defaultSavepath, sizeof(defaultSavepath))) - error("Unable to access application data directory"); - } else { - if (!GetEnvironmentVariable("USERPROFILE", defaultSavepath, sizeof(defaultSavepath))) - error("Unable to access user profile directory"); - - strcat(defaultSavepath, "\\Application Data"); - - // If the directory already exists (as it should in most cases), - // we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND) - if (!CreateDirectory(defaultSavepath, NULL)) { - if (GetLastError() != ERROR_ALREADY_EXISTS) - error("Cannot create Application data folder"); - } - } + // Use the Application Data directory of the user profile. + if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, defaultSavepath) == S_OK) { strcat(defaultSavepath, "\\ScummVM"); if (!CreateDirectory(defaultSavepath, NULL)) { if (GetLastError() != ERROR_ALREADY_EXISTS) @@ -76,6 +61,8 @@ WindowsSaveFileManager::WindowsSaveFileManager() { } ConfMan.registerDefault("savepath", defaultSavepath); + } else { + warning("Unable to access application data directory"); } } |