Replace string manipulation in favour of QFileInfo

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2023-07-09 12:08:15 +01:00
parent 8ae67b84db
commit 6e2fcc9e11

View File

@ -301,10 +301,10 @@ QByteArray ModrinthPackExportTask::generateIndex()
const ResolvedFile& value = iterator.value(); const ResolvedFile& value = iterator.value();
// detect disabled mod // detect disabled mod
QString disabledSuffix = ".disabled"; const QFileInfo pathInfo(path);
if (path.endsWith(disabledSuffix)) { if (pathInfo.suffix() == "disabled") {
// rename it // rename it
path = path.left(path.length() - disabledSuffix.length()); path = pathInfo.dir().filePath(pathInfo.completeBaseName());
// ...and make it optional // ...and make it optional
QJsonObject env; QJsonObject env;
env["client"] = "optional"; env["client"] = "optional";