| 1695 | #endif |
| 1696 | |
| 1697 | QString 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 |
no test coverage detected