Skip to content

Commit

Permalink
UICommon: Set UserConfigPath in the registry to AppData User for back…
Browse files Browse the repository at this point in the history
…wards compatibility
  • Loading branch information
OatmealDome committed May 30, 2022
1 parent e39f1d1 commit c67c82e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Source/Core/UICommon/UICommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,34 @@ void SetUserDirectory(std::string custom_path)
}

if (local) // Case 1-2
{
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
}
else if (configPath) // Case 3
{
user_path = TStrToUTF8(configPath.get());
}
else if (old_user_folder && File::Exists(old_user_folder.value())) // Case 4
{
user_path = old_user_folder.value();
}
else if (appdata_found) // Case 5
{
user_path = TStrToUTF8(appdata) + DIR_SEP "Dolphin Emulator" DIR_SEP;

// Set the UserConfigPath value in the registry for backwards compatibility with older Dolphin
// builds, which will look for the default User directory in Documents. If we set this key,
// they will use this as the User directory instead.
// (If we're in this case, then this key doesn't exist, so it's OK to set it.)
std::wstring wstr_path = UTF8ToWString(user_path);
RegSetKeyValueW(HKEY_CURRENT_USER, TEXT("Software\\Dolphin Emulator"), TEXT("UserConfigPath"),
REG_SZ, wstr_path.c_str(),
static_cast<DWORD>((wstr_path.size() + 1) * sizeof(wchar_t)));
}
else // Case 6
{
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
}

CoTaskMemFree(appdata);
CoTaskMemFree(documents);
Expand Down

0 comments on commit c67c82e

Please sign in to comment.