diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 738624b6f0..9623deccd3 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -252,7 +252,10 @@ if(CXX_CLANG) endif() if (BOOST_NO_HEADERS) - target_link_libraries(common PUBLIC Boost::algorithm Boost::icl Boost::pool Boost::filesystem) + target_link_libraries(common PUBLIC Boost::algorithm Boost::icl Boost::pool) + if (NOT MINGW) + target_link_libraries(common PRIVATE Boost::filesystem) + endif() else() target_link_libraries(common PUBLIC Boost::headers) endif() diff --git a/src/common/fs/ryujinx_compat.cpp b/src/common/fs/ryujinx_compat.cpp index d292891ead..bb6a633723 100644 --- a/src/common/fs/ryujinx_compat.cpp +++ b/src/common/fs/ryujinx_compat.cpp @@ -22,6 +22,11 @@ fs::path GetKvdbPath(const fs::path& path) { / "imkvdb.arc"; } +fs::path GetRyuPathFromSavePath(const fs::path& path) { + // This is a horrible hack, but I cba to find something better + return path.parent_path().parent_path().parent_path().parent_path().parent_path(); +} + fs::path GetRyuSavePath(const u64 &save_id) { return GetRyuSavePath(GetLegacyPath(EmuPath::RyujinxDir), save_id); @@ -98,5 +103,4 @@ IMENReadResult ReadKvdb(const fs::path &path, std::vector &imens) return IMENReadResult::Success; } - } // namespace Common::FS diff --git a/src/common/fs/ryujinx_compat.h b/src/common/fs/ryujinx_compat.h index b8520989d1..50dbf8a7a4 100644 --- a/src/common/fs/ryujinx_compat.h +++ b/src/common/fs/ryujinx_compat.h @@ -17,6 +17,7 @@ constexpr const u8 IMEN_SIZE = 0x8c; fs::path GetKvdbPath(); fs::path GetKvdbPath(const fs::path &path); +fs::path GetRyuPathFromSavePath(const fs::path &path); fs::path GetRyuSavePath(const u64 &save_id); fs::path GetRyuSavePath(const fs::path &path, const u64 &save_id); diff --git a/src/common/fs/symlink.cpp b/src/common/fs/symlink.cpp index a9a2d6893a..3632a97c99 100644 --- a/src/common/fs/symlink.cpp +++ b/src/common/fs/symlink.cpp @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include #include "symlink.h" #ifdef _WIN32 @@ -9,7 +8,9 @@ #include #endif +#ifndef __MINGW32__ #include +#endif namespace fs = std::filesystem; @@ -39,7 +40,18 @@ bool CreateSymlink(const fs::path &from, const fs::path &to) bool IsSymlink(const fs::path &path) { + // boost's is_symlink is broken on MinGW + // use win32 api in this case +#ifdef __MINGW32__ + DWORD attrs = GetFileAttributesW(path.wstring().c_str()); + if (INVALID_FILE_ATTRIBUTES == attrs) { + return false; + } + return attrs & FILE_ATTRIBUTE_DIRECTORY && + attrs & FILE_ATTRIBUTE_REPARSE_POINT; +#else return boost::filesystem::is_symlink(boost::filesystem::path{path}); +#endif } } // namespace Common::FS diff --git a/src/qt_common/util/fs.cpp b/src/qt_common/util/fs.cpp index 7a9d3d1b15..06fcc5455a 100644 --- a/src/qt_common/util/fs.cpp +++ b/src/qt_common/util/fs.cpp @@ -108,6 +108,7 @@ const fs::path GetRyujinxSavePath(const fs::path &path_hint, const u64 &program_ return fs::path{}; ryu_path = selected_path; + // In case the user selects the actual ryujinx installation dir INSTEAD OF // the portable dir if (fs::exists(ryu_path / "portable")) { diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 7015220204..d8dc9b8cc7 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include "common/fs/ryujinx_compat.h" #include "common/fs/symlink.h" #include "main_window.h" #include "network/network.h" @@ -2864,13 +2865,16 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) const std::string user_id = GetProfileID(); const std::string hex_program = fmt::format("{:016X}", program_id); - const fs::path eden_dir - = FrontendCommon::DataManager::GetDataDir(FrontendCommon::DataManager::DataDir::Saves, - user_id) - / hex_program; + const fs::path eden_dir = FrontendCommon::DataManager::GetDataDir( + FrontendCommon::DataManager::DataDir::Saves, user_id) / + hex_program; fs::path ryu_dir; + // filesystem error: read_symlink: Function not implemented + // Theoretically, the check immediately after this should account for it; + // keyword THEORETICALLY +#ifndef __MINGW32__ // If the Eden directory is a symlink we can just read that and use it as our Ryu dir if (Common::FS::IsSymlink(eden_dir)) { ryu_dir = fs::read_symlink(eden_dir); @@ -2883,6 +2887,7 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) ryu_dir = fs::path{}; } } +#endif // Otherwise, prompt the user if (ryu_dir.empty()) { @@ -2892,6 +2897,8 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) .filesystemAbsolutePath(); ryu_dir = QtCommon::FS::GetRyujinxSavePath(existing_path, program_id); + + if (ryu_dir.empty()) return; } // CheckUnlink basically just checks to see if one or both are linked, and prompts the user to @@ -2900,7 +2907,9 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) if (!QtCommon::FS::CheckUnlink(eden_dir, ryu_dir)) { RyujinxDialog dialog(eden_dir, ryu_dir, this); if (dialog.exec() == QDialog::Accepted) { - UISettings::values.ryujinx_link_paths.insert(program_id, QString::fromStdString(ryu_dir.string())); + UISettings::values.ryujinx_link_paths.insert( + program_id, + QString::fromStdString(Common::FS::GetRyuPathFromSavePath(ryu_dir).string())); } } else { UISettings::values.ryujinx_link_paths.remove(program_id);