aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/base-backend.cpp35
-rw-r--r--backends/base-backend.h6
-rw-r--r--backends/modular-backend.h2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp12
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h3
-rw-r--r--backends/platform/iphone/osys_main.cpp23
-rw-r--r--backends/platform/iphone/osys_main.h3
-rw-r--r--backends/platform/null/null.cpp15
-rw-r--r--backends/platform/ps2/systemps2.cpp10
-rw-r--r--backends/platform/ps2/systemps2.h3
-rw-r--r--backends/platform/psp/osys_psp.cpp12
-rw-r--r--backends/platform/psp/osys_psp.h4
-rw-r--r--backends/platform/sdl/sdl.cpp14
-rw-r--r--backends/platform/sdl/sdl.h8
-rw-r--r--common/system.cpp19
-rw-r--r--common/system.h11
16 files changed, 43 insertions, 137 deletions
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index ca46129aa6..ecd22d58bc 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -52,40 +52,5 @@ void BaseBackend::fillScreen(uint32 col) {
unlockScreen();
}
-
-/*
- FIXME: Maybe we should push the default config file loading/saving code below
- out to all the backends?
-*/
-
-
-#if defined(POSIX)
-#define DEFAULT_CONFIG_FILE ".scummvmrc"
-#endif
-
-#if !defined(POSIX)
-#define DEFAULT_CONFIG_FILE "scummvm.ini"
-#endif
-
-BaseBackend::BaseBackend() {
-}
-
-BaseBackend::~BaseBackend() {
-}
-
-Common::SeekableReadStream *BaseBackend::createConfigReadStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *BaseBackend::createConfigWriteStream() {
-#ifdef __DC__
- return 0;
-#else
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createWriteStream();
-#endif
-}
-
void BaseBackend::resetGraphicsScale() {
}
diff --git a/backends/base-backend.h b/backends/base-backend.h
index b6ac8c4ee6..c71b481aa2 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -28,16 +28,10 @@
class BaseBackend : public OSystem, Common::EventSource {
public:
- BaseBackend();
- ~BaseBackend();
-
virtual Common::EventManager *getEventManager();
virtual void displayMessageOnOSD(const char *msg);
virtual void fillScreen(uint32 col);
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
-
virtual void resetGraphicsScale();
};
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 8dbfd1c8af..a978f2062c 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -39,8 +39,6 @@ class MutexManager;
* A backend derivated from this class, will need to implement
* these functions on its own:
* OSystem::pollEvent()
- * OSystem::createConfigReadStream()
- * OSystem::createConfigWriteStream()
* OSystem::getMillis()
* OSystem::delayMillis()
* OSystem::getTimeAndDate()
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index e65402c604..90af02f43b 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -853,16 +853,8 @@ void OSystem_DS::setCharactersEntered(int count) {
DS::setCharactersEntered(count);
}
-Common::SeekableReadStream *OSystem_DS::createConfigReadStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
-// consolePrintf("R %s", DEFAULT_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_DS::createConfigWriteStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
-// consolePrintf("W %s", DEFAULT_CONFIG_FILE);
- return file.createWriteStream();
+Common::String OSystem_DS::getDefaultConfigFileName() {
+ return DEFAULT_CONFIG_FILE;
}
u16 OSystem_DS::applyGamma(u16 color) {
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index ecb8011060..d3e7fce1a1 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -176,8 +176,7 @@ public:
void refreshCursor();
- Common::WriteStream *createConfigWriteStream();
- Common::SeekableReadStream *createConfigReadStream();
+ virtual Common::String getDefaultConfigFileName();
u16 applyGamma(u16 color);
void setGammaValue(int gamma) { _gammaValue = gamma; }
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 75156b9544..d0a10d9edc 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -229,29 +229,16 @@ OSystem *OSystem_IPHONE_create() {
return new OSystem_IPHONE();
}
-Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() {
+CCommon::String OSystem_IPHONE::getDefaultConfigFileName() {
#ifdef IPHONE_OFFICIAL
- char buf[256];
- strncpy(buf, iPhone_getDocumentsDir(), 256);
- strncat(buf, "/Preferences", 256 - strlen(buf) );
- Common::FSNode file(buf);
+ Common::String path = iPhone_getDocumentsDir();
+ path += "/Preferences";
+ return path;
#else
- Common::FSNode file(SCUMMVM_PREFS_PATH);
+ return SCUMMVM_PREFS_PATH;
#endif
- return file.createReadStream();
}
-Common::WriteStream *OSystem_IPHONE::createConfigWriteStream() {
-#ifdef IPHONE_OFFICIAL
- char buf[256];
- strncpy(buf, iPhone_getDocumentsDir(), 256);
- strncat(buf, "/Preferences", 256 - strlen(buf) );
- Common::FSNode file(buf);
-#else
- Common::FSNode file(SCUMMVM_PREFS_PATH);
-#endif
- return file.createWriteStream();
-}
void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
// Get URL of the Resource directory of the .app bundle
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 1ff87967a1..36b4b7356b 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -184,8 +184,7 @@ public:
void startSoundsystem();
void stopSoundsystem();
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
+ virtual Common::String getDefaultConfigFileName();
protected:
void internUpdateScreen();
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 207453ad0d..e46ff9c4db 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -52,9 +52,6 @@ public:
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &t) const {}
-
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
};
OSystem_NULL::OSystem_NULL() {
@@ -100,18 +97,6 @@ uint32 OSystem_NULL::getMillis() {
void OSystem_NULL::delayMillis(uint msecs) {
}
-#define DEFAULT_CONFIG_FILE "scummvm.ini"
-
-Common::SeekableReadStream *OSystem_NULL::createConfigReadStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_NULL::createConfigWriteStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createWriteStream();
-}
-
OSystem *OSystem_NULL_create() {
return new OSystem_NULL();
}
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index aa1a9ade9f..9dc3f639d7 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -983,12 +983,6 @@ void OSystem_PS2::makeConfigPath() {
_configFile = strdup(path);
}
-Common::SeekableReadStream *OSystem_PS2::createConfigReadStream() {
- Common::FSNode file(_configFile);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_PS2::createConfigWriteStream() {
- Common::FSNode file(_configFile);
- return file.createWriteStream();
+Common::String OSystem_PS2::getDefaultConfigFileName() {
+ return _configFile
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index b21a56c184..bbb82940c8 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -112,8 +112,7 @@ public:
virtual void quit();
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
+ virtual Common::String getDefaultConfigFileName();
virtual Graphics::PixelFormat getOverlayFormat() const;
virtual Common::SaveFileManager *getSavefileManager();
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 16688698e2..4408cbf481 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -439,14 +439,6 @@ void OSystem_PSP::getTimeAndDate(TimeDate &td) const {
td.tm_year = t.tm_year;
}
-#define PSP_CONFIG_FILE "ms0:/scummvm.ini"
-
-Common::SeekableReadStream *OSystem_PSP::createConfigReadStream() {
- Common::FSNode file(PSP_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_PSP::createConfigWriteStream() {
- Common::FSNode file(PSP_CONFIG_FILE);
- return file.createWriteStream();
+Common::String OSystem_PSP::getDefaultConfigFileName() {
+ return "ms0:/scummvm.ini";
}
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 8b7c960125..4f1d6f2fa7 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -156,9 +156,7 @@ public:
void logMessage(LogMessageType::Type type, const char *message);
- Common::SeekableReadStream *createConfigReadStream();
- Common::WriteStream *createConfigWriteStream();
-
+ virtual Common::String getDefaultConfigFileName();
};
#endif /* OSYS_PSP_H */
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 527520a7ea..564dd83fd8 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -246,20 +246,6 @@ void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority)
}
-Common::String OSystem_SDL::getDefaultConfigFileName() {
- return "scummvm.ini";
-}
-
-Common::SeekableReadStream *OSystem_SDL::createConfigReadStream() {
- Common::FSNode file(getDefaultConfigFileName());
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_SDL::createConfigWriteStream() {
- Common::FSNode file(getDefaultConfigFileName());
- return file.createWriteStream();
-}
-
void OSystem_SDL::setWindowCaption(const char *caption) {
Common::String cap;
byte c;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index e9e9bc5696..917fac5558 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -65,8 +65,6 @@ public:
virtual void setWindowCaption(const char *caption);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &td) const;
@@ -103,12 +101,6 @@ protected:
*/
virtual void setupIcon();
- /**
- * Get the file path where the user configuration
- * of ScummVM will be saved.
- */
- virtual Common::String getDefaultConfigFileName();
-
// Logging
virtual Common::WriteStream *createLogFile() { return 0; }
Backends::Log::Log *_logger;
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.