mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Use static QFileInfo::exists
This commit is contained in:
parent
9a73c99935
commit
508762cd2c
4 changed files with 8 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue