File: qdiriterator.html

package info (click to toggle)
python-qt4 4.12.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 40,300 kB
  • ctags: 6,185
  • sloc: python: 125,988; cpp: 13,291; xml: 292; makefile: 246; php: 27; sh: 2
file content (163 lines) | stat: -rw-r--r-- 14,209 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDirIterator Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDirIterator Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QDirIterator class provides an iterator for directory
entrylists. <a href="#details">More...</a></p>

<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qdiriterator.html#IteratorFlag-enum">IteratorFlag</a></b> { NoIteratorFlags, FollowSymlinks, Subdirectories }</li><li><div class="fn" />class <b><a href="qdiriterator-iteratorflags.html">IteratorFlags</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdiriterator.html#QDirIterator">__init__</a></b> (<i>self</i>, QDir&#160;<i>dir</i>, IteratorFlags&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</li><li><div class="fn" /><b><a href="qdiriterator.html#QDirIterator-2">__init__</a></b> (<i>self</i>, QString&#160;<i>path</i>, IteratorFlags&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</li><li><div class="fn" /><b><a href="qdiriterator.html#QDirIterator-3">__init__</a></b> (<i>self</i>, QString&#160;<i>path</i>, QDir.Filters&#160;<i>filters</i>, IteratorFlags&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</li><li><div class="fn" /><b><a href="qdiriterator.html#QDirIterator-4">__init__</a></b> (<i>self</i>, QString&#160;<i>path</i>, QStringList&#160;<i>nameFilters</i>, QDir.Filters&#160;<i>filters</i>&#160;=&#160;QDir.NoFilter, IteratorFlags&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</li><li><div class="fn" />QFileInfo <b><a href="qdiriterator.html#fileInfo">fileInfo</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdiriterator.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdiriterator.html#filePath">filePath</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdiriterator.html#hasNext">hasNext</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdiriterator.html#next">next</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdiriterator.html#path">path</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDirIterator class provides an iterator for directory
entrylists.</p>
<p>You can use QDirIterator to navigate entries of a directory one
at a time. It is similar to <a href="qdir.html#entryList">QDir.entryList</a>() and <a href="qdir.html#entryInfoList">QDir.entryInfoList</a>(), 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 <a href="qdir.html#entryList">QDir.entryList</a>(),
QDirIterator does not support sorting.</p>
<p>The QDirIterator constructor takes a <a href="qdir.html">QDir</a> 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:</p>
<pre class="cpp">
 <span class="type">QDirIterator</span> it(<span class="string">"/etc"</span><span class="operator">,</span> <span class="type">QDirIterator</span><span class="operator">.</span>Subdirectories);
 <span class="keyword">while</span> (it<span class="operator">.</span>hasNext()) {
     <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> it<span class="operator">.</span>next();

     <span class="comment">// /etc/.</span>
     <span class="comment">// /etc/..</span>
     <span class="comment">// /etc/X11</span>
     <span class="comment">// /etc/X11/fs</span>
     <span class="comment">// ...</span>
 }
</pre>
<p>The <a href="qdiriterator.html#next">next</a>() function returns
the path to the next directory entry and advances the iterator. You
can also call <a href="qdiriterator.html#filePath">filePath</a>()
to get the current file path without advancing the iterator. The
<a href="qdiriterator.html#fileName">fileName</a>() function
returns only the name of the file, similar to how <a href="qdir.html#entryList">QDir.entryList</a>() works. You can also
call <a href="qdiriterator.html#fileInfo">fileInfo</a>() to get a
<a href="qfileinfo.html">QFileInfo</a> for the current entry.</p>
<p>Unlike Qt's container iterators, QDirIterator is uni-directional
(i.e., you cannot iterate directories in reverse order) and does
not allow random access.</p>
<p>QDirIterator works with all supported file engines, and is
implemented using <a href="qabstractfileengineiterator.html">QAbstractFileEngineIterator</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="IteratorFlag-enum" />QDirIterator.IteratorFlag</h3><p>This enum describes flags that you can combine to configure the
behavior of <a href="qdiriterator.html">QDirIterator</a>.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QDirIterator.NoIteratorFlags</tt></td>
<td class="topAlign"><tt>0x0</tt></td>
<td class="topAlign">The default value, representing no flags. The
iterator will return entries for the assigned path.</td>
</tr>
<tr>
<td class="topAlign"><tt>QDirIterator.Subdirectories</tt></td>
<td class="topAlign"><tt>0x2</tt></td>
<td class="topAlign">List entries inside all subdirectories as
well.</td>
</tr>
<tr>
<td class="topAlign"><tt>QDirIterator.FollowSymlinks</tt></td>
<td class="topAlign"><tt>0x1</tt></td>
<td class="topAlign">When combined with Subdirectories, this flag
enables iterating through all subdirectories of the assigned path,
following all symbolic links. Symbolic link loops (e.g., "link"
=&gt; "." or "link" =&gt; "..") are automatically detected and
ignored.</td>
</tr>
</table>
<p>The IteratorFlags type is a typedef for <a href="qflags.html">QFlags</a>&lt;IteratorFlag&gt;. It stores an OR
combination of IteratorFlag values.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDirIterator" />QDirIterator.__init__ (<i>self</i>, <a href="qdir.html">QDir</a>&#160;<i>dir</i>, <a href="qdiriterator-iteratorflags.html">IteratorFlags</a>&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</h3><p>Constructs a <a href="qdiriterator.html">QDirIterator</a> that
can iterate over <i>dir</i>'s entrylist, using <i>dir</i>'s name
filters and regular filters. You can pass options via <i>flags</i>
to decide how the directory should be iterated.</p>
<p>By default, <i>flags</i> is <a href="qdiriterator.html#IteratorFlag-enum">NoIteratorFlags</a>, which
provides the same behavior as in <a href="qdir.html#entryList">QDir.entryList</a>().</p>
<p>The sorting in <i>dir</i> is ignored.</p>
<p><b>Note:</b> To list symlinks that point to non existing files,
<a href="qdir.html#Filter-enum">QDir.System</a> must be passed to
the flags.</p>
<p><b>See also</b> <a href="qdiriterator.html#hasNext">hasNext</a>(), <a href="qdiriterator.html#next">next</a>(), and <a href="qdiriterator.html#IteratorFlag-enum">IteratorFlags</a>.</p>


<h3 class="fn"><a name="QDirIterator-2" />QDirIterator.__init__ (<i>self</i>, QString&#160;<i>path</i>, <a href="qdiriterator-iteratorflags.html">IteratorFlags</a>&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</h3><p>Constructs a <a href="qdiriterator.html">QDirIterator</a> that
can iterate over <i>path</i>. You can pass options via <i>flags</i>
to decide how the directory should be iterated.</p>
<p>By default, <i>flags</i> is <a href="qdiriterator.html#IteratorFlag-enum">NoIteratorFlags</a>, which
provides the same behavior as in <a href="qdir.html#entryList">QDir.entryList</a>().</p>
<p><b>Note:</b> To list symlinks that point to non existing files,
<a href="qdir.html#Filter-enum">QDir.System</a> must be passed to
the flags.</p>
<p><b>See also</b> <a href="qdiriterator.html#hasNext">hasNext</a>(), <a href="qdiriterator.html#next">next</a>(), and <a href="qdiriterator.html#IteratorFlag-enum">IteratorFlags</a>.</p>


<h3 class="fn"><a name="QDirIterator-3" />QDirIterator.__init__ (<i>self</i>, QString&#160;<i>path</i>, <a href="qdir-filters.html">QDir.Filters</a>&#160;<i>filters</i>, <a href="qdiriterator-iteratorflags.html">IteratorFlags</a>&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</h3><p>Constructs a <a href="qdiriterator.html">QDirIterator</a> that
can iterate over <i>path</i>, with no name filtering and
<i>filters</i> for entry filtering. You can pass options via
<i>flags</i> to decide how the directory should be iterated.</p>
<p>By default, <i>filters</i> is <a href="qdir.html#Filter-enum">QDir.NoFilter</a>, and <i>flags</i> is
<a href="qdiriterator.html#IteratorFlag-enum">NoIteratorFlags</a>,
which provides the same behavior as in <a href="qdir.html#entryList">QDir.entryList</a>().</p>
<p><b>Note:</b> To list symlinks that point to non existing files,
<a href="qdir.html#Filter-enum">QDir.System</a> must be passed to
the flags.</p>
<p><b>See also</b> <a href="qdiriterator.html#hasNext">hasNext</a>(), <a href="qdiriterator.html#next">next</a>(), and <a href="qdiriterator.html#IteratorFlag-enum">IteratorFlags</a>.</p>


<h3 class="fn"><a name="QDirIterator-4" />QDirIterator.__init__ (<i>self</i>, QString&#160;<i>path</i>, QStringList&#160;<i>nameFilters</i>, <a href="qdir-filters.html">QDir.Filters</a>&#160;<i>filters</i>&#160;=&#160;QDir.NoFilter, <a href="qdiriterator-iteratorflags.html">IteratorFlags</a>&#160;<i>flags</i>&#160;=&#160;QDirIterator.NoIteratorFlags)</h3><p>Constructs a <a href="qdiriterator.html">QDirIterator</a> that
can iterate over <i>path</i>, using <i>nameFilters</i> and
<i>filters</i>. You can pass options via <i>flags</i> to decide how
the directory should be iterated.</p>
<p>By default, <i>flags</i> is <a href="qdiriterator.html#IteratorFlag-enum">NoIteratorFlags</a>, which
provides the same behavior as <a href="qdir.html#entryList">QDir.entryList</a>().</p>
<p><b>Note:</b> To list symlinks that point to non existing files,
<a href="qdir.html#Filter-enum">QDir.System</a> must be passed to
the flags.</p>
<p><b>See also</b> <a href="qdiriterator.html#hasNext">hasNext</a>(), <a href="qdiriterator.html#next">next</a>(), and <a href="qdiriterator.html#IteratorFlag-enum">IteratorFlags</a>.</p>


<h3 class="fn"><a name="fileInfo" /><a href="qfileinfo.html">QFileInfo</a> QDirIterator.fileInfo (<i>self</i>)</h3><p>Returns a <a href="qfileinfo.html">QFileInfo</a> for the current
directory entry.</p>
<p><b>See also</b> <a href="qdiriterator.html#filePath">filePath</a>() and <a href="qdiriterator.html#fileName">fileName</a>().</p>


<h3 class="fn"><a name="fileName" />QString QDirIterator.fileName (<i>self</i>)</h3><p>Returns the file name for the current directory entry, without
the path prepended.</p>
<p>This function is convenient when iterating a single directory.
When using the <a href="qdiriterator.html#IteratorFlag-enum">QDirIterator.Subdirectories</a>
flag, you can use <a href="qdiriterator.html#filePath">filePath</a>() to get the full
path.</p>
<p><b>See also</b> <a href="qdiriterator.html#filePath">filePath</a>() and <a href="qdiriterator.html#fileInfo">fileInfo</a>().</p>


<h3 class="fn"><a name="filePath" />QString QDirIterator.filePath (<i>self</i>)</h3><p>Returns the full file path for the current directory entry.</p>
<p><b>See also</b> <a href="qdiriterator.html#fileInfo">fileInfo</a>() and <a href="qdiriterator.html#fileName">fileName</a>().</p>


<h3 class="fn"><a name="hasNext" />bool QDirIterator.hasNext (<i>self</i>)</h3><p>Returns true if there is at least one more entry in the
directory; otherwise, false is returned.</p>
<p><b>See also</b> <a href="qdiriterator.html#next">next</a>(),
<a href="qdiriterator.html#fileName">fileName</a>(), <a href="qdiriterator.html#filePath">filePath</a>(), and <a href="qdiriterator.html#fileInfo">fileInfo</a>().</p>


<h3 class="fn"><a name="next" />QString QDirIterator.next (<i>self</i>)</h3><p>Advances the iterator to the next entry, and returns the file
path of this new entry. If <a href="qdiriterator.html#hasNext">hasNext</a>() returns false, this
function does nothing, and returns a null <a href="qstring.html">QString</a>.</p>
<p>You can call <a href="qdiriterator.html#fileName">fileName</a>()
or <a href="qdiriterator.html#filePath">filePath</a>() to get the
current entry file name or path, or <a href="qdiriterator.html#fileInfo">fileInfo</a>() to get a <a href="qfileinfo.html">QFileInfo</a> for the current entry.</p>
<p><b>See also</b> <a href="qdiriterator.html#hasNext">hasNext</a>(), <a href="qdiriterator.html#fileName">fileName</a>(), <a href="qdiriterator.html#filePath">filePath</a>(), and <a href="qdiriterator.html#fileInfo">fileInfo</a>().</p>


<h3 class="fn"><a name="path" />QString QDirIterator.path (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.12.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt&#160;4.8.7</td></tr></table></div></address></body></html>