mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 20:17:49 +00:00
SDL: Simplify implementations of getDefaultConfigFileName()
This commit is contained in:
parent
c90164f526
commit
aa083256ec
@ -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();
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user