From bf7a57fc55493247a624ecfd65e4d73964e7d8d2 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Sun, 12 Apr 2026 02:40:16 -0500 Subject: Remove vendored usvfs and Windows-only usvfs code paths The Linux port uses its own in-process FUSE VFS (FuseConnector), so usvfs was dead weight: libs/usvfs/ was never built, usvfsconnector.cpp was explicitly REMOVE_ITEM'd from the source list, and every call site was already guarded by #ifdef _WIN32 with a working Linux branch (the Windows build is also broken on this branch, since FUSE3 is a hard find_package dependency). - Drop libs/usvfs/ and src/src/usvfsconnector.{cpp,h} - Collapse #ifdef _WIN32 / usvfs include branches in organizercore, mainwindow, settings, util, spawn - Remove getUsvfsVersionString() and the "usvfs: ..." log field - Remove vfs32/64DLLName APPPARAMs (nothing reads them) - Relabel About dialog "usvfs:" row to "VFS: FUSE 3" --- src/src/CMakeLists.txt | 5 - src/src/aboutdialog.cpp | 3 +- src/src/aboutdialog.ui | 2 +- src/src/mainwindow.cpp | 4 - src/src/moapplication.cpp | 5 +- src/src/organizercore.cpp | 4 - src/src/organizercore.h | 8 - src/src/settings.h | 3 - src/src/shared/appconfig.inc | 2 - src/src/shared/util.cpp | 39 +---- src/src/shared/util.h | 1 - src/src/spawn.cpp | 1 - src/src/usvfsconnector.cpp | 342 ------------------------------------------- src/src/usvfsconnector.h | 102 ------------- 14 files changed, 5 insertions(+), 516 deletions(-) delete mode 100644 src/src/usvfsconnector.cpp delete mode 100644 src/src/usvfsconnector.h (limited to 'src') diff --git a/src/src/CMakeLists.txt b/src/src/CMakeLists.txt index d618af7..c22442c 100644 --- a/src/src/CMakeLists.txt +++ b/src/src/CMakeLists.txt @@ -55,11 +55,6 @@ list(APPEND ORGANIZER_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/settingsdialogproton.h ${CMAKE_CURRENT_SOURCE_DIR}/wineprefix.h) -# Remove Windows-only sources (replaced by Linux equivalents) -list(REMOVE_ITEM ORGANIZER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/usvfsconnector.cpp) -list(REMOVE_ITEM ORGANIZER_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/usvfsconnector.h) # Remove WebEngine-dependent sources when not available if(NOT Qt6WebEngineWidgets_FOUND) diff --git a/src/src/aboutdialog.cpp b/src/src/aboutdialog.cpp index 7c95990..94ccfcb 100644 --- a/src/src/aboutdialog.cpp +++ b/src/src/aboutdialog.cpp @@ -90,8 +90,7 @@ AboutDialog::AboutDialog(const QString& version, QWidget* parent) ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown"); #endif - ui->usvfsLabel->setText(ui->usvfsLabel->text() + " " + - MOShared::getUsvfsVersionString()); + ui->usvfsLabel->setText(ui->usvfsLabel->text() + " FUSE 3"); ui->licenseText->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); } diff --git a/src/src/aboutdialog.ui b/src/src/aboutdialog.ui index 323e20a..042bdd8 100644 --- a/src/src/aboutdialog.ui +++ b/src/src/aboutdialog.ui @@ -107,7 +107,7 @@ - usvfs: + VFS: diff --git a/src/src/mainwindow.cpp b/src/src/mainwindow.cpp index f2ce67b..d61273c 100644 --- a/src/src/mainwindow.cpp +++ b/src/src/mainwindow.cpp @@ -81,11 +81,7 @@ along with Mod Organizer. If not, see . #include #include #include -#ifdef _WIN32 -#include -#else #include "fluorinepaths.h" -#endif #include "directoryrefresher.h" #include "shared/directoryentry.h" diff --git a/src/src/moapplication.cpp b/src/src/moapplication.cpp index 45b79a8..96d9854 100644 --- a/src/src/moapplication.cpp +++ b/src/src/moapplication.cpp @@ -319,9 +319,8 @@ int MOApplication::setup(MOMultiProcess& multiProcess, bool forceSelect) #ifndef GITID #define GITID "unknown" #endif - log::info("starting Mod Organizer version {} revision {} in {}, usvfs: {}", - createVersionInfo().string(), GITID, QCoreApplication::applicationDirPath(), - MOShared::getUsvfsVersionString()); + log::info("starting Mod Organizer version {} revision {} in {}", + createVersionInfo().string(), GITID, QCoreApplication::applicationDirPath()); if (multiProcess.secondary()) { log::debug("another instance of MO is running but --multiple was given"); diff --git a/src/src/organizercore.cpp b/src/src/organizercore.cpp index 3e3e7c9..0e1219d 100644 --- a/src/src/organizercore.cpp +++ b/src/src/organizercore.cpp @@ -39,12 +39,8 @@ #include #include #include -#ifdef _WIN32 -#include -#else #include "fluorineconfig.h" #include "wineprefix.h" -#endif #include #include diff --git a/src/src/organizercore.h b/src/src/organizercore.h index 99b0d86..dc3547e 100644 --- a/src/src/organizercore.h +++ b/src/src/organizercore.h @@ -35,11 +35,7 @@ #include "selfupdater.h" #include "settings.h" #include "uilocker.h" -#ifdef _WIN32 -#include "usvfsconnector.h" -#else #include "fuseconnector.h" -#endif class ModListSortProxy; class PluginListSortProxy; @@ -596,11 +592,7 @@ private: bool m_ArchivesInit; MOBase::DelayedFileWriter m_PluginListsWriter; -#ifdef _WIN32 - UsvfsConnector m_USVFS; -#else FuseConnector m_USVFS; -#endif UILocker m_UILocker; }; diff --git a/src/src/settings.h b/src/src/settings.h index f1ea342..a4a9e89 100644 --- a/src/src/settings.h +++ b/src/src/settings.h @@ -25,9 +25,6 @@ along with Mod Organizer. If not, see . #include #include #include -#ifdef _WIN32 -#include -#endif #ifdef interface #undef interface diff --git a/src/src/shared/appconfig.inc b/src/src/shared/appconfig.inc index 9058bf1..ede9380 100644 --- a/src/src/shared/appconfig.inc +++ b/src/src/shared/appconfig.inc @@ -16,8 +16,6 @@ APPPARAM(std::wstring, iniFileName, L"ModOrganizer.ini") APPPARAM(std::wstring, proxyDLLTarget, L"steam_api.dll") APPPARAM(std::wstring, proxyDLLOrig, L"steam_api_orig.dll") // needs to be identical to the value used in proxydll-project APPPARAM(std::wstring, proxyDLLSource, L"proxy.dll") -APPPARAM(std::wstring, vfs32DLLName, L"usvfs_x86.dll") -APPPARAM(std::wstring, vfs64DLLName, L"usvfs_x64.dll") APPPARAM(std::wstring, nxmHandlerExe, L"nxmhandler.exe") APPPARAM(std::wstring, nxmHandlerIni, L"nxmhandler.ini") APPPARAM(std::wstring, portableLockFileName, L"portable.txt") diff --git a/src/src/shared/util.cpp b/src/src/shared/util.cpp index 70c0aeb..b1df0a6 100644 --- a/src/src/shared/util.cpp +++ b/src/src/shared/util.cpp @@ -22,10 +22,7 @@ along with Mod Organizer. If not, see . #include "../mainwindow.h" #include "windows_error.h" #include -#ifdef _WIN32 -#include -#include -#else +#ifndef _WIN32 #include #include #include @@ -326,40 +323,6 @@ Version createVersionInfo() } #endif -#ifdef _WIN32 -QString getUsvfsDLLVersion() -{ - QString s = usvfsVersionString(); - if (s.isEmpty()) { - s = "?"; - } - return s; -} - -QString getUsvfsVersionString() -{ - const QString dll = getUsvfsDLLVersion(); - const QString header = USVFS_VERSION_STRING; - - QString usvfsVersion; - - if (dll == header) { - return dll; - } else { - return "dll is " + dll + ", compiled against " + header; - } -} -#else -QString getUsvfsDLLVersion() -{ - return "N/A (Linux)"; -} - -QString getUsvfsVersionString() -{ - return "N/A (Linux - using FUSE VFS)"; -} -#endif #ifdef _WIN32 void SetThisThreadName(const QString& s) diff --git a/src/src/shared/util.h b/src/src/shared/util.h index c0dce75..fdb59d8 100644 --- a/src/src/shared/util.h +++ b/src/src/shared/util.h @@ -56,7 +56,6 @@ std::wstring ToLowerCopy(std::wstring_view text); bool CaseInsensitiveEqual(const std::wstring& lhs, const std::wstring& rhs); MOBase::Version createVersionInfo(); -QString getUsvfsVersionString(); void SetThisThreadName(const QString& s); void checkDuplicateShortcuts(const QMenu& m); diff --git a/src/src/spawn.cpp b/src/src/spawn.cpp index 6cb925e..76c1787 100644 --- a/src/src/spawn.cpp +++ b/src/src/spawn.cpp @@ -40,7 +40,6 @@ along with Mod Organizer. If not, see . #include "envwindows.h" #include "shared/windows_error.h" #include -#include #else #include #include diff --git a/src/src/usvfsconnector.cpp b/src/src/usvfsconnector.cpp deleted file mode 100644 index 83c1af1..0000000 --- a/src/src/usvfsconnector.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* -Copyright (C) 2015 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#include "usvfsconnector.h" -#include "envmodule.h" -#include "organizercore.h" -#include "settings.h" -#include "shared/util.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char SHMID[] = "mod_organizer_instance"; -using namespace MOBase; - -std::string to_hex(void* bufferIn, size_t bufferSize) -{ - unsigned char* buffer = static_cast(bufferIn); - std::ostringstream temp; - temp << std::hex; - for (size_t i = 0; i < bufferSize; ++i) { - temp << std::setfill('0') << std::setw(2) << (unsigned int)buffer[i]; - if ((i % 16) == 15) { - temp << "\n"; - } else { - temp << " "; - } - } - return temp.str(); -} - -LogWorker::LogWorker() - : m_Buffer(1024, '\0'), m_QuitRequested(false), - m_LogFile( - qApp->property("dataPath").toString() + - QString("/logs/usvfs-%1.log") - .arg(QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd_hh-mm-ss"))) -{ - m_LogFile.open(QIODevice::WriteOnly); - log::debug("usvfs log messages are written to {}", m_LogFile.fileName()); -} - -LogWorker::~LogWorker() {} - -void LogWorker::process() -{ - MOShared::SetThisThreadName("LogWorker"); - - int noLogCycles = 0; - while (!m_QuitRequested) { - if (usvfsGetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) { - m_LogFile.write(m_Buffer.c_str()); - m_LogFile.write("\n"); - m_LogFile.flush(); - noLogCycles = 0; - } else { - QThread::msleep(std::min(40, noLogCycles) * 5); - ++noLogCycles; - } - } - emit finished(); -} - -void LogWorker::exit() -{ - m_QuitRequested = true; -} - -LogLevel toUsvfsLogLevel(log::Levels level) -{ - switch (level) { - case log::Info: - return LogLevel::Info; - case log::Warning: - return LogLevel::Warning; - case log::Error: - return LogLevel::Error; - case log::Debug: // fall-through - default: - return LogLevel::Debug; - } -} - -CrashDumpsType toUsvfsCrashDumpsType(env::CoreDumpTypes type) -{ - switch (type) { - case env::CoreDumpTypes::None: - return CrashDumpsType::None; - - case env::CoreDumpTypes::Data: - return CrashDumpsType::Data; - - case env::CoreDumpTypes::Full: - return CrashDumpsType::Full; - - case env::CoreDumpTypes::Mini: - default: - return CrashDumpsType::Mini; - } -} - -UsvfsConnector::UsvfsConnector() -{ - using namespace std::chrono; - - const auto& s = Settings::instance(); - - const LogLevel logLevel = toUsvfsLogLevel(s.diagnostics().logLevel()); - const auto dumpType = toUsvfsCrashDumpsType(s.diagnostics().coreDumpType()); - const auto delay = duration_cast(s.diagnostics().spawnDelay()); - std::string dumpPath = - MOShared::ToString(OrganizerCore::getGlobalCoreDumpPath(), true); - - usvfsParameters* params = usvfsCreateParameters(); - - usvfsSetInstanceName(params, SHMID); - usvfsSetDebugMode(params, false); - usvfsSetLogLevel(params, logLevel); - usvfsSetCrashDumpType(params, dumpType); - usvfsSetCrashDumpPath(params, dumpPath.c_str()); - usvfsSetProcessDelay(params, delay.count()); - - usvfsInitLogging(false); - - log::debug("initializing usvfs:\n" - " . instance: {}\n" - " . log: {}\n" - " . dump: {} ({})", - SHMID, usvfsLogLevelToString(logLevel), dumpPath.c_str(), - usvfsCrashDumpTypeToString(dumpType)); - - usvfsCreateVFS(params); - usvfsFreeParameters(params); - - usvfsClearExecutableBlacklist(); - for (auto exec : s.executablesBlacklist().split(";")) { - std::wstring buf = exec.toStdWString(); - usvfsBlacklistExecutable(buf.data()); - } - - usvfsClearSkipFileSuffixes(); - for (auto& suffix : s.skipFileSuffixes()) { - if (suffix.isEmpty()) { - continue; - } - std::wstring buf = suffix.toStdWString(); - usvfsAddSkipFileSuffix(buf.data()); - } - - usvfsClearSkipDirectories(); - for (auto& dir : s.skipDirectories()) { - std::wstring buf = dir.toStdWString(); - usvfsAddSkipDirectory(buf.data()); - } - - usvfsClearLibraryForceLoads(); - - m_LogWorker.moveToThread(&m_WorkerThread); - - connect(&m_WorkerThread, SIGNAL(started()), &m_LogWorker, SLOT(process())); - connect(&m_LogWorker, SIGNAL(finished()), &m_WorkerThread, SLOT(quit())); - - m_WorkerThread.start(QThread::LowestPriority); -} - -UsvfsConnector::~UsvfsConnector() -{ - usvfsDisconnectVFS(); - m_LogWorker.exit(); - m_WorkerThread.quit(); - m_WorkerThread.wait(); -} - -void UsvfsConnector::updateMapping(const MappingType& mapping) -{ - const auto start = std::chrono::high_resolution_clock::now(); - - QProgressDialog progress(qApp->activeWindow()); - progress.setLabelText(tr("Preparing vfs")); - progress.setMaximum(static_cast(mapping.size())); - progress.show(); - - int value = 0; - int files = 0; - int dirs = 0; - - log::debug("Updating VFS mappings..."); - - usvfsClearVirtualMappings(); - - for (auto map : mapping) { - if (progress.wasCanceled()) { - usvfsClearVirtualMappings(); - throw UsvfsConnectorException("VFS mapping canceled by user"); - } - progress.setValue(value++); - if (value % 10 == 0) { - QCoreApplication::processEvents(); - } - - if (map.isDirectory) { - usvfsVirtualLinkDirectoryStatic( - map.source.toStdWString().c_str(), map.destination.toStdWString().c_str(), - (map.createTarget ? LINKFLAG_CREATETARGET : 0) | LINKFLAG_RECURSIVE); - ++dirs; - } else { - usvfsVirtualLinkFile(map.source.toStdWString().c_str(), - map.destination.toStdWString().c_str(), 0); - ++files; - } - } - - const auto end = std::chrono::high_resolution_clock::now(); - const auto time = std::chrono::duration_cast(end - start); - - log::debug("VFS mappings updated, linked {} dirs and {} files in {}ms", dirs, files, - time.count()); -} - -void UsvfsConnector::updateParams(MOBase::log::Levels logLevel, - env::CoreDumpTypes coreDumpType, - const QString& crashDumpsPath, - std::chrono::seconds spawnDelay, - QString executableBlacklist, - const QStringList& skipFileSuffixes, - const QStringList& skipDirectories) -{ - using namespace std::chrono; - - usvfsParameters* p = usvfsCreateParameters(); - - usvfsSetDebugMode(p, FALSE); - usvfsSetLogLevel(p, toUsvfsLogLevel(logLevel)); - usvfsSetCrashDumpType(p, toUsvfsCrashDumpsType(coreDumpType)); - usvfsSetCrashDumpPath(p, crashDumpsPath.toStdString().c_str()); - usvfsSetProcessDelay(p, duration_cast(spawnDelay).count()); - - usvfsUpdateParameters(p); - usvfsFreeParameters(p); - - usvfsClearExecutableBlacklist(); - for (auto exec : executableBlacklist.split(";")) { - std::wstring buf = exec.toStdWString(); - usvfsBlacklistExecutable(buf.data()); - } - - usvfsClearSkipFileSuffixes(); - for (auto& suffix : skipFileSuffixes) { - if (suffix.isEmpty()) { - continue; - } - std::wstring buf = suffix.toStdWString(); - usvfsAddSkipFileSuffix(buf.data()); - } - - usvfsClearSkipDirectories(); - for (auto& dir : skipDirectories) { - std::wstring buf = dir.toStdWString(); - usvfsAddSkipDirectory(buf.data()); - } -} - -void UsvfsConnector::updateForcedLibraries( - const QList& forcedLibraries) -{ - usvfsClearLibraryForceLoads(); - for (auto setting : forcedLibraries) { - if (setting.enabled()) { - usvfsForceLoadLibrary(setting.process().toStdWString().data(), - setting.library().toStdWString().data()); - } - } -} - -std::vector getRunningUSVFSProcesses() -{ - std::vector pids; - - { - size_t count = 0; - DWORD* buffer = nullptr; - if (!::usvfsGetVFSProcessList2(&count, &buffer)) { - log::error("failed to get usvfs process list"); - return {}; - } - - if (buffer) { - pids.assign(buffer, buffer + count); - std::free(buffer); - } - } - - const auto thisPid = GetCurrentProcessId(); - std::vector v; - - const auto rights = - PROCESS_QUERY_LIMITED_INFORMATION | // exit code, image name, etc. - SYNCHRONIZE | // wait functions - PROCESS_SET_QUOTA | PROCESS_TERMINATE; // add to job - - for (auto&& pid : pids) { - if (pid == thisPid) { - continue; // obviously don't wait for MO process - } - - HANDLE handle = ::OpenProcess(rights, FALSE, pid); - - if (handle == INVALID_HANDLE_VALUE) { - const auto e = GetLastError(); - - log::warn("failed to open usvfs process {}: {}", pid, formatSystemMessage(e)); - - continue; - } - - v.push_back(handle); - } - - return v; -} diff --git a/src/src/usvfsconnector.h b/src/src/usvfsconnector.h deleted file mode 100644 index ce410e4..0000000 --- a/src/src/usvfsconnector.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright (C) 2015 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#ifndef USVFSCONNECTOR_H -#define USVFSCONNECTOR_H - -#include "envdump.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class LogWorker : public QThread -{ - - Q_OBJECT - -public: - LogWorker(); - ~LogWorker(); - -public slots: - - void process(); - void exit(); - -signals: - - void outputLog(const QString& message); - void finished(); - -private: - std::string m_Buffer; - bool m_QuitRequested; - QFile m_LogFile; -}; - -class UsvfsConnectorException : public std::exception -{ - -public: - UsvfsConnectorException(const QString& text) - : std::exception(), m_Message(text.toLocal8Bit()) - {} - - virtual const char* what() const throw() { return m_Message.constData(); } - -private: - QByteArray m_Message; -}; - -class UsvfsConnector : public QObject -{ - - Q_OBJECT - -public: - UsvfsConnector(); - ~UsvfsConnector(); - - void updateMapping(const MappingType& mapping); - - void updateParams(MOBase::log::Levels logLevel, env::CoreDumpTypes coreDumpType, - const QString& crashDumpsPath, std::chrono::seconds spawnDelay, - QString executableBlacklist, const QStringList& skipFileSuffixes, - const QStringList& skipDirectories); - - void updateForcedLibraries( - const QList& forcedLibraries); - -private: - LogWorker m_LogWorker; - QThread m_WorkerThread; -}; - -CrashDumpsType crashDumpsType(int type); - -std::vector getRunningUSVFSProcesses(); - -#endif // USVFSCONNECTOR_H -- cgit v1.3.1