ALL: sync with scummvm
This commit is contained in:
parent
0c962164d4
commit
7329a5d164
126 changed files with 2443 additions and 1679 deletions
|
@ -20,12 +20,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_getenv
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_exit
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h
|
||||
|
||||
#include "common/scummsys.h"
|
||||
|
||||
#ifdef UNIX
|
||||
#ifdef POSIX
|
||||
|
||||
#include "backends/platform/sdl/posix/posix.h"
|
||||
#include "backends/saves/posix/posix-saves.h"
|
||||
|
@ -33,6 +36,8 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName)
|
||||
|
@ -57,10 +62,16 @@ void OSystem_POSIX::initBackend() {
|
|||
OSystem_SDL::initBackend();
|
||||
}
|
||||
|
||||
bool OSystem_POSIX::hasFeature(Feature f) {
|
||||
if (f == kFeatureDisplayLogFile)
|
||||
return true;
|
||||
return OSystem_SDL::hasFeature(f);
|
||||
}
|
||||
|
||||
Common::String OSystem_POSIX::getDefaultConfigFileName() {
|
||||
char configFile[MAXPATHLEN];
|
||||
|
||||
// On UNIX type systems, by default we store the config file inside
|
||||
// On POSIX type systems, by default we store the config file inside
|
||||
// to the HOME directory of the user.
|
||||
const char *home = getenv("HOME");
|
||||
if (home != NULL && strlen(home) < MAXPATHLEN)
|
||||
|
@ -72,6 +83,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;
|
||||
|
@ -82,6 +97,9 @@ Common::WriteStream *OSystem_POSIX::createLogFile() {
|
|||
#else
|
||||
logFile += "/.residual";
|
||||
#endif
|
||||
#ifdef SAMSUNGTV
|
||||
logFile = "/mtd_ram";
|
||||
#endif
|
||||
|
||||
struct stat sb;
|
||||
|
||||
|
@ -124,7 +142,62 @@ Common::WriteStream *OSystem_POSIX::createLogFile() {
|
|||
logFile += "/residual.log";
|
||||
|
||||
Common::FSNode file(logFile);
|
||||
return file.createWriteStream();
|
||||
Common::WriteStream *stream = file.createWriteStream();
|
||||
if (stream)
|
||||
_logFilePath = logFile;
|
||||
return stream;
|
||||
}
|
||||
|
||||
bool OSystem_POSIX::displayLogFile() {
|
||||
if (_logFilePath.empty())
|
||||
return false;
|
||||
|
||||
// FIXME: This may not work perfectly when in fullscreen mode.
|
||||
// On my system it drops from fullscreen without ScummVM noticing,
|
||||
// so the next Alt-Enter does nothing, going from windowed to windowed.
|
||||
// (wjp, 20110604)
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
// failed to fork
|
||||
return false;
|
||||
} else if (pid == 0) {
|
||||
|
||||
// Try xdg-open first
|
||||
execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char*)0);
|
||||
|
||||
// If we're here, that clearly failed.
|
||||
|
||||
// TODO: We may also want to try detecting the case where
|
||||
// xdg-open is successfully executed but returns an error code.
|
||||
|
||||
// Try xterm+less next
|
||||
|
||||
execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char*)0);
|
||||
|
||||
// TODO: If less does not exist we could fall back to 'more'.
|
||||
// However, we'll have to use 'xterm -hold' for that to prevent the
|
||||
// terminal from closing immediately (for short log files) or
|
||||
// unexpectedly.
|
||||
|
||||
exit(127);
|
||||
}
|
||||
|
||||
int status;
|
||||
// Wait for viewer to close.
|
||||
// (But note that xdg-open may have spawned a viewer in the background.)
|
||||
|
||||
// FIXME: We probably want the viewer to always open in the background.
|
||||
// This may require installing a SIGCHLD handler.
|
||||
pid = waitpid(pid, &status, 0);
|
||||
|
||||
if (pid < 0) {
|
||||
// Probably nothing sensible to do in this error situation
|
||||
return false;
|
||||
}
|
||||
|
||||
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue