Use global user directory on windows.
Can override by setting HKCU\Software\Dolphin-emu\LocalUserConfig to true.
This commit is contained in:
parent
aaf8e92f78
commit
dfcef6890e
|
@ -665,7 +665,52 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
|
|||
if (paths[D_USER_IDX].empty())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
|
||||
// Detect where the User directory is. There are four different cases (on top of the
|
||||
// command line flag, which overrides all this):
|
||||
// 1. HKCU\Software\Dolphin Emulator\LocalUserConfig exists and is true
|
||||
// -> Use GetExeDirectory()\User
|
||||
// 2. HKCU\Software\Dolphin Emulator\UserConfigPath exists
|
||||
// -> Use this as the user directory path
|
||||
// 3. My Documents exists
|
||||
// -> Use My Documents\Dolphin Emulator as the User directory path
|
||||
// 4. Default
|
||||
// -> Use GetExeDirectory()\User
|
||||
|
||||
// Check our registry keys
|
||||
HKEY hkey;
|
||||
DWORD local = 0;
|
||||
TCHAR configPath[MAX_PATH] = {0};
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Dolphin Emulator"), NULL, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD size = 4;
|
||||
if (RegQueryValueEx(hkey, TEXT("LocalUserConfig"), NULL, NULL, reinterpret_cast<LPBYTE>(&local), &size) != ERROR_SUCCESS)
|
||||
local = 0;
|
||||
|
||||
size = MAX_PATH;
|
||||
if (RegQueryValueEx(hkey, TEXT("UserConfigPath"), NULL, NULL, (LPBYTE)configPath, &size) != ERROR_SUCCESS)
|
||||
configPath[0] = 0;
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
// Get Program Files path in case we need it.
|
||||
TCHAR my_documents[MAX_PATH];
|
||||
bool my_documents_found = SUCCEEDED(SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, my_documents));
|
||||
|
||||
if (local) // Case 1
|
||||
paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
|
||||
else if (configPath[0]) // Case 2
|
||||
paths[D_USER_IDX] = TStrToUTF8(configPath);
|
||||
else if (my_documents_found) // Case 3
|
||||
paths[D_USER_IDX] = TStrToUTF8(my_documents) + DIR_SEP "Dolphin Emulator" DIR_SEP;
|
||||
else // Case 4
|
||||
paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
|
||||
|
||||
// Prettify the path: it will be displayed in some places, we don't want a mix of \ and /.
|
||||
paths[D_USER_IDX] = ReplaceAll(paths[D_USER_IDX], "\\", DIR_SEP);
|
||||
|
||||
// Make sure it ends in DIR_SEP.
|
||||
if (*paths[D_USER_IDX].rbegin() != DIR_SEP_CHR)
|
||||
paths[D_USER_IDX] += DIR_SEP;
|
||||
#else
|
||||
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
|
||||
paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
||||
|
|
|
@ -351,11 +351,7 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
|
|||
{
|
||||
// Use default memcard path if there is no user defined name
|
||||
std::string defaultFilename = isSlotA ? GC_MEMCARDA : GC_MEMCARDB;
|
||||
#ifdef _WIN32
|
||||
memcardPath = "." + File::GetUserPath(D_GCUSER_IDX).substr(File::GetExeDirectory().size()) + defaultFilename + ext;
|
||||
#else
|
||||
memcardPath = File::GetUserPath(D_GCUSER_IDX) + defaultFilename + ext;
|
||||
#endif
|
||||
memcardPath = File::GetUserPath(D_GCUSER_IDX) + defaultFilename + ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -268,6 +268,7 @@ bool DolphinApp::OnInit()
|
|||
File::CopyDir(std::string(SHARED_USER_DIR OPENCL_DIR DIR_SEP),
|
||||
File::GetUserPath(D_OPENCL_IDX));
|
||||
#endif
|
||||
File::CreateFullPath(File::GetUserPath(D_USER_IDX));
|
||||
File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
|
||||
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
|
||||
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
|
||||
|
|
Loading…
Reference in New Issue