diff options
Diffstat (limited to 'backends/platform/sdl/win32')
-rw-r--r-- | backends/platform/sdl/win32/win32.cpp | 34 | ||||
-rw-r--r-- | backends/platform/sdl/win32/win32.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 01471e9cb2..9459263ae2 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -134,4 +134,38 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { return configFile; } +Common::WriteStream *OSystem_Win32::createLogFile() { + char logFile[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", logFile, sizeof(logFile))) + error("Unable to access application data directory"); + } else { + if (!GetEnvironmentVariable("USERPROFILE", logFile, sizeof(logFile))) + error("Unable to access user profile directory"); + + strcat(logFile, "\\Application Data"); + CreateDirectory(logFile, NULL); + } + + strcat(logFile, "\\ScummVM"); + CreateDirectory(logFile, NULL); + strcat(logFile, "\\Logs"); + CreateDirectory(logFile, NULL); + strcat(logFile, "\\scummvm.log"); + + Common::FSNode file(logFile); + return file.createWriteStream(); + } else { + return 0; + } +} + #endif diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index f18ee6ead1..8379c49437 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -34,6 +34,7 @@ public: protected: virtual Common::String getDefaultConfigFileName(); + virtual Common::WriteStream *createLogFile(); }; #endif |