Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into feature/java-downloader

This commit is contained in:
Trial97
2024-07-22 08:57:31 +03:00
85 changed files with 877 additions and 345 deletions

View File

@ -1694,4 +1694,30 @@ QString getPathNameInLocal8bit(const QString& file)
}
#endif
QString getUniqueResourceName(const QString& filePath)
{
auto newFileName = filePath;
if (!newFileName.endsWith(".disabled")) {
return newFileName; // prioritize enabled mods
}
newFileName.chop(9);
if (!QFile::exists(newFileName)) {
return filePath;
}
QFileInfo fileInfo(filePath);
auto baseName = fileInfo.completeBaseName();
auto path = fileInfo.absolutePath();
int counter = 1;
do {
if (counter == 1) {
newFileName = FS::PathCombine(path, baseName + ".duplicate");
} else {
newFileName = FS::PathCombine(path, baseName + ".duplicate" + QString::number(counter));
}
counter++;
} while (QFile::exists(newFileName));
return newFileName;
}
} // namespace FS