Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QDirListing::DirEntry Class Reference

\inmodule QtCore More...

#include <qdirlisting.h>

+ Collaboration diagram for QDirListing::DirEntry:

Public Member Functions

Q_CORE_EXPORT QString fileName () const
 
Q_CORE_EXPORT QString baseName () const
 
Q_CORE_EXPORT QString completeBaseName () const
 
Q_CORE_EXPORT QString suffix () const
 
Q_CORE_EXPORT QString bundleName () const
 
Q_CORE_EXPORT QString completeSuffix () const
 
Q_CORE_EXPORT QString filePath () const
 
Q_CORE_EXPORT bool isDir () const
 
Q_CORE_EXPORT bool isFile () const
 
Q_CORE_EXPORT bool isSymLink () const
 
Q_CORE_EXPORT bool exists () const
 
Q_CORE_EXPORT bool isHidden () const
 
Q_CORE_EXPORT bool isReadable () const
 
Q_CORE_EXPORT bool isWritable () const
 
Q_CORE_EXPORT bool isExecutable () const
 
Q_CORE_EXPORT QFileInfo fileInfo () const
 
Q_CORE_EXPORT QString canonicalFilePath () const
 
Q_CORE_EXPORT QString absoluteFilePath () const
 
Q_CORE_EXPORT QString absolutePath () const
 
Q_CORE_EXPORT qint64 size () const
 
QDateTime birthTime (const QTimeZone &tz) const
 
QDateTime metadataChangeTime (const QTimeZone &tz) const
 
QDateTime lastModified (const QTimeZone &tz) const
 
QDateTime lastRead (const QTimeZone &tz) const
 See the QFileInfo methods with the same names.
 
Q_CORE_EXPORT QDateTime fileTime (QFileDevice::FileTime type, const QTimeZone &tz) const
 

Friends

class QDirListing
 

Detailed Description

\inmodule QtCore

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:

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")) { /* ... */ }
}
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 */) { /* ... */ }
}

Definition at line 60 of file qdirlisting.h.

Member Function Documentation

◆ absoluteFilePath()

QString QDirListing::DirEntry::absoluteFilePath ( ) const

Definition at line 905 of file qdirlisting.cpp.

◆ absolutePath()

QString QDirListing::DirEntry::absolutePath ( ) const

Definition at line 910 of file qdirlisting.cpp.

◆ baseName()

QString QDirListing::DirEntry::baseName ( ) const

Definition at line 870 of file qdirlisting.cpp.

◆ birthTime()

QDateTime QDirListing::DirEntry::birthTime ( const QTimeZone & tz) const
inline

Definition at line 86 of file qdirlisting.h.

◆ bundleName()

QString QDirListing::DirEntry::bundleName ( ) const

Definition at line 885 of file qdirlisting.cpp.

◆ canonicalFilePath()

QString QDirListing::DirEntry::canonicalFilePath ( ) const

Definition at line 900 of file qdirlisting.cpp.

◆ completeBaseName()

QString QDirListing::DirEntry::completeBaseName ( ) const

Definition at line 875 of file qdirlisting.cpp.

◆ completeSuffix()

QString QDirListing::DirEntry::completeSuffix ( ) const

Definition at line 890 of file qdirlisting.cpp.

◆ exists()

bool QDirListing::DirEntry::exists ( ) const

Definition at line 930 of file qdirlisting.cpp.

◆ fileInfo()

QFileInfo QDirListing::DirEntry::fileInfo ( ) const

Definition at line 860 of file qdirlisting.cpp.

◆ fileName()

QString QDirListing::DirEntry::fileName ( ) const

Definition at line 865 of file qdirlisting.cpp.

◆ filePath()

QString QDirListing::DirEntry::filePath ( ) const

Definition at line 895 of file qdirlisting.cpp.

◆ fileTime()

QDateTime QDirListing::DirEntry::fileTime ( QFileDevice::FileTime type,
const QTimeZone & tz ) const

Definition at line 960 of file qdirlisting.cpp.

◆ isDir()

bool QDirListing::DirEntry::isDir ( ) const

Definition at line 915 of file qdirlisting.cpp.

◆ isExecutable()

bool QDirListing::DirEntry::isExecutable ( ) const

Definition at line 950 of file qdirlisting.cpp.

◆ isFile()

bool QDirListing::DirEntry::isFile ( ) const

Definition at line 920 of file qdirlisting.cpp.

◆ isHidden()

bool QDirListing::DirEntry::isHidden ( ) const

Definition at line 935 of file qdirlisting.cpp.

◆ isReadable()

bool QDirListing::DirEntry::isReadable ( ) const

Definition at line 940 of file qdirlisting.cpp.

◆ isSymLink()

bool QDirListing::DirEntry::isSymLink ( ) const

Definition at line 925 of file qdirlisting.cpp.

◆ isWritable()

bool QDirListing::DirEntry::isWritable ( ) const

Definition at line 945 of file qdirlisting.cpp.

◆ lastModified()

QDateTime QDirListing::DirEntry::lastModified ( const QTimeZone & tz) const
inline

Definition at line 90 of file qdirlisting.h.

◆ lastRead()

QDateTime QDirListing::DirEntry::lastRead ( const QTimeZone & tz) const
inline

See the QFileInfo methods with the same names.

Definition at line 92 of file qdirlisting.h.

◆ metadataChangeTime()

QDateTime QDirListing::DirEntry::metadataChangeTime ( const QTimeZone & tz) const
inline

Definition at line 88 of file qdirlisting.h.

◆ size()

qint64 QDirListing::DirEntry::size ( ) const

Definition at line 955 of file qdirlisting.cpp.

◆ suffix()

QString QDirListing::DirEntry::suffix ( ) const

Definition at line 880 of file qdirlisting.cpp.

Friends And Related Symbol Documentation

◆ QDirListing

friend class QDirListing
friend

Definition at line 62 of file qdirlisting.h.


The documentation for this class was generated from the following files: