aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorMax Horn2011-06-03 12:08:37 +0200
committerMax Horn2011-06-03 13:36:04 +0200
commit279a5b4f32ebd9ed9df4390995e4bfc4da38f1df (patch)
tree49f607b86dbc35cb94365e3bb8ad475ddfdc6be1 /backends/platform
parentae4b298bbb41a37a73b0b10eb021d9730bd8b839 (diff)
downloadscummvm-rg350-279a5b4f32ebd9ed9df4390995e4bfc4da38f1df.tar.gz
scummvm-rg350-279a5b4f32ebd9ed9df4390995e4bfc4da38f1df.tar.bz2
scummvm-rg350-279a5b4f32ebd9ed9df4390995e4bfc4da38f1df.zip
BACKENDS: Add OSystem::displayLogFile interface + OSX implementation
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/sdl/macosx/macosx.cpp24
-rw-r--r--backends/platform/sdl/macosx/macosx.h4
-rw-r--r--backends/platform/sdl/posix/posix.cpp9
-rw-r--r--backends/platform/sdl/posix/posix.h17
4 files changed, 51 insertions, 3 deletions
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 0ef16d9a6e..0624de2146 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -34,6 +34,7 @@
#include "common/fs.h"
#include "CoreFoundation/CoreFoundation.h"
+#include "CoreServices/CoreServices.h"
OSystem_MacOSX::OSystem_MacOSX()
:
@@ -75,4 +76,27 @@ void OSystem_MacOSX::setupIcon() {
// Don't set icon on OS X, as we use a nicer external icon there.
}
+bool OSystem_MacOSX::hasFeature(Feature f) {
+ if (f == kFeatureDisplayLogFile)
+ return true;
+ return OSystem_POSIX::hasFeature(f);
+}
+
+bool OSystem_MacOSX::displayLogFile() {
+ // Use LaunchServices to open the log file, if possible.
+
+ if (_logFilePath.empty())
+ return false;
+
+ FSRef ref;
+ OSStatus err;
+
+ err = FSPathMakeRef((const UInt8 *)_logFilePath.c_str(), &ref, NULL);
+ if (err == noErr) {
+ err = LSOpenFSRef(&ref, NULL);
+ }
+
+ return err != noErr;
+}
+
#endif
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 6d78427522..86c70297ec 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -29,6 +29,10 @@ class OSystem_MacOSX : public OSystem_POSIX {
public:
OSystem_MacOSX();
+ virtual bool hasFeature(Feature f);
+
+ virtual bool displayLogFile();
+
virtual void initBackend();
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
virtual void setupIcon();
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 21ad7b9e35..f30b953a8f 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -73,6 +73,10 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() {
}
Common::WriteStream *OSystem_POSIX::createLogFile() {
+ // Start out by resetting _logFilePath, so that in case
+ // of a failure, we know that no log file is open.
+ _logFilePath.clear();
+
const char *home = getenv("HOME");
if (home == NULL)
return 0;
@@ -128,7 +132,10 @@ Common::WriteStream *OSystem_POSIX::createLogFile() {
logFile += "/scummvm.log";
Common::FSNode file(logFile);
- return file.createWriteStream();
+ Common::WriteStream *stream = file.createWriteStream();
+ if (stream)
+ _logFilePath = logFile;
+ return stream;
}
#endif
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index 0a4f38e2c4..6246e6f59d 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -35,10 +35,23 @@ public:
virtual void initBackend();
protected:
- // Base string for creating the default path and filename
- // for the configuration file
+ /**
+ * Base string for creating the default path and filename for the
+ * configuration file. This allows the Mac OS X subclass to override
+ * the config file path and name.
+ */
Common::String _baseConfigName;
+ /**
+ * 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();