mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into feature/java-downloader
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user