aboutsummaryrefslogtreecommitdiff
path: root/libs/bsapacker/src/qlibbsarch/BSArchiveAuto.h
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/qlibbsarch/BSArchiveAuto.h
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/qlibbsarch/BSArchiveAuto.h')
-rw-r--r--libs/bsapacker/src/qlibbsarch/BSArchiveAuto.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/libs/bsapacker/src/qlibbsarch/BSArchiveAuto.h b/libs/bsapacker/src/qlibbsarch/BSArchiveAuto.h
new file mode 100644
index 0000000..d632fa4
--- /dev/null
+++ b/libs/bsapacker/src/qlibbsarch/BSArchiveAuto.h
@@ -0,0 +1,91 @@
+#pragma once
+
+#include "BSArchive.h"
+#include "BSArchiveEntries.h"
+#include <QMap>
+
+/*!
+ * \brief A convenience class for BSArchive and BSArchiveEntries. Its performance is worse than using these
+ * two classes separately, but it removes the need to manually handle the BSArchiveEntries.
+ */
+class BSArchiveAuto
+{
+public:
+ /*!
+ * \brief Constructor
+ * \param rootDirectory The root directory of the BSA. This directory is the one containing folders such as textures and meshes.
+ */
+ BSArchiveAuto(const QString &_rootDirectory);
+ /*!
+ * \brief Opens an existing archive
+ * \param archivePath The path of the archive
+ */
+ void open(const QString &archivePath);
+ /*!
+ * \brief Creates a BSA in memory
+ * \param archiveName The BSA name
+ * \param type The BSA type
+ */
+ void create(const QString& archiveName, const bsa_archive_type_e& type);
+ /*!
+ * \brief Adds a file from the disk to the BSA. Also adds it to the BSA entries.
+ * \param rootDir The root directory of the file.
+ * \param filename The complete path to the file.
+ */
+ void addFileFromDiskRoot(const QString& filename);
+ /*!
+ * \brief Adds files from the disk to the BSA. Also adds them to the BSA entries.
+ * \param rootDir The root directory of the file. This directory is the one containing folders such as textures and meshes.
+ * \param files A list containing the complete paths to the files.
+ */
+ void addFileFromDiskRoot(const QStringList& files);
+ /*!
+ * \brief Adds file from the memory to the BSA. Also adds it to the BSA entries.
+ * \param filename The name of the file. It connot be a full path, and has to be a relative path.
+ * \param data The file bytes data.
+ */
+ void addFileFromMemory(const QString& filename, const QByteArray& data);
+ /*!
+ * \brief Adds a file from the disk to the BSA. Also adds it to the BSA entries.
+ * \param saveAs The path of the file in the BSA
+ * \param diskPath The path of the file on disk
+ */
+ void addFileFromDisk(const QString& saveAs, const QString& diskPath);
+ /*!
+ * \brief Adds files from the disk to the BSA. Also adds it to the BSA entries.
+ * \param map A map containing "save as" path as keys and disk path as values
+ */
+ void addFileFromDisk(const QMap<QString, QString>& map);
+ /*!
+ * \brief Extracts all files from the BSA to the destination.
+ * \param destinationDirectory The directory where all files will be extracted.
+ * \param overwriteExistingFiles Whether files in archive will overwrite existing loose files or not
+ */
+ void extractAll(const QString &destinationDirectory, const bool &overwriteExistingFiles);
+ /*!
+ * \brief Saves the archive to the disk
+ */
+ void save();
+
+ void setShareData(const bool state);
+ void setCompressed(const bool state);
+
+ void reset();
+ /*!
+ * \brief Required in order to create FO4 DDS archive
+ * \param fileDDSInfoProc The function that will process the DDS file
+ */
+ void setDDSCallback(bsa_file_dds_info_proc_t fileDDSInfoProc, void *context);
+
+private:
+ /*!
+ * \brief The key will store the "save as" path, while the value will hold the disk path
+ */
+ QMap<QString, QString> _filesFromDisk;
+ QStringList _filesFromDiskRoot;
+ QMap<QString, QByteArray> _filesfromMemory;
+ QDir _rootDirectory;
+
+ BSArchive _archive;
+ BSArchiveEntries _entries;
+};