aboutsummaryrefslogtreecommitdiff
path: root/libs/bsapacker/src/ArchiveNameService.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/bsapacker/src/ArchiveNameService.cpp
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 <noreply@anthropic.com>
Diffstat (limited to 'libs/bsapacker/src/ArchiveNameService.cpp')
-rw-r--r--libs/bsapacker/src/ArchiveNameService.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/libs/bsapacker/src/ArchiveNameService.cpp b/libs/bsapacker/src/ArchiveNameService.cpp
new file mode 100644
index 0000000..9cea91b
--- /dev/null
+++ b/libs/bsapacker/src/ArchiveNameService.cpp
@@ -0,0 +1,75 @@
+#include "ArchiveNameService.h"
+
+#include "NexusId.h"
+
+#include <QFileInfo>
+
+namespace BsaPacker
+{
+ ArchiveNameService::ArchiveNameService(const IModContext* modContext)
+ : m_ModContext(modContext)
+ {
+ }
+
+ QString ArchiveNameService::GetFileExtension() const
+ {
+ switch (this->m_ModContext->GetNexusId()) {
+ case NexusId::Morrowind:
+ case NexusId::Oblivion:
+ case NexusId::Fallout3:
+ case NexusId::NewVegas:
+ case NexusId::Skyrim:
+ case NexusId::SkyrimSE:
+ case NexusId::Enderal:
+ case NexusId::EnderalSE:
+ return QStringLiteral(".bsa");
+ case NexusId::Fallout4:
+ case NexusId::Starfield:
+ return QStringLiteral(".ba2");
+ default:
+ return QString();
+ }
+ }
+
+ QString ArchiveNameService::GetArchiveFullPath(const bsa_archive_type_e type, const IModDto* modDto) const
+ {
+ const QString& pathNoExt(QDir::toNativeSeparators(modDto->Directory() + '/' + modDto->ArchiveName() + this->Infix(type)));
+ const QString& suffix = this->Suffix(pathNoExt);
+ return QDir::toNativeSeparators(pathNoExt + suffix + this->GetFileExtension());
+ }
+
+ QString ArchiveNameService::Infix(const bsa_archive_type_e type) const
+ {
+ switch (type) {
+ case baFO4:
+ case baSF:
+ return QStringLiteral(" - Main");
+ case baSFdds:
+ case baFO4dds:
+ return QStringLiteral(" - Textures");
+ case baTES3:
+ case baTES4:
+ case baFO3:
+ case baSSE:
+ case baNone:
+ default:
+ return QString();
+ };
+ }
+
+ // gets the number to append when there are multiple archives
+ // a way to avoid overwriting any existing files
+ QString ArchiveNameService::Suffix(const QString& pathNoExt) const {
+ int archiveIndex = 0;
+ const QString& fileExt = this->GetFileExtension();
+ QFileInfo fileInfo(pathNoExt + fileExt);
+ while (fileInfo.exists()) {
+ ++archiveIndex;
+ fileInfo.setFile(pathNoExt + QString::number(archiveIndex) + fileExt);
+ }
+ if (archiveIndex != 0) {
+ return QString::number(archiveIndex);
+ }
+ return QString();
+ }
+}