MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / getUniqueResourceName

Function getUniqueResourceName

launcher/FileSystem.cpp:1697–1722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1695#endif
1696
1697QString getUniqueResourceName(const QString& filePath)
1698{
1699 auto newFileName = filePath;
1700 if (!newFileName.endsWith(".disabled")) {
1701 return newFileName; // prioritize enabled mods
1702 }
1703 newFileName.chop(9);
1704 if (!QFile::exists(newFileName)) {
1705 return filePath;
1706 }
1707 QFileInfo fileInfo(filePath);
1708 auto baseName = fileInfo.completeBaseName();
1709 auto path = fileInfo.absolutePath();
1710
1711 int counter = 1;
1712 do {
1713 if (counter == 1) {
1714 newFileName = FS::PathCombine(path, baseName + ".duplicate");
1715 } else {
1716 newFileName = FS::PathCombine(path, baseName + ".duplicate" + QString::number(counter));
1717 }
1718 counter++;
1719 } while (QFile::exists(newFileName));
1720
1721 return newFileName;
1722}
1723} // namespace FS

Callers 3

enableMethod · 0.85
executeTaskMethod · 0.85
executeTaskMethod · 0.85

Calls 1

PathCombineFunction · 0.85

Tested by

no test coverage detected