diff options
author | Elvis Angelaccio <elvis.angelaccio@kde.org> | 2016-09-12 18:48:17 +0200 |
---|---|---|
committer | Elvis Angelaccio <elvis.angelaccio@kde.org> | 2017-01-08 16:11:34 +0000 |
commit | 3f455a4b53254b3ebbafae91600a63caebee3e0e (patch) | |
tree | 5e63f750d03de84307369c66c0bfac144b238adf /src/corelib/io/qdir.h | |
parent | 5311d481c2159c0076afc31c1276e1bd5b674fc4 (diff) |
Introduce QDir::isEmpty()
A directory is empty when it doesn't contain files or folders.
We can exploit QDirIterator::hasNext() to check whether this is the
case. This is efficient since it doesn't list the whole folder (in the
non-empty case).
Test cases are added for both the empty and non-empty cases.
Change-Id: I0f7e26782c0f97f9c16f928dab6cae37927875d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qdir.h')
-rw-r--r-- | src/corelib/io/qdir.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index ef7ec2c701..950a26f327 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -144,6 +144,8 @@ public: void setSorting(SortFlags sort); uint count() const; + bool isEmpty(Filters filters = Filters(AllEntries | NoDotAndDotDot)) const; + QString operator[](int) const; static QStringList nameFiltersFromString(const QString &nameFilter); |