Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 219e40cf authored by Elvis Angelaccio's avatar Elvis Angelaccio

Use qplatformdefs wrappers

As recommended by krazy and as kio does.
parent 56b132ff
......@@ -24,8 +24,8 @@
#ifdef Q_OS_WIN
#include <QDir>
#else
#include <dirent.h>
#include <QFile>
#include <qplatformdefs.h>
#endif
KDirectoryContentsCounterWorker::KDirectoryContentsCounterWorker(QObject* parent) :
......@@ -52,15 +52,15 @@ int KDirectoryContentsCounterWorker::subItemsCount(const QString& path, Options
}
return dir.entryList(filters).count();
#else
// Taken from kdelibs/kio/kio/kdirmodel.cpp
// Taken from kio/src/widgets/kdirmodel.cpp
// Copyright (C) 2006 David Faure <faure@kde.org>
int count = -1;
DIR* dir = ::opendir(QFile::encodeName(path));
if (dir) { // krazy:exclude=syscalls
auto dir = QT_OPENDIR(QFile::encodeName(path));
if (dir) {
count = 0;
struct dirent *dirEntry = nullptr;
while ((dirEntry = ::readdir(dir))) {
QT_DIRENT *dirEntry = nullptr;
while ((dirEntry = QT_READDIR(dir))) {
if (dirEntry->d_name[0] == '.') {
if (dirEntry->d_name[1] == '\0' || !countHiddenFiles) {
// Skip "." or hidden files
......@@ -83,7 +83,7 @@ int KDirectoryContentsCounterWorker::subItemsCount(const QString& path, Options
++count;
}
}
::closedir(dir);
QT_CLOSEDIR(dir);
}
return count;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment