mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +01:00
parent
800cc14dcd
commit
ffcf137967
|
@ -223,22 +223,23 @@ QString QzTools::ensureUniqueFilename(const QString &name, const QString &append
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString tmpFileName = name;
|
QString tmpPath = name;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (QFile::exists(tmpFileName)) {
|
while (QFile::exists(tmpPath)) {
|
||||||
tmpFileName = name;
|
tmpPath = name;
|
||||||
int index = tmpFileName.lastIndexOf(QLatin1Char('.'));
|
int fileNameIndex = tmpPath.lastIndexOf(QL1C('/'));
|
||||||
|
int index = tmpPath.lastIndexOf(QL1C('.'), fileNameIndex);
|
||||||
|
|
||||||
QString appendString = appendFormat.arg(i);
|
QString appendString = appendFormat.arg(i);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
tmpFileName.append(appendString);
|
tmpPath.append(appendString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tmpFileName = tmpFileName.left(index) + appendString + tmpFileName.mid(index);
|
tmpPath = tmpPath.left(index) + appendString + tmpPath.mid(index);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return tmpFileName;
|
return tmpPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QzTools::getFileNameFromUrl(const QUrl &url)
|
QString QzTools::getFileNameFromUrl(const QUrl &url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user