feat: implement lax filename match in BlockedModsDialog

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-11-23 13:54:50 +01:00
parent d61323aa6d
commit e08d97825d
No known key found for this signature in database
GPG Key ID: C10411294912A422

View File

@ -236,14 +236,24 @@ void BlockedModsDialog::checkMatchHash(QString hash, QString path)
/// @return boolean: did the path match the name of a blocked mod?
bool BlockedModsDialog::checkValidPath(QString path)
{
QFileInfo file = QFileInfo(path);
QString filename = file.fileName();
const QFileInfo file = QFileInfo(path);
const QString filename = file.fileName();
QString laxFilename(filename);
laxFilename.replace('+', ' ');
auto compare = [](QString fsfilename, QString metadataFilename) {
return metadataFilename.compare(fsfilename, Qt::CaseInsensitive) == 0;
};
for (auto& mod : m_mods) {
if (mod.name.compare(filename, Qt::CaseInsensitive) == 0) {
if (compare(filename, mod.name)) {
qDebug() << "[Blocked Mods Dialog] Name match found:" << mod.name << "| From path:" << path;
return true;
}
if (compare(laxFilename, mod.name)) {
qDebug() << "[Blocked Mods Dialog] Lax name match found:" << mod.name << "| From path:" << path;
return true;
}
}
return false;