From 4f5479ee744ac6b419cdf7ec1e96fbf7c83d36ef Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 4 Aug 2008 19:38:28 +0000 Subject: Pushed some port specific code from DefaultSaveFileManager out to port specific code in backends/platform/ svn-id: r33621 --- backends/platform/PalmOS/Src/be_base.cpp | 5 ++++- backends/platform/gp2x/gp2x.cpp | 2 +- backends/platform/iphone/osys_iphone.cpp | 6 +----- backends/platform/iphone/osys_iphone.h | 1 - backends/saves/default/default-saves.cpp | 24 ++++++++---------------- backends/saves/default/default-saves.h | 1 + 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp index afb3f15bae..32e68bde9f 100644 --- a/backends/platform/PalmOS/Src/be_base.cpp +++ b/backends/platform/PalmOS/Src/be_base.cpp @@ -30,6 +30,9 @@ #include "backends/timer/default/default-timer.h" #include "sound/mixer.h" +#define DEFAULT_SAVE_PATH "/PALM/Programs/ScummVM/Saved" + + OSystem_PalmBase::OSystem_PalmBase() { _overlayVisible = false; @@ -100,7 +103,7 @@ void OSystem_PalmBase::initBackend() { // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). if (_saveMgr == 0) { - _saveMgr = new DefaultSaveFileManager(); + _saveMgr = new DefaultSaveFileManager(DEFAULT_SAVE_PATH); } // Create and hook up the mixer, if none exists yet (we check for this to diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp index c138f6c54d..e5f062ed35 100644 --- a/backends/platform/gp2x/gp2x.cpp +++ b/backends/platform/gp2x/gp2x.cpp @@ -219,7 +219,7 @@ void OSystem_GP2X::initBackend() { // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). if (_savefile == 0) { - _savefile = new DefaultSaveFileManager(); + _savefile = new DefaultSaveFileManager(savePath); } // Create and hook up the mixer, if none exists yet (we check for this to diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp index fdef911d0a..3d5571cf3a 100644 --- a/backends/platform/iphone/osys_iphone.cpp +++ b/backends/platform/iphone/osys_iphone.cpp @@ -88,7 +88,7 @@ int OSystem_IPHONE::timerHandler(int t) { } void OSystem_IPHONE::initBackend() { - _savefile = new DefaultSaveFileManager(); + _savefile = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH); _timer = new DefaultTimerManager(); gettimeofday(&_startTime, NULL); @@ -1196,10 +1196,6 @@ const char* OSystem_IPHONE::getConfigPath() { return SCUMMVM_PREFS_PATH; } -const char* OSystem_IPHONE::getSavePath() { - return SCUMMVM_SAVE_PATH; -} - void OSystem_IPHONE::migrateApp() { // Migrate to the new 1.1.3 directory structure, if needed. diff --git a/backends/platform/iphone/osys_iphone.h b/backends/platform/iphone/osys_iphone.h index af883a62c9..c058686c8c 100644 --- a/backends/platform/iphone/osys_iphone.h +++ b/backends/platform/iphone/osys_iphone.h @@ -172,7 +172,6 @@ public: static void migrateApp(); static const char* getConfigPath(); - static const char* getSavePath(); protected: inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h); diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index bd72739f44..dc5e8adca7 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -41,10 +41,6 @@ #include #endif -#ifdef IPHONE -#include "backends/platform/iphone/osys_iphone.h" -#endif - #ifdef UNIX #ifdef MACOSX #define DEFAULT_SAVE_PATH "Documents/ScummVM Savegames" @@ -53,8 +49,6 @@ #endif #elif defined(__SYMBIAN32__) #define DEFAULT_SAVE_PATH "Savegames" -#elif defined(PALMOS_MODE) -#define DEFAULT_SAVE_PATH "/PALM/Programs/ScummVM/Saved" #endif DefaultSaveFileManager::DefaultSaveFileManager() { @@ -62,27 +56,25 @@ DefaultSaveFileManager::DefaultSaveFileManager() { // TODO: Remove this code here, and instead leave setting the // default savepath to the ports using this class. #ifdef DEFAULT_SAVE_PATH - char savePath[MAXPATHLEN]; + Common::String savePath; #if defined(UNIX) && !defined(IPHONE) const char *home = getenv("HOME"); if (home && *home && strlen(home) < MAXPATHLEN) { - snprintf(savePath, MAXPATHLEN, "%s/%s", home, DEFAULT_SAVE_PATH); + savePath = home; + savePath += "/" DEFAULT_SAVE_PATH; ConfMan.registerDefault("savepath", savePath); } #elif defined(__SYMBIAN32__) - strcpy(savePath, Symbian::GetExecutablePath()); - strcat(savePath, DEFAULT_SAVE_PATH); - strcat(savePath, "\\"); + savePath = Symbian::GetExecutablePath(); + savePath += DEFAULT_SAVE_PATH "\\"; ConfMan.registerDefault("savepath", savePath); -#elif defined (IPHONE) - ConfMan.registerDefault("savepath", OSystem_IPHONE::getSavePath()); - -#elif defined(PALMOS_MODE) - ConfMan.registerDefault("savepath", DEFAULT_SAVE_PATH); #endif #endif // #ifdef DEFAULT_SAVE_PATH } +DefaultSaveFileManager::DefaultSaveFileManager(const Common::String &defaultSavepath) { + ConfMan.registerDefault("savepath", defaultSavepath); +} Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) { diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index 0e98d0ea9e..97845c4623 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -35,6 +35,7 @@ class DefaultSaveFileManager : public Common::SaveFileManager { public: DefaultSaveFileManager(); + DefaultSaveFileManager(const Common::String &defaultSavepath); virtual Common::StringList listSavefiles(const char *pattern); virtual Common::InSaveFile *openForLoading(const char *filename); -- cgit v1.2.3