From 05aa96d20ca726908a7d8b1943f86f0c4e11bf18 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Wed, 17 Jun 2026 01:46:09 -0500 Subject: Prepare Nexus-safe release cleanup --- libs/installer_fomod_plus/scanner/archiveparser.h | 97 ----------------------- 1 file changed, 97 deletions(-) delete mode 100644 libs/installer_fomod_plus/scanner/archiveparser.h (limited to 'libs/installer_fomod_plus/scanner/archiveparser.h') diff --git a/libs/installer_fomod_plus/scanner/archiveparser.h b/libs/installer_fomod_plus/scanner/archiveparser.h deleted file mode 100644 index 8819a84..0000000 --- a/libs/installer_fomod_plus/scanner/archiveparser.h +++ /dev/null @@ -1,97 +0,0 @@ -#pragma once -#include "stringutil.h" - -#include -#include -#include -#include -#include - -inline std::ostream& operator<<(std::ostream& os, const Archive::Error& error) -{ - switch (error) { - case Archive::Error::ERROR_NONE: - os << "No error"; - break; - case Archive::Error::ERROR_ARCHIVE_NOT_FOUND: - os << "File not found"; - break; - case Archive::Error::ERROR_FAILED_TO_OPEN_ARCHIVE: - os << "Failed to open file"; - break; - case Archive::Error::ERROR_INVALID_ARCHIVE_FORMAT: - os << "Invalid archive format"; - break; - default: - os << "Unknown error??"; - } - return os; -} - -inline bool hasFomodFiles(const std::vector& files) -{ - bool hasModuleXml = false; - bool hasInfoXml = false; - - for (const auto* file : files) { - if (endsWithCaseInsensitive(file->getArchiveFilePath(), StringConstants::FomodFiles::W_MODULE_CONFIG.data())) { - hasModuleXml = true; - } - if (endsWithCaseInsensitive(file->getArchiveFilePath(), StringConstants::FomodFiles::W_INFO_XML.data())) { - hasInfoXml = true; - } - } - return hasModuleXml && hasInfoXml; -} - -/* This class can do the following: - * 1.) Detects if an archive has FOMOD files in it (without extracting) - * - This is used by the FOMOD scanner to set content flags - * - * 2.) It may support extracting ESPs and FOMODs, but this might be better served - * by a separate class. Maybe it could return a ModuleConfiguration to use like - * the installer. - */ - -enum class ScanResult { - HAS_FOMOD, - NO_FOMOD, - NO_ARCHIVE -}; - -class ArchiveParser { -public: - static ScanResult scanForFomodFiles(const QString& downloadsPath, const QString& installationFilePath, - const QString& modName) - { - if (installationFilePath.isEmpty()) { - return ScanResult::NO_ARCHIVE; - } - const auto qualifiedInstallerPath = QDir(installationFilePath).isAbsolute() - ? installationFilePath - : downloadsPath + "/" + installationFilePath; - - const auto archive = CreateArchive(); - - if (!archive->isValid()) { - logErrorForMod(modName, "Failed to load the archive module ", archive); - return ScanResult::NO_ARCHIVE; - } - if (!archive->open(qualifiedInstallerPath.toStdWString(), nullptr)) { - logErrorForMod(modName, "Failed to open archive [" + qualifiedInstallerPath + "]", archive); - return ScanResult::NO_ARCHIVE; - } - - if (hasFomodFiles(archive->getFileList())) { - return ScanResult::HAS_FOMOD; - } - return ScanResult::NO_FOMOD; - } - -private: - static void logErrorForMod(const QString& modName, const QString& message, const std::unique_ptr& archive) - { - std::cerr << "[" << modName.toStdString() << "] " << message.toStdString() << " (" << archive->getLastError() << - ")" << std::endl; - } -}; \ No newline at end of file -- cgit v1.3.1