aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSulfurNitride <lukew19@proton.me>2026-06-23 16:10:53 -0500
committerSulfurNitride <lukew19@proton.me>2026-06-23 16:10:53 -0500
commit08939441e50e52c685c531a16704fb8f6e1138bd (patch)
tree962932046d46d4fd33953c073e3eb95aeb768096 /libs
parentf415cfae26153b0853466316c0d8d1738e029976 (diff)
Fix FOMOD casing and VFS test coverage
Diffstat (limited to 'libs')
-rw-r--r--libs/installer_fomod/src/fomodinstallerdialog.cpp21
-rw-r--r--libs/installer_fomod/src/installerfomod.cpp15
2 files changed, 28 insertions, 8 deletions
diff --git a/libs/installer_fomod/src/fomodinstallerdialog.cpp b/libs/installer_fomod/src/fomodinstallerdialog.cpp
index 7c27726..9e3eaaa 100644
--- a/libs/installer_fomod/src/fomodinstallerdialog.cpp
+++ b/libs/installer_fomod/src/fomodinstallerdialog.cpp
@@ -166,6 +166,21 @@ static QString tempArchivePath(const QString& archivePath)
return QDir(QDir::tempPath()).filePath(normalizeArchivePath(archivePath));
}
+static QString fomodFilePath(const QString& fomodPath, const QString& fomodDirName,
+ const QString& fileName)
+{
+ const QString directory = tempArchivePath(joinArchivePath(fomodPath, fomodDirName));
+ const QDir dir(directory);
+
+ for (const QString& candidate : dir.entryList(QDir::Files | QDir::NoDotAndDotDot)) {
+ if (candidate.compare(fileName, Qt::CaseInsensitive) == 0) {
+ return dir.filePath(candidate);
+ }
+ }
+
+ return dir.filePath(fileName);
+}
+
QByteArray skipXmlHeader(QIODevice& file)
{
static const unsigned char UTF16LE_BOM[] = {0xFF, 0xFE};
@@ -265,8 +280,7 @@ void FomodInstallerDialog::readXml(QFile& file,
void FomodInstallerDialog::readInfoXml()
{
- QFile file(tempArchivePath(joinArchivePath(
- joinArchivePath(m_FomodPath, m_FomodDirName), "info.xml")));
+ QFile file(fomodFilePath(m_FomodPath, m_FomodDirName, "info.xml"));
// We don't need a info.xml file, so we just return if we cannot open it:
if (!file.open(QIODevice::ReadOnly)) {
@@ -277,8 +291,7 @@ void FomodInstallerDialog::readInfoXml()
void FomodInstallerDialog::readModuleConfigXml()
{
- QFile file(tempArchivePath(joinArchivePath(
- joinArchivePath(m_FomodPath, m_FomodDirName), "ModuleConfig.xml")));
+ QFile file(fomodFilePath(m_FomodPath, m_FomodDirName, "ModuleConfig.xml"));
if (!file.open(QIODevice::ReadOnly)) {
throw Exception(tr("%1 missing.").arg(file.fileName()));
}
diff --git a/libs/installer_fomod/src/installerfomod.cpp b/libs/installer_fomod/src/installerfomod.cpp
index e526610..9d9690a 100644
--- a/libs/installer_fomod/src/installerfomod.cpp
+++ b/libs/installer_fomod/src/installerfomod.cpp
@@ -1,5 +1,7 @@
#include "installerfomod.h"
+#include <algorithm>
+
#include <QImageReader>
#include <QStringList>
#include <QtPlugin>
@@ -115,10 +117,14 @@ InstallerFomod::findFomodDirectory(std::shared_ptr<const IFileTree> tree) const
bool InstallerFomod::isArchiveSupported(std::shared_ptr<const IFileTree> tree) const
{
tree = findFomodDirectory(tree);
- if (tree != nullptr) {
- return tree->exists("ModuleConfig.xml", FileTreeEntry::FILE);
+ if (tree == nullptr) {
+ return false;
}
- return false;
+
+ return std::any_of(tree->begin(), tree->end(), [](const auto& entry) {
+ return entry->isFile() &&
+ entry->name().compare("ModuleConfig.xml", Qt::CaseInsensitive) == 0;
+ });
}
void InstallerFomod::appendImageFiles(
@@ -145,7 +151,8 @@ InstallerFomod::buildFomodTree(std::shared_ptr<const IFileTree> tree) const
for (auto entry : *fomodTree) {
if (entry->isFile() &&
- (entry->compare("info.xml") == 0 || entry->compare("ModuleConfig.xml") == 0)) {
+ (entry->name().compare("info.xml", Qt::CaseInsensitive) == 0 ||
+ entry->name().compare("ModuleConfig.xml", Qt::CaseInsensitive) == 0)) {
entries.push_back(entry);
}
}