From 2c00ccca83938bb46b455f26d4e063e4aa9c178d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 11 Dec 2023 01:49:37 +1000 Subject: [PATCH] Qt: Resolve any symbolic links in AppRoot/DataRoot Should fix incorrect relative path generation when PCSX2's data directory is a within a symbolic link. --- pcsx2/Pcsx2Config.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 38dc8195d9..583434e178 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -1687,7 +1687,7 @@ bool EmuFolders::InitializeCriticalFolders() void EmuFolders::SetAppRoot() { - std::string program_path(FileSystem::GetProgramPath()); + const std::string program_path = FileSystem::GetProgramPath(); Console.WriteLn("Program Path: %s", program_path.c_str()); AppRoot = Path::Canonicalize(Path::GetDirectory(program_path)); @@ -1732,12 +1732,11 @@ void EmuFolders::SetDataDirectory() const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); if (xdg_config_home && Path::IsAbsolute(xdg_config_home)) { - DataRoot = Path::Combine(xdg_config_home, "PCSX2"); + DataRoot = Path::RealPath(Path::Combine(xdg_config_home, "PCSX2")); } else { // Use ~/PCSX2 for non-XDG, and ~/.config/PCSX2 for XDG. - // Maybe we should drop the former when Qt goes live. const char* home_dir = getenv("HOME"); if (home_dir) { @@ -1746,14 +1745,14 @@ void EmuFolders::SetDataDirectory() if (!FileSystem::DirectoryExists(config_dir.c_str())) FileSystem::CreateDirectoryPath(config_dir.c_str(), false); - DataRoot = Path::Combine(config_dir, "PCSX2"); + DataRoot = Path::RealPath(Path::Combine(config_dir, "PCSX2")); } } #elif defined(__APPLE__) static constexpr char MAC_DATA_DIR[] = "Library/Application Support/PCSX2"; const char* home_dir = getenv("HOME"); if (home_dir) - DataRoot = Path::Combine(home_dir, MAC_DATA_DIR); + DataRoot = Path::RealPath(Path::Combine(home_dir, MAC_DATA_DIR)); #endif // make sure it exists