Know if a directory is empty or not in QT

1
2
#Include <QDir>
#Include <QFileInfo>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
A simply bool function to know if a directory is empty or not in QT framework of C++.

2 Responses

omg, it's the worst code I've ever seen...
it can be simply written like:

bool isEmptyFolder(QString path) {
return QDir(path).entryList(QDir::NoDotAndDotDot|QDir::AllEntries).count() == 0;
}
omg, it's the worst code I've ever seen...
it can be simply written like:

1
2
bool isEmptyFolder(QString path) {
return QDir(path).entryList(QDir::NoDotAndDotDot|QDir::AllEntries).count() == 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.