diff options
author | Cameron Cawley | 2019-12-07 14:08:33 +0000 |
---|---|---|
committer | Filippos Karapetis | 2019-12-07 21:15:41 +0200 |
commit | aa083256ec05ee43d9f1977ca2178cacdfb25ae3 (patch) | |
tree | eaaf0b2788921203c0d0487bcedf4ceb2d5e54ed /backends | |
parent | c90164f526b506a59092b48bcf78838777b68544 (diff) | |
download | scummvm-rg350-aa083256ec05ee43d9f1977ca2178cacdfb25ae3.tar.gz scummvm-rg350-aa083256ec05ee43d9f1977ca2178cacdfb25ae3.tar.bz2 scummvm-rg350-aa083256ec05ee43d9f1977ca2178cacdfb25ae3.zip |
SDL: Simplify implementations of getDefaultConfigFileName()
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/samsungtv/samsungtv.cpp | 9 | ||||
-rw-r--r-- | backends/platform/samsungtv/samsungtv.h | 3 | ||||
-rw-r--r-- | backends/platform/sdl/macosx/macosx.cpp | 23 | ||||
-rw-r--r-- | backends/platform/sdl/macosx/macosx.h | 2 | ||||
-rw-r--r-- | backends/platform/sdl/posix/posix.cpp | 21 | ||||
-rw-r--r-- | backends/platform/sdl/posix/posix.h | 11 | ||||
-rw-r--r-- | backends/platform/sdl/ps3/ps3.cpp | 6 | ||||
-rw-r--r-- | backends/platform/sdl/ps3/ps3.h | 8 | ||||
-rw-r--r-- | backends/platform/sdl/psp2/psp2.cpp | 6 | ||||
-rw-r--r-- | backends/platform/sdl/psp2/psp2.h | 8 | ||||
-rw-r--r-- | backends/platform/sdl/switch/switch.cpp | 8 | ||||
-rw-r--r-- | backends/platform/sdl/switch/switch.h | 9 |
12 files changed, 33 insertions, 81 deletions
diff --git a/backends/platform/samsungtv/samsungtv.cpp b/backends/platform/samsungtv/samsungtv.cpp index bee71b7ff2..5a103793fa 100644 --- a/backends/platform/samsungtv/samsungtv.cpp +++ b/backends/platform/samsungtv/samsungtv.cpp @@ -31,11 +31,6 @@ #include "backends/fs/posix/posix-fs.h" #include "common/textconsole.h" -OSystem_SDL_SamsungTV::OSystem_SDL_SamsungTV() - : - OSystem_POSIX("/mtd_rwarea/.scummvmrc") { -} - void OSystem_SDL_SamsungTV::initBackend() { // Create the savefile manager if (_savefileManager == 0) { @@ -63,6 +58,10 @@ void OSystem_SDL_SamsungTV::fatalError() { for (;;) {} } +Common::String OSystem_SDL_SamsungTV::getDefaultConfigFileName() { + return "/mtd_rwarea/.scummvmrc"; +} + Common::String OSystem_SDL_SamsungTV::getDefaultLogFileName() { if (!Posix::assureDirectoryExists("/mtd_ram", nullptr)) { return Common::String(); diff --git a/backends/platform/samsungtv/samsungtv.h b/backends/platform/samsungtv/samsungtv.h index aad946aa0a..0b98297d79 100644 --- a/backends/platform/samsungtv/samsungtv.h +++ b/backends/platform/samsungtv/samsungtv.h @@ -29,13 +29,12 @@ class OSystem_SDL_SamsungTV : public OSystem_POSIX { public: - OSystem_SDL_SamsungTV(); - virtual void initBackend(); virtual void quit(); virtual void fatalError(); protected: + virtual Common::String getDefaultConfigFileName(); virtual Common::String getDefaultLogFileName(); }; diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 1c47401c13..1545d9ab61 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -45,11 +45,6 @@ #include "ApplicationServices/ApplicationServices.h" // for LSOpenFSRef #include "CoreFoundation/CoreFoundation.h" // for CF* stuff -OSystem_MacOSX::OSystem_MacOSX() - : - OSystem_POSIX("Library/Preferences/ScummVM Preferences") { -} - OSystem_MacOSX::~OSystem_MacOSX() { releaseMenu(); } @@ -205,6 +200,24 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { #endif // USE_DETECTLANG } +Common::String OSystem_MacOSX::getDefaultConfigFileName() { + const Common::String baseConfigName = "Library/Preferences/ScummVM Preferences"; + + Common::String configFile; + + Common::String prefix = getenv("HOME"); + + if (!prefix.empty() && (prefix.size() + 1 + baseConfigName.size()) < MAXPATHLEN) { + configFile = prefix; + configFile += '/'; + configFile += baseConfigName; + } else { + configFile = baseConfigName; + } + + return configFile; +} + Common::String OSystem_MacOSX::getDefaultLogFileName() { const char *prefix = getenv("HOME"); if (prefix == nullptr) { diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index b860b71ad8..e4b5b2a631 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -27,7 +27,6 @@ class OSystem_MacOSX : public OSystem_POSIX { public: - OSystem_MacOSX(); ~OSystem_MacOSX(); virtual bool hasFeature(Feature f); @@ -50,6 +49,7 @@ public: virtual Common::String getScreenshotsPath(); protected: + virtual Common::String getDefaultConfigFileName(); virtual Common::String getDefaultLogFileName(); // Override createAudioCDManager() to get our Mac-specific diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index b9838498a4..b6afd36ba6 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -60,11 +60,6 @@ #endif extern char **environ; -OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName) - : - _baseConfigName(baseConfigName) { -} - void OSystem_POSIX::init() { // Initialze File System Factory _fsFactory = new POSIXFilesystemFactory(); @@ -108,16 +103,15 @@ bool OSystem_POSIX::hasFeature(Feature f) { } Common::String OSystem_POSIX::getDefaultConfigFileName() { + const Common::String baseConfigName = "scummvm.ini"; + Common::String configFile; Common::String prefix; -#ifdef MACOSX - prefix = getenv("HOME"); -#elif !defined(SAMSUNGTV) - const char *envVar; + // Our old configuration file path for POSIX systems was ~/.scummvmrc. // If that file exists, we still use it. - envVar = getenv("HOME"); + const char *envVar = getenv("HOME"); if (envVar && *envVar) { configFile = envVar; configFile += '/'; @@ -152,14 +146,13 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() { if (!prefix.empty() && Posix::assureDirectoryExists("scummvm", prefix.c_str())) { prefix += "/scummvm"; } -#endif - if (!prefix.empty() && (prefix.size() + 1 + _baseConfigName.size()) < MAXPATHLEN) { + if (!prefix.empty() && (prefix.size() + 1 + baseConfigName.size()) < MAXPATHLEN) { configFile = prefix; configFile += '/'; - configFile += _baseConfigName; + configFile += baseConfigName; } else { - configFile = _baseConfigName; + configFile = baseConfigName; } return configFile; diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index 5df6738d45..41fdc35c99 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -27,10 +27,6 @@ class OSystem_POSIX : public OSystem_SDL { public: - // Let the subclasses be able to change _baseConfigName in the constructor - OSystem_POSIX(Common::String baseConfigName = "scummvm.ini"); - virtual ~OSystem_POSIX() {} - virtual bool hasFeature(Feature f); virtual bool displayLogFile(); @@ -45,13 +41,6 @@ public: Common::String getScreenshotsPath() override; protected: - /** - * Base string for creating the default path and filename for the - * configuration file. This allows the Mac OS X subclass to override - * the config file path and name. - */ - Common::String _baseConfigName; - virtual Common::String getDefaultConfigFileName(); virtual Common::String getDefaultLogFileName(); diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp index 78b02d7e2e..9f77c035a2 100644 --- a/backends/platform/sdl/ps3/ps3.cpp +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -45,10 +45,6 @@ int access(const char *pathname, int mode) { return 0; } -OSystem_PS3::OSystem_PS3(Common::String baseConfigName) - : _baseConfigName(baseConfigName) { -} - void OSystem_PS3::init() { // Initialze File System Factory _fsFactory = new PS3FilesystemFactory(); @@ -75,7 +71,7 @@ void OSystem_PS3::initBackend() { } Common::String OSystem_PS3::getDefaultConfigFileName() { - return PREFIX "/" + _baseConfigName; + return PREFIX "/scummvm.ini"; } Common::String OSystem_PS3::getDefaultLogFileName() { diff --git a/backends/platform/sdl/ps3/ps3.h b/backends/platform/sdl/ps3/ps3.h index a0c0d80b0e..766cf5f2f2 100644 --- a/backends/platform/sdl/ps3/ps3.h +++ b/backends/platform/sdl/ps3/ps3.h @@ -27,18 +27,10 @@ class OSystem_PS3 : public OSystem_SDL { public: - // Let the subclasses be able to change _baseConfigName in the constructor - OSystem_PS3(Common::String baseConfigName = "scummvm.ini"); - virtual ~OSystem_PS3() {} - virtual void init(); virtual void initBackend(); protected: - // Base string for creating the default path and filename - // for the configuration file - Common::String _baseConfigName; - virtual Common::String getDefaultConfigFileName(); virtual Common::String getDefaultLogFileName(); }; diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp index bb26694dfd..f87d8f809f 100644 --- a/backends/platform/sdl/psp2/psp2.cpp +++ b/backends/platform/sdl/psp2/psp2.cpp @@ -49,10 +49,6 @@ int access(const char *pathname, int mode) { return 0; } -OSystem_PSP2::OSystem_PSP2(Common::String baseConfigName) - : _baseConfigName(baseConfigName) { -} - void OSystem_PSP2::init() { #if __PSP2_DEBUG__ @@ -172,7 +168,7 @@ void OSystem_PSP2::logMessage(LogMessageType::Type type, const char *message) { } Common::String OSystem_PSP2::getDefaultConfigFileName() { - return "ux0:data/scummvm/" + _baseConfigName; + return "ux0:data/scummvm/scummvm.ini"; } Common::String OSystem_PSP2::getDefaultLogFileName() { diff --git a/backends/platform/sdl/psp2/psp2.h b/backends/platform/sdl/psp2/psp2.h index a90272ba62..0b3be25950 100644 --- a/backends/platform/sdl/psp2/psp2.h +++ b/backends/platform/sdl/psp2/psp2.h @@ -30,10 +30,6 @@ class OSystem_PSP2 : public OSystem_SDL { public: - // Let the subclasses be able to change _baseConfigName in the constructor - OSystem_PSP2(Common::String baseConfigName = "scummvm.ini"); - virtual ~OSystem_PSP2() {} - virtual void init() override; virtual void initBackend() override; virtual bool hasFeature(Feature f) override; @@ -42,10 +38,6 @@ public: virtual void logMessage(LogMessageType::Type type, const char *message) override; protected: - // Base string for creating the default path and filename - // for the configuration file - Common::String _baseConfigName; - virtual Common::String getDefaultConfigFileName() override; virtual Common::String getDefaultLogFileName() override; }; diff --git a/backends/platform/sdl/switch/switch.cpp b/backends/platform/sdl/switch/switch.cpp index 1a3c573608..120fb955fb 100644 --- a/backends/platform/sdl/switch/switch.cpp +++ b/backends/platform/sdl/switch/switch.cpp @@ -30,10 +30,6 @@ #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.h" -OSystem_Switch::OSystem_Switch(Common::String baseConfigName) - : _baseConfigName(baseConfigName) { -} - void OSystem_Switch::init() { // Initialze File System Factory @@ -126,10 +122,6 @@ void OSystem_Switch::logMessage(LogMessageType::Type type, const char *message) printf("%s\n", message); } -Common::String OSystem_Switch::getDefaultConfigFileName() { - return _baseConfigName; -} - Common::String OSystem_Switch::getDefaultLogFileName() { return "scummvm.log"; } diff --git a/backends/platform/sdl/switch/switch.h b/backends/platform/sdl/switch/switch.h index 61b4f3c058..2bdea6fe09 100644 --- a/backends/platform/sdl/switch/switch.h +++ b/backends/platform/sdl/switch/switch.h @@ -27,10 +27,6 @@ class OSystem_Switch : public OSystem_SDL { public: - // Let the subclasses be able to change _baseConfigName in the constructor - OSystem_Switch(Common::String baseConfigName = "scummvm.ini"); - virtual ~OSystem_Switch() {} - virtual void init() override; virtual void initBackend() override; virtual bool hasFeature(Feature f) override; @@ -39,11 +35,6 @@ public: virtual void logMessage(LogMessageType::Type type, const char *message) override; protected: - // Base string for creating the default path and filename - // for the configuration file - Common::String _baseConfigName; - - virtual Common::String getDefaultConfigFileName() override; virtual Common::String getDefaultLogFileName() override; }; |