aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/sdl/macosx/macosx.h4
-rw-r--r--backends/platform/sdl/posix/posix.cpp51
-rw-r--r--backends/platform/sdl/posix/posix.h2
-rw-r--r--backends/platform/sdl/sdl.cpp94
-rw-r--r--backends/platform/sdl/sdl.h2
-rw-r--r--backends/platform/sdl/win32/win32.cpp34
-rw-r--r--backends/platform/sdl/win32/win32.h1
7 files changed, 93 insertions, 95 deletions
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 3c583a0ac0..7402618b0e 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -36,6 +36,10 @@ public:
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
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 6f91188184..65a3f52f6f 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -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 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() {
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
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index 13f9304f1e..a0a0b89c40 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -43,6 +43,8 @@ protected:
Common::String _baseConfigName;
virtual Common::String getDefaultConfigFileName();
+
+ virtual Common::WriteStream *createLogFile();
};
#endif
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 <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 @@ 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;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 72bbda0600..dac1f18a88 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -113,7 +113,7 @@ protected:
virtual Common::String getDefaultConfigFileName();
// Logging
- virtual Common::WriteStream *createLogFile();
+ virtual Common::WriteStream *createLogFile() { return 0; }
Backends::Log::Log *_logger;
#ifdef USE_OPENGL
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