Browse Source

make windows work

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/2815/head
crueter 4 months ago
parent
commit
5867a1a1f9
  1. 6
      src/common/fs/symlink.cpp
  2. 4
      src/qt_common/util/fs.cpp

6
src/common/fs/symlink.cpp

@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include <iostream>
#include "symlink.h" #include "symlink.h"
#ifdef _WIN32 #ifdef _WIN32
#include <winbase.h>
#include <windows.h>
#endif #endif
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -34,7 +35,8 @@ bool CreateSymlink(const fs::path &from, const fs::path &to)
bool IsSymlink(const fs::path &path) bool IsSymlink(const fs::path &path)
{ {
#ifdef _WIN32 #ifdef _WIN32
return fs::status(path).type() == fs::file_type::junction;
auto attributes = GetFileAttributesW(path.wstring().c_str());
return attributes & FILE_ATTRIBUTE_REPARSE_POINT;
#else #else
return fs::is_symlink(path); return fs::is_symlink(path);
#endif #endif

4
src/qt_common/util/fs.cpp

@ -58,7 +58,9 @@ bool CheckUnlink(const fs::path &eden_dir, const fs::path &ryu_dir)
// first cleanup the symlink/junction, // first cleanup the symlink/junction,
try { try {
fs::remove_all(linked);
// NB: do NOT use remove_all, as Windows treats this as a remove_all to the target,
// NOT the junction
fs::remove(linked);
} catch (std::exception &e) { } catch (std::exception &e) {
QtCommon::Frontend::Critical( QtCommon::Frontend::Critical(
tr("Failed to unlink old directory"), tr("Failed to unlink old directory"),

Loading…
Cancel
Save