diff options
| author | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-11 02:37:39 -0600 |
|---|---|---|
| committer | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-11 02:37:39 -0600 |
| commit | 7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch) | |
| tree | 27fb39be241fdb5ac2734c574de678977d1856d0 /libs/bsapacker/src/ArchiveBuilderHelper.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/ArchiveBuilderHelper.cpp')
| -rw-r--r-- | libs/bsapacker/src/ArchiveBuilderHelper.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/libs/bsapacker/src/ArchiveBuilderHelper.cpp b/libs/bsapacker/src/ArchiveBuilderHelper.cpp new file mode 100644 index 0000000..c5c956b --- /dev/null +++ b/libs/bsapacker/src/ArchiveBuilderHelper.cpp @@ -0,0 +1,77 @@ +#include <bsapacker/ArchiveBuilderHelper.h> + +#include <algorithm> +#include <ranges> + +#include "SettingsService.h" + +#include <QDebug> + +using std::filesystem::path; +using std::filesystem::directory_entry; +using std::filesystem::directory_iterator; +using std::filesystem::recursive_directory_iterator; + +namespace BsaPacker +{ + const std::set<std::string> ArchiveBuilderHelper::INCOMPRESSIBLE_TYPES = { ".wav", ".ogg", ".mp3" }; + + ArchiveBuilderHelper::ArchiveBuilderHelper(const ISettingsService* settingsService) + : m_SettingsService(settingsService) + { + } + uint32_t ArchiveBuilderHelper::getFileCount(const path& rootDirectory) const + { + uint32_t count = 0; + for(auto& p : recursive_directory_iterator(rootDirectory)) { + if (p.is_regular_file()) { + count++; + } + } + return count; + } + + std::vector<path::string_type> ArchiveBuilderHelper::getRootDirectoryFilenames(const path& rootDirectory) const + { + std::vector<path::string_type> filenames; + for (const auto& entry : directory_iterator(rootDirectory)) { + filenames.push_back(entry.path().filename().native()); + } + return filenames; + } + + bool ArchiveBuilderHelper::isFileIgnorable(const path& filepath, const std::vector<path::string_type>& rootDirFilenames) const + { + return this->doesPathContainFiles(filepath, rootDirFilenames) || // ignore files within mod directory + this->isExtensionBlacklisted(filepath); // ignore user blacklisted file types + } + + bool ArchiveBuilderHelper::isIncompressible(const path& filename) const + { + if (!this->m_SettingsService->GetPluginSetting(SettingsService::SETTING_COMPRESS_ARCHIVES).toBool()) { + return true; + } + + const auto& extension = filename.extension().string(); + const auto& count = ArchiveBuilderHelper::INCOMPRESSIBLE_TYPES.count(extension); + const auto& result = count > 0; + return result; + } + + bool ArchiveBuilderHelper::isExtensionBlacklisted(const path& filepath) const + { + const auto& setting = this->m_SettingsService->GetPluginSetting(SettingsService::SETTING_BLACKLISTED_FILES).toString().toStdString(); + const auto &extension = filepath.extension().string(); + const auto count = std::ranges::count( + setting | std::views::split(' '), + extension, + [](auto r) + { return std::string_view(r.data(), r.size()); }); + return count > 0; + } + + bool ArchiveBuilderHelper::doesPathContainFiles(const path& filepath, const std::vector<path::string_type>& files) const + { + return std::find(files.begin(), files.end(), filepath.filename()) != files.end(); + } +} // namespace BsaPacker |
