aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl/win32/win32.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-06-13 13:12:23 -0400
committerMatthew Hoops2011-06-13 13:12:23 -0400
commitd355475a0416897ed254fa85f4d63d0f75d9c7ea (patch)
tree184892480ebb704b28163c51999e50c414e85f8a /backends/platform/sdl/win32/win32.cpp
parent224c71e483e09931ba386555ff3b436b9defe63d (diff)
parentbfa26ffc44f80e4eb3d8590f5f865cda6a5188b7 (diff)
downloadscummvm-rg350-d355475a0416897ed254fa85f4d63d0f75d9c7ea.tar.gz
scummvm-rg350-d355475a0416897ed254fa85f4d63d0f75d9c7ea.tar.bz2
scummvm-rg350-d355475a0416897ed254fa85f4d63d0f75d9c7ea.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'backends/platform/sdl/win32/win32.cpp')
-rw-r--r--backends/platform/sdl/win32/win32.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 93b76f4188..5b14be4417 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -32,6 +32,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one...
+#include <shellapi.h>
#include "backends/platform/sdl/win32/win32.h"
#include "backends/fs/windows/windows-fs-factory.h"
@@ -87,6 +88,49 @@ void OSystem_Win32::init() {
OSystem_SDL::init();
}
+
+bool OSystem_Win32::hasFeature(Feature f) {
+ if (f == kFeatureDisplayLogFile)
+ return true;
+
+ return OSystem_SDL::hasFeature(f);
+}
+
+bool OSystem_Win32::displayLogFile() {
+ if (_logFilePath.empty())
+ return false;
+
+ // Try opening the log file with the default text editor
+ // log files should be registered as "txtfile" by default and thus open in the default text editor
+ HINSTANCE shellExec = ShellExecute(NULL, NULL, _logFilePath.c_str(), NULL, NULL, SW_SHOWNORMAL);
+ if ((intptr_t)shellExec > 32)
+ return true;
+
+ // ShellExecute with the default verb failed, try the "Open with..." dialog
+ PROCESS_INFORMATION processInformation;
+ STARTUPINFO startupInfo;
+ memset(&processInformation, 0, sizeof(processInformation));
+ memset(&startupInfo, 0, sizeof(startupInfo));
+ startupInfo.cb = sizeof(startupInfo);
+
+ char cmdLine[MAX_PATH * 2]; // CreateProcess may change the contents of cmdLine
+ sprintf(cmdLine, "rundll32 shell32.dll,OpenAs_RunDLL %s", _logFilePath.c_str());
+ BOOL result = CreateProcess(NULL,
+ cmdLine,
+ NULL,
+ NULL,
+ FALSE,
+ NORMAL_PRIORITY_CLASS,
+ NULL,
+ NULL,
+ &startupInfo,
+ &processInformation);
+ if (result)
+ return true;
+
+ return false;
+}
+
Common::String OSystem_Win32::getDefaultConfigFileName() {
char configFile[MAXPATHLEN];
@@ -136,6 +180,10 @@ Common::String OSystem_Win32::getDefaultConfigFileName() {
}
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();
+
char logFile[MAXPATHLEN];
OSVERSIONINFO win32OsVersion;
@@ -163,7 +211,11 @@ Common::WriteStream *OSystem_Win32::createLogFile() {
strcat(logFile, "\\scummvm.log");
Common::FSNode file(logFile);
- return file.createWriteStream();
+ Common::WriteStream *stream = file.createWriteStream();
+ if (stream)
+ _logFilePath= logFile;
+
+ return stream;
} else {
return 0;
}