@@ -1173,15 +1173,24 @@ void GlobalData::parseGameDataDefinition( INI* ini )
11731173
11741174 TheWritableGlobalData->m_userDataDir .clear ();
11751175
1176- char temp[_MAX_PATH];
1177- if (::SHGetSpecialFolderPath (nullptr , temp, CSIDL_PERSONAL , true ))
1176+ PWSTR pszPath = nullptr ;
1177+ HRESULT hr = SHGetKnownFolderPath (FOLDERID_Documents, KF_FLAG_DEFAULT , nullptr , &pszPath);
1178+ if (SUCCEEDED (hr) && pszPath)
11781179 {
1179- if (temp[strlen (temp)-1 ] != ' \\ ' )
1180- strcat (temp, " \\ " );
1181- strcat (temp, TheWritableGlobalData->m_userDataLeafName .str ());
1182- strcat (temp, " \\ " );
1183- CreateDirectory (temp, nullptr );
1184- TheWritableGlobalData->m_userDataDir = temp;
1180+ AsciiString myDocumentsDirectory;
1181+ myDocumentsDirectory.translate (UnicodeString (pszPath));
1182+ CoTaskMemFree (pszPath);
1183+
1184+ if (myDocumentsDirectory.getCharAt (myDocumentsDirectory.getLength () -1 ) != ' \\ ' )
1185+ myDocumentsDirectory.concat ( ' \\ ' );
1186+
1187+ myDocumentsDirectory.concat (TheWritableGlobalData->m_userDataLeafName .str ());
1188+
1189+ if (myDocumentsDirectory.getCharAt ( myDocumentsDirectory.getLength () - 1 ) != ' \\ ' )
1190+ myDocumentsDirectory.concat ( ' \\ ' );
1191+
1192+ CreateDirectory (myDocumentsDirectory.str (), nullptr );
1193+ TheWritableGlobalData->m_userDataDir = myDocumentsDirectory;
11851194 }
11861195
11871196 // override INI values with user preferences
0 commit comments