[Scummvm-git-logs] scummvm master -> aa083256ec05ee43d9f1977ca2178cacdfb25ae3

bluegr bluegr at gmail.com
Sat Dec 7 19:15:44 UTC 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
aa083256ec SDL: Simplify implementations of getDefaultConfigFileName()


Commit: aa083256ec05ee43d9f1977ca2178cacdfb25ae3
    https://github.com/scummvm/scummvm/commit/aa083256ec05ee43d9f1977ca2178cacdfb25ae3
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2019-12-07T21:15:41+02:00

Commit Message:
SDL: Simplify implementations of getDefaultConfigFileName()

Changed paths:
    backends/platform/samsungtv/samsungtv.cpp
    backends/platform/samsungtv/samsungtv.h
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/macosx/macosx.h
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/posix/posix.h
    backends/platform/sdl/ps3/ps3.cpp
    backends/platform/sdl/ps3/ps3.h
    backends/platform/sdl/psp2/psp2.cpp
    backends/platform/sdl/psp2/psp2.h
    backends/platform/sdl/switch/switch.cpp
    backends/platform/sdl/switch/switch.h


diff --git a/backends/platform/samsungtv/samsungtv.cpp b/backends/platform/samsungtv/samsungtv.cpp
index bee71b7..5a10379 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 aad946a..0b98297 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 1c47401..1545d9a 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 b860b71..e4b5b2a 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 b983849..b6afd36 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 5df6738..41fdc35 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 78b02d7..9f77c03 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 a0c0d80..766cf5f 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 bb26694..f87d8f8 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 a90272b..0b3be25 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 1a3c573..120fb95 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 61b4f3c..2bdea6f 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;
 };
 




More information about the Scummvm-git-logs mailing list