From 70e9a5b951e9086eb08aed8ce95b22eab0354637 Mon Sep 17 00:00:00 2001 From: Alejandro Marzini Date: Sat, 26 Jun 2010 03:44:47 +0000 Subject: Removed DEFAULT_CONFIG_FILE define in favor of new getConfigFileNameString function. svn-id: r50301 --- backends/platform/sdl/macosx/macosx.cpp | 16 ++-------------- backends/platform/sdl/macosx/macosx.h | 1 + backends/platform/sdl/posix/posix.cpp | 10 ++++++---- backends/platform/sdl/posix/posix.h | 1 + backends/platform/sdl/sdl.cpp | 8 +++++--- backends/platform/sdl/sdl.h | 1 + backends/platform/sdl/win32/win32.cpp | 12 +++++++----- backends/platform/sdl/win32/win32.h | 1 + 8 files changed, 24 insertions(+), 26 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 446c41dd4e..d6faf40294 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -33,8 +33,6 @@ #include "CoreFoundation/CoreFoundation.h" -#define DEFAULT_CONFIG_FILE "Library/Preferences/ScummVM Preferences" - OSystem_MacOSX::OSystem_MacOSX() { } @@ -51,18 +49,8 @@ void OSystem_MacOSX::initBackend() { OSystem_POSIX::initBackend(); } -Common::String OSystem_MacOSX::getDefaultConfigFileName() { - char configFile[MAXPATHLEN]; - - // On UNIX type systems, by default we store the config file inside - // to the HOME directory of the user. - const char *home = getenv("HOME"); - if (home != NULL && strlen(home) < MAXPATHLEN) - snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE); - else - strcpy(configFile, DEFAULT_CONFIG_FILE); - - return configFile; +const char *OSystem_MacOSX::getConfigFileNameString() { + return "Library/Preferences/ScummVM Preferences"; } void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 0b665d1132..a6f902b97b 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -38,6 +38,7 @@ public: void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); protected: + const char *getConfigFileNameString(); Common::String getDefaultConfigFileName(); }; diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 75f09c3555..0b770bc512 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -41,8 +41,6 @@ #include "backends/fs/posix/posix-fs-factory.h" -#define DEFAULT_CONFIG_FILE ".scummvmrc" - OSystem_POSIX::OSystem_POSIX() { } @@ -63,6 +61,10 @@ void OSystem_POSIX::initBackend() { OSystem_SDL::initBackend(); } +const char *OSystem_POSIX::getConfigFileNameString() { + return ".scummvmrc"; +} + Common::String OSystem_POSIX::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -76,9 +78,9 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() { // from the Springboard, is /. Which we don't want. const char *home = getenv("HOME"); if (home != NULL && strlen(home) < MAXPATHLEN) - snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE); + snprintf(configFile, MAXPATHLEN, "%s/%s", home, getConfigFileNameString()); else - strcpy(configFile, DEFAULT_CONFIG_FILE); + strcpy(configFile, getConfigFileNameString()); return configFile; } diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index ca912c9d87..7e7e388229 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -38,6 +38,7 @@ public: virtual void initBackend(); protected: + virtual const char *getConfigFileNameString(); virtual Common::String getDefaultConfigFileName(); }; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 85506c9520..832f6ffb78 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -38,8 +38,6 @@ #include "icons/scummvm.xpm" -#define DEFAULT_CONFIG_FILE "scummvm.ini" - #include OSystem_SDL::OSystem_SDL() @@ -129,9 +127,13 @@ void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) } +const char *OSystem_SDL::getConfigFileNameString() { + return "scummvm.ini"; +} + Common::String OSystem_SDL::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; - strcpy(configFile, DEFAULT_CONFIG_FILE); + strcpy(configFile, getConfigFileNameString()); return configFile; } diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 8740b82b9f..53b38d1dd6 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -79,6 +79,7 @@ protected: virtual void setupIcon(); + virtual const char *getConfigFileNameString(); virtual Common::String getDefaultConfigFileName(); }; diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 4d585add77..907059feaf 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -44,8 +44,6 @@ #include "backends/fs/windows/windows-fs-factory.h" -#define DEFAULT_CONFIG_FILE "scummvm.ini" - OSystem_Win32::OSystem_Win32() { } @@ -57,6 +55,10 @@ void OSystem_Win32::init() { OSystem_SDL::init(); } +const char *OSystem_Win32::getConfigFileNameString() { + return "\\scummvm.ini"; +} + Common::String OSystem_Win32::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -80,14 +82,14 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { strcat(configFile, "\\ScummVM"); CreateDirectory(configFile, NULL); - strcat(configFile, "\\" DEFAULT_CONFIG_FILE); + strcat(configFile, getConfigFileNameString()); FILE *tmp = NULL; if ((tmp = fopen(configFile, "r")) == NULL) { // Check windows directory char oldConfigFile[MAXPATHLEN]; GetWindowsDirectory(oldConfigFile, MAXPATHLEN); - strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE); + strcat(oldConfigFile, getConfigFileNameString()); if ((tmp = fopen(oldConfigFile, "r"))) { strcpy(configFile, oldConfigFile); @@ -99,7 +101,7 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { } else { // Check windows directory GetWindowsDirectory(configFile, MAXPATHLEN); - strcat(configFile, "\\" DEFAULT_CONFIG_FILE); + strcat(configFile, getConfigFileNameString()); } return configFile; diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index e4541e314d..e8bc255459 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -36,6 +36,7 @@ public: void init(); protected: + const char *getConfigFileNameString(); Common::String getDefaultConfigFileName(); }; -- cgit v1.2.3