[Scummvm-cvs-logs] SF.net SVN: scummvm:[54581] scummvm/trunk/backends/platform/sdl

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Nov 29 19:30:24 CET 2010


Revision: 54581
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54581&view=rev
Author:   lordhoto
Date:     2010-11-29 18:30:23 +0000 (Mon, 29 Nov 2010)

Log Message:
-----------
SDL: Move createLogFile implementions to the OSystem_SDL subclasses.

Modified Paths:
--------------
    scummvm/trunk/backends/platform/sdl/macosx/macosx.h
    scummvm/trunk/backends/platform/sdl/posix/posix.cpp
    scummvm/trunk/backends/platform/sdl/posix/posix.h
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/sdl/sdl.h
    scummvm/trunk/backends/platform/sdl/win32/win32.cpp
    scummvm/trunk/backends/platform/sdl/win32/win32.h

Modified: scummvm/trunk/backends/platform/sdl/macosx/macosx.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/macosx/macosx.h	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/macosx/macosx.h	2010-11-29 18:30:23 UTC (rev 54581)
@@ -36,6 +36,10 @@
 	virtual void initBackend();
 	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
 	virtual void setupIcon();
+
+private:
+	// TODO: Implement log file support for Mac OS X
+	virtual Common::WriteStream *createLogFile() { return 0; }
 };
 
 #endif

Modified: scummvm/trunk/backends/platform/sdl/posix/posix.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/posix/posix.cpp	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/posix/posix.cpp	2010-11-29 18:30:23 UTC (rev 54581)
@@ -31,6 +31,9 @@
 #include "backends/saves/posix/posix-saves.h"
 #include "backends/fs/posix/posix-fs-factory.h"
 
+#include <errno.h>
+#include <sys/stat.h>
+
 OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName)
 	:
 	_baseConfigName(baseConfigName) {
@@ -67,4 +70,52 @@
 	return configFile;
 }
 
+Common::WriteStream *OSystem_POSIX::createLogFile() {
+	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 += "/scummvm.log";
+
+	Common::FSNode file(logFile);
+	return file.createWriteStream();
+}
+
 #endif

Modified: scummvm/trunk/backends/platform/sdl/posix/posix.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/posix/posix.h	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/posix/posix.h	2010-11-29 18:30:23 UTC (rev 54581)
@@ -43,6 +43,8 @@
 	Common::String _baseConfigName;
 
 	virtual Common::String getDefaultConfigFileName();
+
+	virtual Common::WriteStream *createLogFile();
 };
 
 #endif

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2010-11-29 18:30:23 UTC (rev 54581)
@@ -47,12 +47,6 @@
 
 #include <time.h>	// for getTimeAndDate()
 
-// For logging
-#ifdef UNIX
-#include <errno.h>
-#include <sys/stat.h>
-#endif
-
 #ifdef USE_DETECTLANG
 #ifndef WIN32
 #include <locale.h>
@@ -254,94 +248,6 @@
 	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;

Modified: scummvm/trunk/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.h	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/sdl.h	2010-11-29 18:30:23 UTC (rev 54581)
@@ -113,7 +113,7 @@
 	virtual Common::String getDefaultConfigFileName();
 
 	// Logging
-	virtual Common::WriteStream *createLogFile();
+	virtual Common::WriteStream *createLogFile() { return 0; }
 	Backends::Log::Log *_logger;
 
 #ifdef USE_OPENGL

Modified: scummvm/trunk/backends/platform/sdl/win32/win32.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/win32/win32.cpp	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/win32/win32.cpp	2010-11-29 18:30:23 UTC (rev 54581)
@@ -134,4 +134,38 @@
 	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

Modified: scummvm/trunk/backends/platform/sdl/win32/win32.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/win32/win32.h	2010-11-29 18:22:31 UTC (rev 54580)
+++ scummvm/trunk/backends/platform/sdl/win32/win32.h	2010-11-29 18:30:23 UTC (rev 54581)
@@ -34,6 +34,7 @@
 
 protected:
 	virtual Common::String getDefaultConfigFileName();
+	virtual Common::WriteStream *createLogFile();
 };
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list