Skip to content

Commit

Permalink
QFileSystemIterator: simplify the constructor
Browse files Browse the repository at this point in the history
Neither implementation (Unix and Windows) uses the QStringList
or the QDir::Filters args.

Change-Id: I6a552e41eb37e4b76246e35d43ac4d34a4ae9d12
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
  • Loading branch information
ahmadsamir committed Feb 2, 2024
1 parent 0516d48 commit e26fbd5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/corelib/io/qdiriterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
} else {
#ifndef QT_NO_FILESYSTEMITERATOR
nativeIterators.emplace(std::make_unique<QFileSystemIterator>(
fileInfo.d_ptr->fileEntry, filters, nameFilters, iteratorFlags));
fileInfo.d_ptr->fileEntry, filters));
#else
qWarning("Qt was built with -no-feature-filesystemiterator: no files/plugins will be found!");
#endif
Expand Down
4 changes: 1 addition & 3 deletions src/corelib/io/qfilesystemiterator_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ QT_BEGIN_NAMESPACE
class QFileSystemIterator
{
public:
QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
const QStringList &nameFilters, QDirIterator::IteratorFlags flags
= QDirIterator::FollowSymlinks | QDirIterator::Subdirectories);
QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters);
~QFileSystemIterator();

bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData);
Expand Down
5 changes: 1 addition & 4 deletions src/corelib/io/qfilesystemiterator_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ static bool checkNameDecodable(const char *d_name, qsizetype len)
Native filesystem iterator, which uses ::opendir()/readdir()/dirent from the system
libraries to iterate over the directory represented by \a entry.
*/
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
const QStringList &nameFilters, QDirIterator::IteratorFlags flags)
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters)
: nativePath(entry.nativeFilePath())
{
Q_UNUSED(filters);
Q_UNUSED(nameFilters);
Q_UNUSED(flags);

dir.reset(QT_OPENDIR(entry.nativeFilePath().constData()));
if (!dir) {
Expand Down
5 changes: 1 addition & 4 deletions src/corelib/io/qfilesystemiterator_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ using namespace Qt::StringLiterals;

bool done = true;

QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
const QStringList &nameFilters, QDirIterator::IteratorFlags flags)
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters)
: nativePath(entry.nativeFilePath())
, dirPath(entry.filePath())
, findFileHandle(INVALID_HANDLE_VALUE)
, uncFallback(false)
, uncShareIndex(0)
, onlyDirs(false)
{
Q_UNUSED(nameFilters);
Q_UNUSED(flags);
if (nativePath.endsWith(u".lnk"_s) && !QFileSystemEngine::isDirPath(dirPath, nullptr)) {
QFileSystemMetaData metaData;
QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData);
Expand Down
3 changes: 1 addition & 2 deletions src/corelib/io/qfsfileengine_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ QFSFileEngineIterator::~QFSFileEngineIterator()
bool QFSFileEngineIterator::hasNext() const
{
if (!done && !nativeIterator) {
nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()),
filters(), nameFilters()));
nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()), filters()));
advance();
}

Expand Down

0 comments on commit e26fbd5

Please sign in to comment.