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).
This commit is contained in:
parent
afb06b51cc
commit
c847522422
16 changed files with 43 additions and 137 deletions
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -184,8 +184,7 @@ public:
|
|||
void startSoundsystem();
|
||||
void stopSoundsystem();
|
||||
|
||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
||||
virtual Common::WriteStream *createConfigWriteStream();
|
||||
virtual Common::String getDefaultConfigFileName();
|
||||
|
||||
protected:
|
||||
void internUpdateScreen();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue