| 103 | if (fopen(configFile, "r") == NULL) { |
| 104 | OSVERSIONINFO win32OsVersion; |
| 105 | ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); |
| 106 | win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
| 107 | GetVersionEx(&win32OsVersion); |
| 108 | // Check for non-9X version of Windows. |
| 109 | if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { |
| 110 | // Use the Application Data directory of the user profile. |
| 111 | int bytesRead; |
| 112 | if (win32OsVersion.dwMajorVersion >= 5) |
| 113 | bytesRead = GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)); |
| 114 | else { |
| 115 | bytesRead = GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)); |
| 116 | if (bytesRead > 0) { |
| 117 | strcat(configFile, "\\Application Data"); |
| 118 | CreateDirectory(configFile, NULL); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | //Use APPDATA/USERPROFILE if found, otherwise fall back to Windows directory. |
| 123 | if (bytesRead > 0) { |
| 124 | strcat(configFile, "\\ScummVM"); |
| 125 | CreateDirectory(configFile, NULL); |
| 126 | strcat(configFile, "\\" DEFAULT_CONFIG_FILE); |
| 127 | } else { |
| 128 | GetWindowsDirectory(configFile, MAXPATHLEN); |
| 129 | strcat(configFile, "\\" DEFAULT_CONFIG_FILE); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |