From 39aad6ece718acb39ad38ba5858f2aeeb5c29474 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 29 Nov 2010 18:30:23 +0000 Subject: SDL: Move createLogFile implementions to the OSystem_SDL subclasses. svn-id: r54581 --- backends/platform/sdl/sdl.cpp | 94 ------------------------------------------- 1 file changed, 94 deletions(-) (limited to 'backends/platform/sdl/sdl.cpp') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 82ff537c51..dc91bd9fe7 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -47,12 +47,6 @@ #include // for getTimeAndDate() -// For logging -#ifdef UNIX -#include -#include -#endif - #ifdef USE_DETECTLANG #ifndef WIN32 #include @@ -254,94 +248,6 @@ Common::WriteStream *OSystem_SDL::createConfigWriteStream() { return file.createWriteStream(); } -#define DEFAULT_LOG_FILE "scummvm.log" - -Common::WriteStream *OSystem_SDL::createLogFile() { -#if defined(MACOSX) - return 0; -#elif defined(UNIX) - const char *home = getenv("HOME"); - if (home == NULL) - return 0; - - Common::String logFile(home); - logFile += "/.scummvm"; - - struct stat sb; - - // Check whether the dir exists - if (stat(logFile.c_str(), &sb) == -1) { - // The dir does not exist, or stat failed for some other reason. - if (errno != ENOENT) - return 0; - - // If the problem was that the path pointed to nothing, try - // to create the dir. - if (mkdir(logFile.c_str(), 0755) != 0) - return 0; - } else if (!S_ISDIR(sb.st_mode)) { - // Path is no directory. Oops - return 0; - } - - logFile += "/logs"; - - // Check whether the dir exists - if (stat(logFile.c_str(), &sb) == -1) { - // The dir does not exist, or stat failed for some other reason. - if (errno != ENOENT) - return 0; - - // If the problem was that the path pointed to nothing, try - // to create the dir. - if (mkdir(logFile.c_str(), 0755) != 0) - return 0; - } else if (!S_ISDIR(sb.st_mode)) { - // Path is no directory. Oops - return 0; - } - - logFile += "/" DEFAULT_LOG_FILE; - - Common::FSNode file(logFile); - return file.createWriteStream(); -#elif defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) - 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 -} - void OSystem_SDL::setWindowCaption(const char *caption) { Common::String cap; byte c; -- cgit v1.2.3