aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2011-06-06 15:30:21 +0200
committerMax Horn2011-06-06 15:30:21 +0200
commitc8475224221ed14590ad08929a1cadd6e8e3cc4e (patch)
tree54c3bd35cd63e81246b10ff9213217335f928118 /common
parentafb06b51cceb96cf3ac2baae1f562c673114d108 (diff)
downloadscummvm-rg350-c8475224221ed14590ad08929a1cadd6e8e3cc4e.tar.gz
scummvm-rg350-c8475224221ed14590ad08929a1cadd6e8e3cc4e.tar.bz2
scummvm-rg350-c8475224221ed14590ad08929a1cadd6e8e3cc4e.zip
BACKENDS: Add OSystem::getDefaultConfigFileName
This is used to provide default implementations for createConfigWriteStream and createConfigReadStream, which can be used by most backends. Note that backends can still override createConfigRead/WriteStream; this could be useful if settings on some port are not stored in a regular file (think 'Windows registry', for a hypothetical example).
Diffstat (limited to 'common')
-rw-r--r--common/system.cpp19
-rw-r--r--common/system.h11
2 files changed, 28 insertions, 2 deletions
diff --git a/common/system.cpp b/common/system.cpp
index dcdc38c0db..307079d112 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -26,6 +26,7 @@
#include "common/system.h"
#include "common/str.h"
+#include "common/fs.h"
#include "common/textconsole.h"
#include "backends/audiocd/default/default-audiocd.h"
@@ -90,6 +91,24 @@ void OSystem::fatalError() {
exit(1);
}
+Common::SeekableReadStream *OSystem::createConfigReadStream() {
+ Common::FSNode file(getDefaultConfigFileName());
+ return file.createReadStream();
+}
+
+Common::WriteStream *OSystem::createConfigWriteStream() {
+#ifdef __DC__
+ return 0;
+#else
+ Common::FSNode file(getDefaultConfigFileName());
+ return file.createWriteStream();
+#endif
+}
+
+Common::String OSystem::getDefaultConfigFileName() {
+ return "scummvm.ini";
+}
+
void OSystem::logMessage(LogMessageType::Type type, const char *message) {
FILE *output = 0;
diff --git a/common/system.h b/common/system.h
index 4b85f143b7..85771cf982 100644
--- a/common/system.h
+++ b/common/system.h
@@ -1015,7 +1015,7 @@ public:
* ReadStream instance. It is the callers responsiblity to delete
* the stream after use.
*/
- virtual Common::SeekableReadStream *createConfigReadStream() = 0;
+ virtual Common::SeekableReadStream *createConfigReadStream();
/**
* Open the default config file for writing, by returning a suitable
@@ -1024,7 +1024,14 @@ public:
*
* May return 0 to indicate that writing to config file is not possible.
*/
- virtual Common::WriteStream *createConfigWriteStream() = 0;
+ virtual Common::WriteStream *createConfigWriteStream();
+
+ /**
+ * Get the default file name (or even path) where the user configuration
+ * of ScummVM will be saved.
+ * Note that not all ports may use this.
+ */
+ virtual Common::String getDefaultConfigFileName();
/**
* Logs a given message.