| QString | absoluteFilePath() const |
| QString | absolutePath() const |
| QString | baseName() const |
| QDateTime | birthTime(const QTimeZone &tz) const |
| QString | bundleName() const |
| QString | canonicalFilePath() const |
| QString | completeBaseName() const |
| QString | completeSuffix() const |
| bool | exists() const |
| QFileInfo | fileInfo() const |
| QString | fileName() const |
| QString | filePath() const |
| QDateTime | fileTime(QFileDevice::FileTime type, const QTimeZone &tz) const |
| bool | isDir() const |
| bool | isExecutable() const |
| bool | isFile() const |
| bool | isHidden() const |
| bool | isReadable() const |
| bool | isSymLink() const |
| bool | isWritable() const |
| QDateTime | lastModified(const QTimeZone &tz) const |
| QDateTime | lastRead(const QTimeZone &tz) const |
| QDateTime | metadataChangeTime(const QTimeZone &tz) const |
| qint64 | size() const |
| QString | suffix() const |
Dereferencing a valid QDirListing::const_iterator returns a DirEntry object.
DirEntry offers a subset of QFileInfo's API (for example, fileName(), filePath(), exists()). Internally, DirEntry only constructs a QFileInfo object if needed, that is, if the info hasn't been already fetched by other system functions. You can use DirEntry::fileInfo() to get a QFileInfo. For example:
using ItFlag = QDirListing::IteratorFlag;
for (const auto &dirEntry : QDirListing(u"/etc"_s, ItFlag::Recursive)) {
// Faster
if (dirEntry.fileName().endsWith(u".conf")) { /* ... */ }
// This works, but might be potentially slower, since it has to construct a
// QFileInfo, whereas (depending on the implementation) the fileName could
// be known already
if (dirEntry.fileInfo().fileName().endsWith(u".conf")) { /* ... */ }
}
using ItFlag = QDirListing::IteratorFlag;
for (const auto &dirEntry : QDirListing(u"/etc"_s, ItFlag::Recursive)) {
// Both approaches are the same, because DirEntry will have to construct
// a QFileInfo to get this info (for example, by calling system stat())
if (dirEntry.size() >= 4'000 /* 4KB */) { /* ...*/ }
if (dirEntry.fileInfo().size() >= 4'000 /* 4KB */) { /* ... */ }
}See the QFileInfo methods with the same names.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.9/qdirlisting-direntry.html