Browse Source

fix mingw

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/2929/head
crueter 3 months ago
parent
commit
fbd0551e5b
  1. 5
      src/common/CMakeLists.txt
  2. 6
      src/common/fs/ryujinx_compat.cpp
  3. 1
      src/common/fs/ryujinx_compat.h
  4. 14
      src/common/fs/symlink.cpp
  5. 1
      src/qt_common/util/fs.cpp
  6. 19
      src/yuzu/main_window.cpp

5
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()

6
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<IMEN> &imens)
return IMENReadResult::Success;
}
} // namespace Common::FS

1
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);

14
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 <iostream>
#include "symlink.h"
#ifdef _WIN32
@ -9,7 +8,9 @@
#include <fmt/format.h>
#endif
#ifndef __MINGW32__
#include <boost/filesystem.hpp>
#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

1
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")) {

19
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);

Loading…
Cancel
Save