| 44 | } |
| 45 | |
| 46 | QString SessionFileRegistry::uniqueFreePath(const QString &desiredPath) const |
| 47 | { |
| 48 | if (desiredPath.isEmpty() || !m_lockedPaths.contains(desiredPath)) { |
| 49 | return desiredPath; |
| 50 | } |
| 51 | |
| 52 | const QFileInfo info(desiredPath); |
| 53 | const QString dir = info.path(); |
| 54 | const QString base = info.completeBaseName(); |
| 55 | const QString suffix = info.suffix(); |
| 56 | |
| 57 | for (int counter = 2;; ++counter) { |
| 58 | QString candidate = dir + '/' + base + '_' + QString::number(counter); |
| 59 | if (!suffix.isEmpty()) { |
| 60 | candidate += '.' + suffix; |
| 61 | } |
| 62 | if (!m_lockedPaths.contains(candidate)) { |
| 63 | return candidate; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | } // namespace QodeAssist::Chat |
no test coverage detected