[Scummvm-cvs-logs] SF.net SVN: scummvm: [23465] scummvm/trunk/common/config-manager.cpp

kirben at users.sourceforge.net kirben at users.sourceforge.net
Thu Jul 20 22:40:13 CEST 2006


Revision: 23465
          http://svn.sourceforge.net/scummvm/?rev=23465&view=rev
Author:   kirben
Date:     2006-07-09 18:25:52 -0700 (Sun, 09 Jul 2006)

Log Message:
-----------
Change default config file location to 'Application Data\ScummVM' directory of the user's profile, when using Windows NT4/2000/XP/Vista

Modified Paths:
--------------
    scummvm/trunk/common/config-manager.cpp

Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp	2006-07-09 18:54:12 UTC (rev 23464)
+++ scummvm/trunk/common/config-manager.cpp	2006-07-10 01:25:52 UTC (rev 23465)
@@ -97,8 +97,42 @@
 		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 @@
 	_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) {






More information about the Scummvm-git-logs mailing list