aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/samsungtv/samsungtv.cpp8
-rw-r--r--backends/platform/samsungtv/samsungtv.h3
-rw-r--r--backends/platform/sdl/macosx/macosx.cpp14
-rw-r--r--backends/platform/sdl/macosx/macosx.h2
-rw-r--r--backends/platform/sdl/posix/posix.cpp36
-rw-r--r--backends/platform/sdl/posix/posix.h13
-rw-r--r--backends/platform/sdl/ps3/ps3.cpp5
-rw-r--r--backends/platform/sdl/ps3/ps3.h3
-rw-r--r--backends/platform/sdl/psp2/psp2.cpp5
-rw-r--r--backends/platform/sdl/psp2/psp2.h3
-rw-r--r--backends/platform/sdl/riscos/riscos.cpp16
-rw-r--r--backends/platform/sdl/riscos/riscos.h12
-rw-r--r--backends/platform/sdl/sdl.cpp16
-rw-r--r--backends/platform/sdl/sdl.h13
-rw-r--r--backends/platform/sdl/switch/switch.cpp5
-rw-r--r--backends/platform/sdl/switch/switch.h3
-rw-r--r--backends/platform/sdl/win32/win32.cpp31
-rw-r--r--backends/platform/sdl/win32/win32.h12
18 files changed, 86 insertions, 114 deletions
diff --git a/backends/platform/samsungtv/samsungtv.cpp b/backends/platform/samsungtv/samsungtv.cpp
index a766916fab..e72b1ee05d 100644
--- a/backends/platform/samsungtv/samsungtv.cpp
+++ b/backends/platform/samsungtv/samsungtv.cpp
@@ -57,4 +57,12 @@ void OSystem_SDL_SamsungTV::fatalError() {
for (;;) {}
}
+Common::String OSystem_SDL_SamsungTV::getDefaultLogFileName() {
+ if (!Posix::assureDirectoryExists("/mtd_ram", nullptr)) {
+ return Common::String();
+ }
+
+ return "/mtd_ram/scummvm.log";
+}
+
#endif
diff --git a/backends/platform/samsungtv/samsungtv.h b/backends/platform/samsungtv/samsungtv.h
index fdd1015c8a..aad946aa0a 100644
--- a/backends/platform/samsungtv/samsungtv.h
+++ b/backends/platform/samsungtv/samsungtv.h
@@ -34,6 +34,9 @@ public:
virtual void initBackend();
virtual void quit();
virtual void fatalError();
+
+protected:
+ virtual Common::String getDefaultLogFileName();
};
#endif
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index ae9203fd45..3628168e71 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -34,6 +34,7 @@
#include "backends/taskbar/macosx/macosx-taskbar.h"
#include "backends/dialogs/macosx/macosx-dialogs.h"
#include "backends/platform/sdl/macosx/macosx_wrapper.h"
+#include "backends/fs/posix/posix-fs.h"
#include "common/archive.h"
#include "common/config-manager.h"
@@ -198,6 +199,19 @@ Common::String OSystem_MacOSX::getSystemLanguage() const {
#endif // USE_DETECTLANG
}
+Common::String OSystem_MacOSX::getDefaultLogFileName() {
+ const char *prefix = getenv("HOME");
+ if (prefix == nullptr) {
+ return Common::String();
+ }
+
+ if (!Posix::assureDirectoryExists("Library/Logs", prefix)) {
+ return Common::String();
+ }
+
+ return Common::String(prefix) + "/Library/Logs/scummvm.log";
+}
+
Common::String OSystem_MacOSX::getScreenshotsPath() {
Common::String path = ConfMan.get("screenshotpath");
if (path.empty())
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 6f960dbdad..b860b71ad8 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -50,6 +50,8 @@ public:
virtual Common::String getScreenshotsPath();
protected:
+ virtual Common::String getDefaultLogFileName();
+
// Override createAudioCDManager() to get our Mac-specific
// version.
virtual AudioCDManager *createAudioCDManager();
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 227f8ef0b3..b204daa643 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -269,55 +269,29 @@ void OSystem_POSIX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority
OSystem_SDL::addSysArchivesToSearchSet(s, priority);
}
-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 *prefix = nullptr;
+Common::String OSystem_POSIX::getDefaultLogFileName() {
Common::String logFile;
-#ifdef MACOSX
- prefix = getenv("HOME");
- if (prefix == nullptr) {
- return 0;
- }
- logFile = "Library/Logs";
-#elif SAMSUNGTV
- prefix = nullptr;
- logFile = "/mtd_ram";
-#else
// On POSIX systems we follow the XDG Base Directory Specification for
// where to store files. The version we based our code upon can be found
// over here: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
- prefix = getenv("XDG_CACHE_HOME");
+ const char *prefix = getenv("XDG_CACHE_HOME");
if (prefix == nullptr || !*prefix) {
prefix = getenv("HOME");
if (prefix == nullptr) {
- return 0;
+ return Common::String();
}
logFile = ".cache/";
}
logFile += "scummvm/logs";
-#endif
if (!Posix::assureDirectoryExists(logFile, prefix)) {
- return 0;
+ return Common::String();
}
- if (prefix) {
- logFile = Common::String::format("%s/%s", prefix, logFile.c_str());
- }
-
- logFile += "/scummvm.log";
-
- Common::FSNode file(logFile);
- Common::WriteStream *stream = file.createWriteStream();
- if (stream)
- _logFilePath = logFile;
- return stream;
+ return Common::String::format("%s/%s/scummvm.log", prefix, logFile.c_str());
}
bool OSystem_POSIX::displayLogFile() {
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index fd9bbadc9a..5df6738d45 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -52,19 +52,8 @@ protected:
*/
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();
+ virtual Common::String getDefaultLogFileName();
Common::String getXdgUserDir(const char *name);
diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp
index b13088afd3..78b02d7e2e 100644
--- a/backends/platform/sdl/ps3/ps3.cpp
+++ b/backends/platform/sdl/ps3/ps3.cpp
@@ -78,7 +78,6 @@ Common::String OSystem_PS3::getDefaultConfigFileName() {
return PREFIX "/" + _baseConfigName;
}
-Common::WriteStream *OSystem_PS3::createLogFile() {
- Common::FSNode file(PREFIX "/scummvm.log");
- return file.createWriteStream();
+Common::String OSystem_PS3::getDefaultLogFileName() {
+ return PREFIX "/scummvm.log";
}
diff --git a/backends/platform/sdl/ps3/ps3.h b/backends/platform/sdl/ps3/ps3.h
index d812a13548..a0c0d80b0e 100644
--- a/backends/platform/sdl/ps3/ps3.h
+++ b/backends/platform/sdl/ps3/ps3.h
@@ -40,8 +40,7 @@ protected:
Common::String _baseConfigName;
virtual Common::String getDefaultConfigFileName();
-
- virtual Common::WriteStream *createLogFile();
+ virtual Common::String getDefaultLogFileName();
};
#endif
diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp
index 6919343001..5a127b05b3 100644
--- a/backends/platform/sdl/psp2/psp2.cpp
+++ b/backends/platform/sdl/psp2/psp2.cpp
@@ -169,7 +169,6 @@ Common::String OSystem_PSP2::getDefaultConfigFileName() {
return "ux0:data/scummvm/" + _baseConfigName;
}
-Common::WriteStream *OSystem_PSP2::createLogFile() {
- Common::FSNode file("ux0:data/scummvm/scummvm.log");
- return file.createWriteStream();
+Common::String OSystem_PSP2::getDefaultLogFileName() {
+ return "ux0:data/scummvm/scummvm.log";
}
diff --git a/backends/platform/sdl/psp2/psp2.h b/backends/platform/sdl/psp2/psp2.h
index db9140e4c1..a90272ba62 100644
--- a/backends/platform/sdl/psp2/psp2.h
+++ b/backends/platform/sdl/psp2/psp2.h
@@ -47,8 +47,7 @@ protected:
Common::String _baseConfigName;
virtual Common::String getDefaultConfigFileName() override;
-
- virtual Common::WriteStream *createLogFile() override;
+ virtual Common::String getDefaultLogFileName() override;
};
#endif
diff --git a/backends/platform/sdl/riscos/riscos.cpp b/backends/platform/sdl/riscos/riscos.cpp
index 3cd9616585..a0173ed653 100644
--- a/backends/platform/sdl/riscos/riscos.cpp
+++ b/backends/platform/sdl/riscos/riscos.cpp
@@ -119,24 +119,14 @@ Common::String OSystem_RISCOS::getDefaultConfigFileName() {
return "/<Choices$Write>/ScummVM/scummvmrc";
}
-Common::WriteStream *OSystem_RISCOS::createLogFile() {
- // Start out by resetting _logFilePath, so that in case
- // of a failure, we know that no log file is open.
- _logFilePath.clear();
-
+Common::String OSystem_RISCOS::getDefaultLogFileName() {
Common::String logFile = "/<Choices$Write>/ScummVM/Logs";
if (!Riscos::assureDirectoryExists(logFile)) {
- return 0;
+ return Common::String();
}
- logFile += "/scummvm";
-
- Common::FSNode file(logFile);
- Common::WriteStream *stream = file.createWriteStream();
- if (stream)
- _logFilePath = logFile;
- return stream;
+ return logFile + "/scummvm";
}
#endif
diff --git a/backends/platform/sdl/riscos/riscos.h b/backends/platform/sdl/riscos/riscos.h
index 49ac5a2264..7abeb4f8ef 100644
--- a/backends/platform/sdl/riscos/riscos.h
+++ b/backends/platform/sdl/riscos/riscos.h
@@ -37,18 +37,8 @@ public:
virtual void logMessage(LogMessageType::Type type, const char *message);
protected:
- /**
- * 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();
+ virtual Common::String getDefaultLogFileName();
};
#endif
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 57f77fde6d..e4726dcd16 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -406,6 +406,22 @@ void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) {
_logger->print(message);
}
+Common::WriteStream *OSystem_SDL::createLogFile() {
+ // Start out by resetting _logFilePath, so that in case
+ // of a failure, we know that no log file is open.
+ _logFilePath.clear();
+
+ Common::String logFile = getDefaultLogFileName();
+ if (logFile.empty())
+ return nullptr;
+
+ Common::FSNode file(logFile);
+ Common::WriteStream *stream = file.createWriteStream();
+ if (stream)
+ _logFilePath = logFile;
+ return stream;
+}
+
Common::String OSystem_SDL::getSystemLanguage() const {
#if defined(USE_DETECTLANG) && !defined(WIN32)
// Activating current locale settings
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index c746d2d2dd..521e67a915 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -94,6 +94,16 @@ protected:
#endif
/**
+ * 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;
+
+ /**
* Mixer manager that configures and setups SDL for
* the wrapped Audio::Mixer, the true mixer.
*/
@@ -122,7 +132,8 @@ protected:
virtual AudioCDManager *createAudioCDManager();
// Logging
- virtual Common::WriteStream *createLogFile() { return 0; }
+ virtual Common::String getDefaultLogFileName() { return Common::String(); }
+ virtual Common::WriteStream *createLogFile();
Backends::Log::Log *_logger;
#ifdef USE_OPENGL
diff --git a/backends/platform/sdl/switch/switch.cpp b/backends/platform/sdl/switch/switch.cpp
index ef44cb4c4c..85e7b7a458 100644
--- a/backends/platform/sdl/switch/switch.cpp
+++ b/backends/platform/sdl/switch/switch.cpp
@@ -124,7 +124,6 @@ Common::String OSystem_Switch::getDefaultConfigFileName() {
return _baseConfigName;
}
-Common::WriteStream *OSystem_Switch::createLogFile() {
- Common::FSNode file("scummvm.log");
- return file.createWriteStream();
+Common::String OSystem_Switch::getDefaultLogFileName() {
+ return "scummvm.log";
}
diff --git a/backends/platform/sdl/switch/switch.h b/backends/platform/sdl/switch/switch.h
index b9e41e6fe4..61b4f3c058 100644
--- a/backends/platform/sdl/switch/switch.h
+++ b/backends/platform/sdl/switch/switch.h
@@ -44,8 +44,7 @@ protected:
Common::String _baseConfigName;
virtual Common::String getDefaultConfigFileName() override;
-
- virtual Common::WriteStream *createLogFile() override;
+ virtual Common::String getDefaultLogFileName() override;
};
#endif
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index a116e71e76..cb65fa813a 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -278,31 +278,22 @@ Common::String OSystem_Win32::getDefaultConfigFileName() {
return configFile;
}
-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();
-
+Common::String OSystem_Win32::getDefaultLogFileName() {
char logFile[MAXPATHLEN];
// Use the Application Data directory of the user profile.
- if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, logFile) == S_OK) {
- strcat(logFile, "\\ScummVM");
- CreateDirectory(logFile, NULL);
- strcat(logFile, "\\Logs");
- CreateDirectory(logFile, NULL);
- strcat(logFile, "\\scummvm.log");
-
- Common::FSNode file(logFile);
- Common::WriteStream *stream = file.createWriteStream();
- if (stream)
- _logFilePath= logFile;
-
- return stream;
- } else {
+ if (SHGetFolderPathFunc(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, logFile) != S_OK) {
warning("Unable to access application data directory");
- return 0;
+ return Common::String();
}
+
+ strcat(logFile, "\\ScummVM");
+ CreateDirectory(logFile, NULL);
+ strcat(logFile, "\\Logs");
+ CreateDirectory(logFile, NULL);
+ strcat(logFile, "\\scummvm.log");
+
+ return logFile;
}
namespace {
diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h
index 9919495e37..050137ffe1 100644
--- a/backends/platform/sdl/win32/win32.h
+++ b/backends/platform/sdl/win32/win32.h
@@ -46,18 +46,8 @@ public:
virtual Common::String getScreenshotsPath();
protected:
- /**
- * 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();
+ virtual Common::String getDefaultLogFileName();
// Override createAudioCDManager() to get our Mac-specific
// version.