Skip to content

Commit

Permalink
QFile: code tidies
Browse files Browse the repository at this point in the history
There's no need of converting a QFlags to int in openExternalFile's
signature; just use the flag.

Also, avoid an implicit QFlags->bool conversion by using testAnyFlag.

Change-Id: Ia2d560bce235c842745d8a6a5fb5d8ac0851fc47
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
dangelog committed May 17, 2021
1 parent af38f72 commit 536a4ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/corelib/io/qfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ QFilePrivate::~QFilePrivate()
}

bool
QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleFlags)
QFilePrivate::openExternalFile(QIODevice::OpenMode flags, int fd, QFile::FileHandleFlags handleFlags)
{
#ifdef QT_NO_FSFILEENGINE
Q_UNUSED(flags);
Expand All @@ -88,12 +88,12 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF
auto fs = std::make_unique<QFSFileEngine>();
auto fe = fs.get();
fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fd, handleFlags);
return fe->open(flags, fd, handleFlags);
#endif
}

bool
QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handleFlags)
QFilePrivate::openExternalFile(QIODevice::OpenMode flags, FILE *fh, QFile::FileHandleFlags handleFlags)
{
#ifdef QT_NO_FSFILEENGINE
Q_UNUSED(flags);
Expand All @@ -103,7 +103,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl
auto fs = std::make_unique<QFSFileEngine>();
auto fe = fs.get();
fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fh, handleFlags);
return fe->open(flags, fh, handleFlags);
#endif
}

Expand Down Expand Up @@ -377,8 +377,8 @@ QFile::exists() const
{
Q_D(const QFile);
// 0x1000000 = QAbstractFileEngine::Refresh, forcing an update
return (d->engine()->fileFlags(QAbstractFileEngine::FlagsMask
| QAbstractFileEngine::Refresh) & QAbstractFileEngine::ExistsFlag);
return d->engine()->fileFlags(QAbstractFileEngine::FlagsMask
| QAbstractFileEngine::Refresh).testAnyFlag(QAbstractFileEngine::ExistsFlag);
}

/*!
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/io/qfile_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class QFilePrivate : public QFileDevicePrivate
QFilePrivate();
~QFilePrivate();

bool openExternalFile(int flags, int fd, QFile::FileHandleFlags handleFlags);
bool openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handleFlags);
bool openExternalFile(QIODevice::OpenMode flags, int fd, QFile::FileHandleFlags handleFlags);
bool openExternalFile(QIODevice::OpenMode flags, FILE *fh, QFile::FileHandleFlags handleFlags);

QAbstractFileEngine *engine() const override;

Expand Down

0 comments on commit 536a4ab

Please sign in to comment.