[][src]Struct qt_core::QDirIterator

#[repr(C)]pub struct QDirIterator { /* fields omitted */ }

The QDirIterator class provides an iterator for directory entrylists.

C++ class: QDirIterator.

C++ documentation:

The QDirIterator class provides an iterator for directory entrylists.

You can use QDirIterator to navigate entries of a directory one at a time. It is similar to QDir::entryList() and QDir::entryInfoList(), but because it lists entries one at a time instead of all at once, it scales better and is more suitable for large directories. It also supports listing directory contents recursively, and following symbolic links. Unlike QDir::entryList(), QDirIterator does not support sorting.

The QDirIterator constructor takes a QDir or a directory as argument. After construction, the iterator is located before the first directory entry. Here's how to iterate over all the entries sequentially:

QDirIterator it("/etc", QDirIterator::Subdirectories); while (it.hasNext()) { qDebug() << it.next();

// /etc/. // /etc/.. // /etc/X11 // /etc/X11/fs // ... }

Here's how to find and read all files filtered by name, recursively:

QDirIterator it("/sys", QStringList() << "scaling_cur_freq", QDir::NoFilter, QDirIterator::Subdirectories); while (it.hasNext()) { QFile f(it.next()); f.open(QIODevice::ReadOnly); qDebug() << f.fileName() << f.readAll().trimmed().toDouble() / 1000 << "MHz"; }

The next() function returns the path to the next directory entry and advances the iterator. You can also call filePath() to get the current file path without advancing the iterator. The fileName() function returns only the name of the file, similar to how QDir::entryList() works. You can also call fileInfo() to get a QFileInfo for the current entry.

Unlike Qt's container iterators, QDirIterator is uni-directional (i.e., you cannot iterate directories in reverse order) and does not allow random access.

Methods

impl QDirIterator[src]

pub unsafe fn file_info(&self) -> CppBox<QFileInfo>[src]

Returns a QFileInfo for the current directory entry.

Calls C++ function: QFileInfo QDirIterator::fileInfo() const.

C++ documentation:

Returns a QFileInfo for the current directory entry.

See also filePath() and fileName().

pub unsafe fn file_name(&self) -> CppBox<QString>[src]

Returns the file name for the current directory entry, without the path prepended.

Calls C++ function: QString QDirIterator::fileName() const.

C++ documentation:

Returns the file name for the current directory entry, without the path prepended.

This function is convenient when iterating a single directory. When using the QDirIterator::Subdirectories flag, you can use filePath() to get the full path.

See also filePath() and fileInfo().

pub unsafe fn file_path(&self) -> CppBox<QString>[src]

Returns the full file path for the current directory entry.

Calls C++ function: QString QDirIterator::filePath() const.

C++ documentation:

Returns the full file path for the current directory entry.

See also fileInfo() and fileName().

pub unsafe fn has_next(&self) -> bool[src]

Returns true if there is at least one more entry in the directory; otherwise, false is returned.

Calls C++ function: bool QDirIterator::hasNext() const.

C++ documentation:

Returns true if there is at least one more entry in the directory; otherwise, false is returned.

See also next(), fileName(), filePath(), and fileInfo().

pub unsafe fn from_q_dir_q_flags_iterator_flag(
    dir: impl CastInto<Ref<QDir>>,
    flags: QFlags<IteratorFlag>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over dir's entrylist, using dir's name filters and regular filters. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QDir& dir, QFlags<QDirIterator::IteratorFlag> flags = …).

C++ documentation:

Constructs a QDirIterator that can iterate over dir's entrylist, using dir's name filters and regular filters. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

The sorting in dir is ignored.

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string_q_flags_iterator_flag(
    path: impl CastInto<Ref<QString>>,
    flags: QFlags<IteratorFlag>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path, QFlags<QDirIterator::IteratorFlag> flags = …).

C++ documentation:

Constructs a QDirIterator that can iterate over path. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string_q_flags_filter_q_flags_iterator_flag(
    path: impl CastInto<Ref<QString>>,
    filter: QFlags<Filter>,
    flags: QFlags<IteratorFlag>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path, with no name filtering and filters for entry filtering. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path, QFlags<QDir::Filter> filter, QFlags<QDirIterator::IteratorFlag> flags = …).

C++ documentation:

Constructs a QDirIterator that can iterate over path, with no name filtering and filters for entry filtering. You can pass options via flags to decide how the directory should be iterated.

By default, filters is QDir::NoFilter, and flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string_q_string_list_q_flags_filter_q_flags_iterator_flag(
    path: impl CastInto<Ref<QString>>,
    name_filters: impl CastInto<Ref<QStringList>>,
    filters: QFlags<Filter>,
    flags: QFlags<IteratorFlag>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path, const QStringList& nameFilters, QFlags<QDir::Filter> filters = …, QFlags<QDirIterator::IteratorFlag> flags = …).

C++ documentation:

Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_dir(dir: impl CastInto<Ref<QDir>>) -> CppBox<QDirIterator>[src]

Constructs a QDirIterator that can iterate over dir's entrylist, using dir's name filters and regular filters. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QDir& dir).

C++ documentation:

Constructs a QDirIterator that can iterate over dir's entrylist, using dir's name filters and regular filters. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

The sorting in dir is ignored.

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string(
    path: impl CastInto<Ref<QString>>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path).

C++ documentation:

Constructs a QDirIterator that can iterate over path. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string_q_flags_filter(
    path: impl CastInto<Ref<QString>>,
    filter: QFlags<Filter>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path, with no name filtering and filters for entry filtering. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path, QFlags<QDir::Filter> filter).

C++ documentation:

Constructs a QDirIterator that can iterate over path, with no name filtering and filters for entry filtering. You can pass options via flags to decide how the directory should be iterated.

By default, filters is QDir::NoFilter, and flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string_q_string_list_q_flags_filter(
    path: impl CastInto<Ref<QString>>,
    name_filters: impl CastInto<Ref<QStringList>>,
    filters: QFlags<Filter>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path, const QStringList& nameFilters, QFlags<QDir::Filter> filters = …).

C++ documentation:

Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn from_q_string_q_string_list(
    path: impl CastInto<Ref<QString>>,
    name_filters: impl CastInto<Ref<QStringList>>
) -> CppBox<QDirIterator>
[src]

Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

Calls C++ function: [constructor] void QDirIterator::QDirIterator(const QString& path, const QStringList& nameFilters).

C++ documentation:

Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

By default, flags is NoIteratorFlags, which provides the same behavior as QDir::entryList().

Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

See also hasNext(), next(), and IteratorFlags.

pub unsafe fn next(&self) -> CppBox<QString>[src]

Advances the iterator to the next entry, and returns the file path of this new entry. If hasNext() returns false, this function does nothing, and returns an empty QString.

Calls C++ function: QString QDirIterator::next().

C++ documentation:

Advances the iterator to the next entry, and returns the file path of this new entry. If hasNext() returns false, this function does nothing, and returns an empty QString.

You can call fileName() or filePath() to get the current entry file name or path, or fileInfo() to get a QFileInfo for the current entry.

See also hasNext(), fileName(), filePath(), and fileInfo().

pub unsafe fn path(&self) -> CppBox<QString>[src]

Returns the base directory of the iterator.

Calls C++ function: QString QDirIterator::path() const.

C++ documentation:

Returns the base directory of the iterator.

Trait Implementations

impl CppDeletable for QDirIterator[src]

unsafe fn delete(&self)[src]

Destroys the QDirIterator.

Calls C++ function: [destructor] void QDirIterator::~QDirIterator().

C++ documentation:

Destroys the QDirIterator.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.