Use static QFileInfo::exists

This commit is contained in:
Ilya Fedin 2021-03-13 23:05:36 +04:00 committed by John Preston
parent 9a73c99935
commit 508762cd2c
4 changed files with 8 additions and 8 deletions

View file

@ -94,7 +94,7 @@ QString filedialogDefaultName(
const auto nameBase = (dir.endsWith('/') ? dir : (dir + '/'))
+ base;
name = nameBase + extension;
for (int i = 0; QFileInfo(name).exists(); ++i) {
for (int i = 0; QFileInfo::exists(name); ++i) {
name = nameBase + qsl(" (%1)").arg(i + 2) + extension;
}
}
@ -115,7 +115,7 @@ QString filedialogNextFilename(
const auto dir = directory.absolutePath();
const auto nameBase = (dir.endsWith('/') ? dir : (dir + '/')) + prefix;
auto result = nameBase + extension;
for (int i = 0; result.toLower() != cur.toLower() && QFileInfo(result).exists(); ++i) {
for (int i = 0; result.toLower() != cur.toLower() && QFileInfo::exists(result); ++i) {
result = nameBase + qsl(" (%1)").arg(i + 2) + extension;
}
return result;

View file

@ -213,7 +213,7 @@ QString FileNameUnsafe(
}
QString nameBase = path + nameStart;
name = nameBase + extension;
for (int i = 0; QFileInfo(name).exists(); ++i) {
for (int i = 0; QFileInfo::exists(name); ++i) {
name = nameBase + QString(" (%1)").arg(i + 2) + extension;
}

View file

@ -153,7 +153,7 @@ bool FileParser::readKeyValue(const char *&from, const char *end) {
}
QByteArray FileParser::ReadFile(const QString &absolutePath, const QString &relativePath) {
QFile file(QFileInfo(relativePath).exists() ? relativePath : absolutePath);
QFile file(QFileInfo::exists(relativePath) ? relativePath : absolutePath);
if (!file.open(QIODevice::ReadOnly)) {
Ui::Integration::Instance().writeLogEntry(u"Lang Error: Could not open file at '%1' ('%2')"_q.arg(relativePath, absolutePath));
return QByteArray();

View file

@ -38,15 +38,15 @@ QString ToFilePart(FileKey val) {
bool KeyAlreadyUsed(QString &name) {
name += '0';
if (QFileInfo(name).exists()) {
if (QFileInfo::exists(name)) {
return true;
}
name[name.size() - 1] = '1';
if (QFileInfo(name).exists()) {
if (QFileInfo::exists(name)) {
return true;
}
name[name.size() - 1] = 's';
if (QFileInfo(name).exists()) {
if (QFileInfo::exists(name)) {
return true;
}
return false;
@ -319,7 +319,7 @@ bool ReadFile(
// detect order of read attempts
QString toTry[2];
const auto modern = base + 's';
if (QFileInfo(modern).exists()) {
if (QFileInfo::exists(modern)) {
toTry[0] = modern;
} else {
// Legacy way.