diff options
author | Johannes Schickel | 2010-11-26 00:52:04 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-11-26 00:52:04 +0000 |
commit | 03df4955636db7a087a4b77d86ff6e62e43140a5 (patch) | |
tree | f25f6b0d007d5489433696bf1b0da45c492b1972 /backends/platform/sdl | |
parent | 425f28405036a0ee6422fe848476561100ade6ab (diff) | |
download | scummvm-rg350-03df4955636db7a087a4b77d86ff6e62e43140a5.tar.gz scummvm-rg350-03df4955636db7a087a4b77d86ff6e62e43140a5.tar.bz2 scummvm-rg350-03df4955636db7a087a4b77d86ff6e62e43140a5.zip |
SDL: Hook up file logger to log on Windows.
For now the log file will be either "%APPDATA%/ScummVM/Logs/scummvm.log" or
"%USERPROFILE%/Application Data/ScummVM/Logs/scummvm.log" to match the
location of the default ScummVM configuration file.
svn-id: r54490
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 5e09eaa957..9bebc63830 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -543,7 +543,37 @@ Common::WriteStream *OSystem_SDL::createLogFile() { Common::FSNode file(logFile); return file.createWriteStream(); #elif defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) - return 0; + 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, "\\" DEFAULT_LOG_FILE); + + Common::FSNode file(logFile); + return file.createWriteStream(); + } else { + return 0; + } #else return 0; #endif |