From 8b8fb6d3a4748ded6f47cf057fc22f9aeab225d0 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sun, 4 Aug 2019 21:45:17 +0100 Subject: SDL: Simplify implementation of createLogFile() --- backends/platform/sdl/win32/win32.cpp | 31 +++++++++++-------------------- backends/platform/sdl/win32/win32.h | 12 +----------- 2 files changed, 12 insertions(+), 31 deletions(-) (limited to 'backends/platform/sdl/win32') diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index a116e71e76..cb65fa813a 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -278,31 +278,22 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { return configFile; } -Common::WriteStream *OSystem_Win32::createLogFile() { - // Start out by resetting _logFilePath, so that in case - // of a failure, we know that no log file is open. - _logFilePath.clear(); - +Common::String OSystem_Win32::getDefaultLogFileName() { char logFile[MAXPATHLEN]; // Use the Application Data directory of the user profile. - if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, logFile) == S_OK) { - strcat(logFile, "\\ScummVM"); - CreateDirectory(logFile, NULL); - strcat(logFile, "\\Logs"); - CreateDirectory(logFile, NULL); - strcat(logFile, "\\scummvm.log"); - - Common::FSNode file(logFile); - Common::WriteStream *stream = file.createWriteStream(); - if (stream) - _logFilePath= logFile; - - return stream; - } else { + if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, logFile) != S_OK) { warning("Unable to access application data directory"); - return 0; + return Common::String(); } + + strcat(logFile, "\\ScummVM"); + CreateDirectory(logFile, NULL); + strcat(logFile, "\\Logs"); + CreateDirectory(logFile, NULL); + strcat(logFile, "\\scummvm.log"); + + return logFile; } namespace { diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index 9919495e37..050137ffe1 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -46,18 +46,8 @@ public: virtual Common::String getScreenshotsPath(); protected: - /** - * The path of the currently open log file, if any. - * - * @note This is currently a string and not an FSNode for simplicity; - * e.g. we don't need to include fs.h here, and currently the - * only use of this value is to use it to open the log file in an - * editor; for that, we need it only as a string anyway. - */ - Common::String _logFilePath; - virtual Common::String getDefaultConfigFileName(); - virtual Common::WriteStream *createLogFile(); + virtual Common::String getDefaultLogFileName(); // Override createAudioCDManager() to get our Mac-specific // version. -- cgit v1.2.3