1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qfsfileengine_iterator_p.h"
5#include "qfileinfo_p.h"
6#include "qvariant.h"
7
8#ifndef QT_NO_FILESYSTEMITERATOR
9
10QT_BEGIN_NAMESPACE
11
12QFSFileEngineIterator::QFSFileEngineIterator(const QString &path, QDir::Filters filters,
13 const QStringList &filterNames)
14 : QAbstractFileEngineIterator(path, filters, filterNames),
15 nativeIterator(new QFileSystemIterator(QFileSystemEntry(path), filters))
16{
17}
18
19QFSFileEngineIterator::QFSFileEngineIterator(const QString &path, QDirListing::IteratorFlags filters,
20 const QStringList &filterNames)
21 : QAbstractFileEngineIterator(path, filters, filterNames),
22 nativeIterator(new QFileSystemIterator(QFileSystemEntry(path), filters))
23{
24}
25
26QFSFileEngineIterator::~QFSFileEngineIterator()
27{
28}
29
30bool QFSFileEngineIterator::advance()
31{
32 if (!nativeIterator)
33 return false;
34
35 QFileSystemEntry entry;
36 QFileSystemMetaData data;
37 if (nativeIterator->advance(fileEntry&: entry, metaData&: data)) {
38 m_fileInfo = QFileInfo(new QFileInfoPrivate(entry, data));
39 return true;
40 } else {
41 nativeIterator.reset();
42 return false;
43 }
44}
45
46QString QFSFileEngineIterator::currentFileName() const
47{
48 return m_fileInfo.fileName();
49}
50
51QFileInfo QFSFileEngineIterator::currentFileInfo() const
52{
53 return m_fileInfo;
54}
55
56QT_END_NAMESPACE
57
58#endif // QT_NO_FILESYSTEMITERATOR
59

source code of qtbase/src/corelib/io/qfsfileengine_iterator.cpp