|
@@ -211,46 +211,57 @@ void SetUserDirectory(const std::string& custom_path) |
|
|
// -> Use GetExeDirectory()\User |
|
|
|
|
|
// Check our registry keys |
|
|
// TODO: Maybe use WIL when it's available? |
|
|
HKEY hkey; |
|
|
DWORD local = 0; |
|
|
TCHAR configPath[MAX_PATH] = {0}; |
|
|
std::unique_ptr<TCHAR[]> configPath; |
|
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, |
|
|
&hkey) == ERROR_SUCCESS) |
|
|
{ |
|
|
DWORD size = 4; |
|
|
if (RegQueryValueEx(hkey, TEXT("LocalUserConfig"), nullptr, nullptr, |
|
|
reinterpret_cast<LPBYTE>(&local), &size) != ERROR_SUCCESS) |
|
|
{ |
|
|
local = 0; |
|
|
} |
|
|
|
|
|
size = 0; |
|
|
RegQueryValueEx(hkey, TEXT("UserConfigPath"), nullptr, nullptr, nullptr, &size); |
|
|
configPath = std::make_unique<TCHAR[]>(size / sizeof(TCHAR)); |
|
|
if (RegQueryValueEx(hkey, TEXT("UserConfigPath"), nullptr, nullptr, |
|
|
reinterpret_cast<LPBYTE>(configPath.get()), &size) != ERROR_SUCCESS) |
|
|
{ |
|
|
configPath.reset(); |
|
|
} |
|
|
|
|
|
size = MAX_PATH; |
|
|
if (RegQueryValueEx(hkey, TEXT("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, |
|
|
&size) != ERROR_SUCCESS) |
|
|
configPath[0] = 0; |
|
|
RegCloseKey(hkey); |
|
|
} |
|
|
|
|
|
local = local || File::Exists(File::GetExeDirectory() + DIR_SEP "portable.txt"); |
|
|
local = local != 0 || File::Exists(File::GetExeDirectory() + DIR_SEP "portable.txt"); |
|
|
|
|
|
// Get Program Files path in case we need it. |
|
|
TCHAR my_documents[MAX_PATH]; |
|
|
bool my_documents_found = SUCCEEDED( |
|
|
SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents)); |
|
|
// Get Documents path in case we need it. |
|
|
// TODO: Maybe use WIL when it's available? |
|
|
PWSTR my_documents = nullptr; |
|
|
bool my_documents_found = |
|
|
SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr, &my_documents)); |
|
|
|
|
|
if (local) // Case 1-2 |
|
|
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; |
|
|
else if (configPath[0]) // Case 3 |
|
|
user_path = TStrToUTF8(configPath); |
|
|
else if (configPath) // Case 3 |
|
|
user_path = TStrToUTF8(configPath.get()); |
|
|
else if (my_documents_found) // Case 4 |
|
|
user_path = TStrToUTF8(my_documents) + DIR_SEP "Dolphin Emulator" DIR_SEP; |
|
|
else // Case 5 |
|
|
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; |
|
|
|
|
|
CoTaskMemFree(my_documents); |
|
|
|
|
|
// Prettify the path: it will be displayed in some places, we don't want a mix |
|
|
// of \ and /. |
|
|
user_path = ReplaceAll(user_path, "\\", DIR_SEP); |
|
|
user_path = ReplaceAll(std::move(user_path), "\\", DIR_SEP); |
|
|
|
|
|
// Make sure it ends in DIR_SEP. |
|
|
if (*user_path.rbegin() != DIR_SEP_CHR) |
|
|
if (user_path.back() != DIR_SEP_CHR) |
|
|
user_path += DIR_SEP; |
|
|
|
|
|
#else |
|
@@ -325,7 +336,7 @@ void SetUserDirectory(const std::string& custom_path) |
|
|
#endif |
|
|
} |
|
|
#endif |
|
|
File::SetUserPath(D_USER_IDX, user_path); |
|
|
File::SetUserPath(D_USER_IDX, std::move(user_path)); |
|
|
} |
|
|
|
|
|
void SaveWiimoteSources() |
|
|
0 comments on commit
3b21d32