aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2006-07-10 01:25:52 +0000
committerTravis Howell2006-07-10 01:25:52 +0000
commit53aa4f054adf2b9ade12b8af400b1abb0fb01239 (patch)
treea2d8e2913f6c5c1f585086c5eb192b5424198e95
parentdcbbfa01c09854903666cce7ec855883b4257c00 (diff)
downloadscummvm-rg350-53aa4f054adf2b9ade12b8af400b1abb0fb01239.tar.gz
scummvm-rg350-53aa4f054adf2b9ade12b8af400b1abb0fb01239.tar.bz2
scummvm-rg350-53aa4f054adf2b9ade12b8af400b1abb0fb01239.zip
Change default config file location to 'Application Data\ScummVM' directory of the user's profile, when using Windows NT4/2000/XP/Vista
svn-id: r23465
-rw-r--r--common/config-manager.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 69f65a6173..7651f58ee2 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -97,8 +97,42 @@ void ConfigManager::loadDefaultConfigFile() {
strcpy(configFile, DEFAULT_CONFIG_FILE);
#else
#if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
- GetWindowsDirectory(configFile, MAXPATHLEN);
- strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
+ OSVERSIONINFO win32OsVersion;
+ ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
+ win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&win32OsVersion);
+ // Check for non-9X version of Windows.
+ if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
+ // Use the Application Data directory of the user profile.
+ if (win32OsVersion.dwMajorVersion >= 5) {
+ if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)))
+ error("Unable to access application data directory");
+ } else {
+ if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)))
+ error("Unable to access user profile directory");
+
+ strcat(configFile, "\\Application Data");
+ CreateDirectory(configFile, NULL);
+ }
+
+ strcat(configFile, "\\ScummVM");
+ CreateDirectory(configFile, NULL);
+ strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
+
+ if (fopen(configFile, "r") == NULL) {
+ // Check windows directory
+ char oldConfigFile[MAXPATHLEN];
+ GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
+ strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE);
+ if (fopen(oldConfigFile, "r"))
+ strcpy(configFile, oldConfigFile);
+ }
+ } else {
+ // Check windows directory
+ GetWindowsDirectory(configFile, MAXPATHLEN);
+ strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
+ }
+
#elif defined(PALMOS_MODE)
strcpy(configFile,"/PALM/Programs/ScummVM/" DEFAULT_CONFIG_FILE);
#elif defined(__PLAYSTATION2__)
@@ -125,7 +159,7 @@ void ConfigManager::loadConfigFile(const String &filename) {
_filename = filename;
_domainSaveOrder.clear();
loadFile(_filename);
- debug(1, "Switched to configuration %s", _filename.c_str());
+ printf("Using configuration file: %s\n", _filename.c_str());
}
void ConfigManager::loadFile(const String &filename) {