From c8475224221ed14590ad08929a1cadd6e8e3cc4e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 6 Jun 2011 15:30:21 +0200 Subject: 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). --- backends/platform/ds/arm9/source/osystem_ds.cpp | 12 ++---------- backends/platform/ds/arm9/source/osystem_ds.h | 3 +-- backends/platform/iphone/osys_main.cpp | 23 +++++------------------ backends/platform/iphone/osys_main.h | 3 +-- backends/platform/null/null.cpp | 15 --------------- backends/platform/ps2/systemps2.cpp | 10 ++-------- backends/platform/ps2/systemps2.h | 3 +-- backends/platform/psp/osys_psp.cpp | 12 ++---------- backends/platform/psp/osys_psp.h | 4 +--- backends/platform/sdl/sdl.cpp | 14 -------------- backends/platform/sdl/sdl.h | 8 -------- 11 files changed, 15 insertions(+), 92 deletions(-) (limited to 'backends/platform') 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; -- cgit v1.2.3