From 7ee008e150bc5bcf76082d726f719ee0fdfda982 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Wed, 11 Feb 2026 02:37:39 -0600 Subject: Fluorine Manager: full Linux port of Mod Organizer 2 Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 --- libs/uibase/src/filesystemutilities.cpp | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 libs/uibase/src/filesystemutilities.cpp (limited to 'libs/uibase/src/filesystemutilities.cpp') diff --git a/libs/uibase/src/filesystemutilities.cpp b/libs/uibase/src/filesystemutilities.cpp new file mode 100644 index 0000000..6a01324 --- /dev/null +++ b/libs/uibase/src/filesystemutilities.cpp @@ -0,0 +1,68 @@ +#include + +#include +#include + +namespace MOBase +{ + +bool fixDirectoryName(QString& name) +{ + QString temp = name.simplified(); + while (temp.endsWith('.')) + temp.chop(1); + + temp.replace(QRegularExpression(R"([<>:"/\\|?*])"), ""); + static QString invalidNames[] = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", + "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", + "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", + "LPT6", "LPT7", "LPT8", "LPT9"}; + for (unsigned int i = 0; i < sizeof(invalidNames) / sizeof(QString); ++i) { + if (temp == invalidNames[i]) { + temp = ""; + break; + } + } + + temp = temp.simplified(); + + if (temp.length() >= 1) { + name = temp; + return true; + } else { + return false; + } +} + +QString sanitizeFileName(const QString& name, const QString& replacement) +{ + QString new_name = name; + + // Remove characters not allowed by Windows + new_name.replace(QRegularExpression("[\\x{00}-\\x{1f}\\\\/:\\*\\?\"<>|]"), + replacement); + + // Don't end with a period or a space + // Don't be "." or ".." + new_name.remove(QRegularExpression("[\\. ]*$")); + + // Recurse until stuff stops changing + if (new_name != name) { + return sanitizeFileName(new_name); + } + return new_name; +} + +bool validFileName(const QString& name) +{ + if (name.isEmpty()) { + return false; + } + if (name == "." || name == "..") { + return false; + } + + return (name == sanitizeFileName(name)); +} + +} // namespace MOBase -- cgit v1.3.1