aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2008-10-16 17:18:15 +0000
committerMax Horn2008-10-16 17:18:15 +0000
commit36311eefb44a43221665bf6d5d11a4d6fd9f330f (patch)
tree0bc717c6fb5709a0aefe415506877e89b82d2e1d
parent0cd49391103a4d7ea33c2a8d61f5c93ab3af0155 (diff)
downloadscummvm-rg350-36311eefb44a43221665bf6d5d11a4d6fd9f330f.tar.gz
scummvm-rg350-36311eefb44a43221665bf6d5d11a4d6fd9f330f.tar.bz2
scummvm-rg350-36311eefb44a43221665bf6d5d11a4d6fd9f330f.zip
OSYSTEM: Pushed out some port specific code from common/system.cpp to the respective ports
svn-id: r34812
-rw-r--r--backends/platform/PalmOS/Src/be_base.cpp16
-rw-r--r--backends/platform/PalmOS/Src/be_base.h3
-rw-r--r--backends/platform/iphone/osys_iphone.cpp10
-rw-r--r--backends/platform/iphone/osys_iphone.h3
-rw-r--r--backends/platform/ps2/systemps2.cpp15
-rw-r--r--backends/platform/ps2/systemps2.h3
-rw-r--r--backends/platform/psp/osys_psp.cpp11
-rw-r--r--backends/platform/psp/osys_psp.h2
-rw-r--r--common/system.cpp37
9 files changed, 62 insertions, 38 deletions
diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp
index 32e68bde9f..9e1fdf39d1 100644
--- a/backends/platform/PalmOS/Src/be_base.cpp
+++ b/backends/platform/PalmOS/Src/be_base.cpp
@@ -171,10 +171,22 @@ Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
return _saveMgr;
}
-Audio::Mixer * OSystem_PalmBase::getMixer() {
+Audio::Mixer *OSystem_PalmBase::getMixer() {
return _mixerMgr;
}
-Common::TimerManager * OSystem_PalmBase::getTimerManager() {
+Common::TimerManager *OSystem_PalmBase::getTimerManager() {
return _timerMgr;
}
+
+#define PALMOS_CONFIG_FILE "/PALM/Programs/ScummVM/scummvm.ini"
+
+Common::SeekableReadStream *OSystem_PalmBase::openConfigFileForReading() {
+ Common::FSNode file(PALMOS_CONFIG_FILE);
+ return file.openForReading();
+}
+
+Common::WriteStream *OSystem_PalmBase::openConfigFileForWriting() {
+ Common::FSNode file(PALMOS_CONFIG_FILE);
+ return file.openForWriting();
+}
diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h
index 582aae5d7a..8c08c0a2ff 100644
--- a/backends/platform/PalmOS/Src/be_base.h
+++ b/backends/platform/PalmOS/Src/be_base.h
@@ -257,6 +257,9 @@ public:
Common::SaveFileManager *getSavefileManager();
Common::TimerManager *getTimerManager();
+
+ virtual Common::SeekableReadStream *openConfigFileForReading();
+ virtual Common::WriteStream *openConfigFileForWriting();
};
#endif
diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp
index 521e91a87e..6ca5a52928 100644
--- a/backends/platform/iphone/osys_iphone.cpp
+++ b/backends/platform/iphone/osys_iphone.cpp
@@ -1312,8 +1312,14 @@ OSystem *OSystem_IPHONE_create() {
return new OSystem_IPHONE();
}
-const char* OSystem_IPHONE::getConfigPath() {
- return SCUMMVM_PREFS_PATH;
+Common::SeekableReadStream *OSystem_IPHONE::openConfigFileForReading() {
+ Common::FSNode file(SCUMMVM_PREFS_PATH);
+ return file.openForReading();
+}
+
+Common::WriteStream *OSystem_IPHONE::openConfigFileForWriting() {
+ Common::FSNode file(SCUMMVM_PREFS_PATH);
+ return file.openForWriting();
}
void iphone_main(int argc, char *argv[]) {
diff --git a/backends/platform/iphone/osys_iphone.h b/backends/platform/iphone/osys_iphone.h
index a9a3ddad65..c743039860 100644
--- a/backends/platform/iphone/osys_iphone.h
+++ b/backends/platform/iphone/osys_iphone.h
@@ -177,7 +177,8 @@ public:
void startSoundsystem();
void stopSoundsystem();
- static const char* getConfigPath();
+ virtual Common::SeekableReadStream *openConfigFileForReading();
+ virtual Common::WriteStream *openConfigFileForWriting();
protected:
inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h);
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index d4dd9aedcf..85eb303e86 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -770,6 +770,7 @@ void OSystem_PS2::quit(void) {
}
void OSystem_PS2::makeConfigPath(char *dest) {
+ // FIXME: Maybe merge this method into openConfigFileForReading/openConfigFileForWriting ?
FILE *handle;
strcpy(dest, "cdfs:/ScummVM.ini");
handle = ps2_fopen(dest, "r");
@@ -783,6 +784,20 @@ void OSystem_PS2::makeConfigPath(char *dest) {
strcpy(dest, "mc0:ScummVM/scummvm.ini");
}
+Common::SeekableReadStream *OSystem_PS2::openConfigFileForReading() {
+ char configFile[MAXPATHLEN];
+ makeConfigPath(configFile);
+ Common::FSNode file(configFile);
+ return file.openForReading();
+}
+
+Common::WriteStream *OSystem_PS2::openConfigFileForWriting() {
+ char configFile[MAXPATHLEN];
+ makeConfigPath(configFile);
+ Common::FSNode file(configFile);
+ return file.openForWriting();
+}
+
bool OSystem_PS2::runningFromHost(void) {
return (_bootDevice == HOST);
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index 08975ab2c8..9539baf4f5 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -107,6 +107,9 @@ public:
virtual void quit();
+ virtual Common::SeekableReadStream *openConfigFileForReading();
+ virtual Common::WriteStream *openConfigFileForWriting();
+
virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 69be0abcb2..cf65ef13c9 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -677,3 +677,14 @@ void OSystem_PSP::setWindowCaption(const char *caption) {
void OSystem_PSP::displayMessageOnOSD(const char *msg) {
}
+#define PSP_CONFIG_FILE "ms0:/scummvm.ini"
+
+Common::SeekableReadStream *OSystem_PSP::openConfigFileForReading() {
+ Common::FSNode file(PSP_CONFIG_FILE);
+ return file.openForReading();
+}
+
+Common::WriteStream *OSystem_PSP::openConfigFileForWriting() {
+ Common::FSNode file(PSP_CONFIG_FILE);
+ return file.openForWriting();
+}
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index dca6ccb036..e231a08d24 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -145,5 +145,7 @@ public:
virtual void displayMessageOnOSD(const char *msg);
+ virtual Common::SeekableReadStream *openConfigFileForReading();
+ virtual Common::WriteStream *openConfigFileForWriting();
};
diff --git a/common/system.cpp b/common/system.cpp
index 0e29dded38..a07ffba6d6 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -122,48 +122,19 @@ void OSystem::clearScreen() {
/*
-FIXME: The config file loading code below needs to be cleaned up.
- Port specific variants should be pushed into the respective ports.
-
- Ideally, the default OSystem::openConfigFileForReading/Writing methods
- should be removed completely.
+ FIXME: Maybe we should push the default config file loading/saving code below
+ out to all the backends?
*/
-#ifdef __PLAYSTATION2__
-#include "backends/platform/ps2/systemps2.h"
-#endif
-
-#ifdef IPHONE
-#include "backends/platform/iphone/osys_iphone.h"
-#endif
-
-
#if defined(UNIX)
#define DEFAULT_CONFIG_FILE ".scummvmrc"
#else
#define DEFAULT_CONFIG_FILE "scummvm.ini"
#endif
-static Common::String getDefaultConfigFileName() {
- char configFile[MAXPATHLEN];
-#if defined(PALMOS_MODE)
- strcpy(configFile,"/PALM/Programs/ScummVM/" DEFAULT_CONFIG_FILE);
-#elif defined(IPHONE)
- strcpy(configFile, OSystem_IPHONE::getConfigPath());
-#elif defined(__PLAYSTATION2__)
- ((OSystem_PS2*)g_system)->makeConfigPath(configFile);
-#elif defined(__PSP__)
- strcpy(configFile, "ms0:/" DEFAULT_CONFIG_FILE);
-#else
- strcpy(configFile, DEFAULT_CONFIG_FILE);
-#endif
-
- return configFile;
-}
-
Common::SeekableReadStream *OSystem::openConfigFileForReading() {
- Common::FSNode file(getDefaultConfigFileName());
+ Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.openForReading();
}
@@ -171,7 +142,7 @@ Common::WriteStream *OSystem::openConfigFileForWriting() {
#ifdef __DC__
return 0;
#else
- Common::FSNode file(getDefaultConfigFileName());
+ Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.openForWriting();
#endif
}