MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / getUniqueResourceName

Function getUniqueResourceName

launcher/FileSystem.cpp:1688–1713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1686#endif
1687
1688QString getUniqueResourceName(const QString& filePath)
1689{
1690 auto newFileName = filePath;
1691 if (!newFileName.endsWith(".disabled")) {
1692 return newFileName; // prioritize enabled mods
1693 }
1694 newFileName.chop(9);
1695 if (!QFile::exists(newFileName)) {
1696 return filePath;
1697 }
1698 QFileInfo fileInfo(filePath);
1699 auto baseName = fileInfo.completeBaseName();
1700 auto path = fileInfo.absolutePath();
1701
1702 int counter = 1;
1703 do {
1704 if (counter == 1) {
1705 newFileName = FS::PathCombine(path, baseName + ".duplicate");
1706 } else {
1707 newFileName = FS::PathCombine(path, baseName + ".duplicate" + QString::number(counter));
1708 }
1709 counter++;
1710 } while (QFile::exists(newFileName));
1711
1712 return newFileName;
1713}
1714bool removeFiles(QStringList listFile)
1715{
1716 bool ret = true;

Callers 2

enableMethod · 0.85
executeTaskMethod · 0.85

Calls 1

PathCombineFunction · 0.85

Tested by

no test coverage detected