UICommon: Change default User directory location to AppData

This commit is contained in:
OatmealDome 2022-05-29 18:10:10 -04:00
parent c4f4ecbb62
commit 75d87ff90e

View File

@ -289,8 +289,8 @@ void SetUserDirectory(std::string custom_path)
// -> Use GetExeDirectory()\User // -> Use GetExeDirectory()\User
// 3. HKCU\Software\Dolphin Emulator\UserConfigPath exists // 3. HKCU\Software\Dolphin Emulator\UserConfigPath exists
// -> Use this as the user directory path // -> Use this as the user directory path
// 4. My Documents exists // 4. AppData\Roaming exists
// -> Use My Documents\Dolphin Emulator as the User directory path // -> Use AppData\Roaming\Dolphin Emulator as the User directory path
// 5. Default // 5. Default
// -> Use GetExeDirectory()\User // -> Use GetExeDirectory()\User
@ -323,22 +323,22 @@ void SetUserDirectory(std::string custom_path)
local = local != 0 || File::Exists(File::GetExeDirectory() + DIR_SEP "portable.txt"); local = local != 0 || File::Exists(File::GetExeDirectory() + DIR_SEP "portable.txt");
// Get Documents path in case we need it. // Get AppData path in case we need it.
// TODO: Maybe use WIL when it's available? // TODO: Maybe use WIL when it's available?
PWSTR my_documents = nullptr; PWSTR appdata = nullptr;
bool my_documents_found = bool appdata_found =
SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr, &my_documents)); SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DEFAULT, nullptr, &appdata));
if (local) // Case 1-2 if (local) // Case 1-2
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
else if (configPath) // Case 3 else if (configPath) // Case 3
user_path = TStrToUTF8(configPath.get()); user_path = TStrToUTF8(configPath.get());
else if (my_documents_found) // Case 4 else if (appdata_found) // Case 4
user_path = TStrToUTF8(my_documents) + DIR_SEP "Dolphin Emulator" DIR_SEP; user_path = TStrToUTF8(appdata) + DIR_SEP "Dolphin Emulator" DIR_SEP;
else // Case 5 else // Case 5
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
CoTaskMemFree(my_documents); CoTaskMemFree(appdata);
#else #else
if (File::IsDirectory(ROOT_DIR DIR_SEP USERDATA_DIR)) if (File::IsDirectory(ROOT_DIR DIR_SEP USERDATA_DIR))
{ {