1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/io/qdir.cpp -->
7
<title>Qt 4.0: QDir Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QDir Class Reference</h1>
21
<p>The QDir class provides access to directory structures and their contents. <a href="#details">More...</a></p>
22
<pre>#include <QDir></pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
23
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
25
<li><a href="qdir-members.html">List of all members, including inherited members</a></li>
26
<li><a href="qdir-obsolete.html">Obsolete members</a></li>
27
<li><a href="qdir-qt3.html">Qt 3 support members</a></li>
29
<a name="public-types"></a>
32
<li><div class="fn"/>enum <b><a href="qdir.html#Filter-enum">Filter</a></b> { Dirs, AllDirs, Files, Drives, ..., CaseSensitive }</li>
33
<li><div class="fn"/>typedef <b><a href="qdir.html#FilterSpec-typedef">FilterSpec</a></b></li>
34
<li><div class="fn"/>flags <b><a href="qdir.html#Filter-enum">Filters</a></b></li>
35
<li><div class="fn"/>enum <b><a href="qdir.html#SortFlag-enum">SortFlag</a></b> { Name, Time, Size, Unsorted, ..., IgnoreCase }</li>
36
<li><div class="fn"/>flags <b><a href="qdir.html#SortFlag-enum">SortFlags</a></b></li>
37
<li><div class="fn"/>typedef <b><a href="qdir.html#SortSpec-typedef">SortSpec</a></b></li>
39
<a name="public-functions"></a>
40
<h3>Public Functions</h3>
42
<li><div class="fn"/><b><a href="qdir.html#QDir">QDir</a></b> ( const QDir & <i>dir</i> )</li>
43
<li><div class="fn"/><b><a href="qdir.html#QDir-2">QDir</a></b> ( const QString & <i>path</i> = QString() )</li>
44
<li><div class="fn"/><b><a href="qdir.html#QDir-3">QDir</a></b> ( const QString & <i>path</i>, const QString & <i>nameFilter</i>, SortFlags <i>sort</i> = SortFlags( Name | IgnoreCase ), Filters <i>filters</i> = TypeMask )</li>
45
<li><div class="fn"/><b><a href="qdir.html#dtor.QDir">~QDir</a></b> ()</li>
46
<li><div class="fn"/>QString <b><a href="qdir.html#absoluteFilePath">absoluteFilePath</a></b> ( const QString & <i>fileName</i> ) const</li>
47
<li><div class="fn"/>QString <b><a href="qdir.html#absolutePath">absolutePath</a></b> () const</li>
48
<li><div class="fn"/>QString <b><a href="qdir.html#canonicalPath">canonicalPath</a></b> () const</li>
49
<li><div class="fn"/>bool <b><a href="qdir.html#cd">cd</a></b> ( const QString & <i>dirName</i> )</li>
50
<li><div class="fn"/>bool <b><a href="qdir.html#cdUp">cdUp</a></b> ()</li>
51
<li><div class="fn"/>uint <b><a href="qdir.html#count">count</a></b> () const</li>
52
<li><div class="fn"/>QString <b><a href="qdir.html#dirName">dirName</a></b> () const</li>
53
<li><div class="fn"/>QFileInfoList <b><a href="qdir.html#entryInfoList-2">entryInfoList</a></b> ( Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort ) const</li>
54
<li><div class="fn"/>QFileInfoList <b><a href="qdir.html#entryInfoList-3">entryInfoList</a></b> ( const QStringList & <i>nameFilters</i>, Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort ) const</li>
55
<li><div class="fn"/>QStringList <b><a href="qdir.html#entryList">entryList</a></b> ( const QStringList & <i>nameFilters</i>, Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort ) const</li>
56
<li><div class="fn"/>QStringList <b><a href="qdir.html#entryList-3">entryList</a></b> ( Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort ) const</li>
57
<li><div class="fn"/>bool <b><a href="qdir.html#exists">exists</a></b> ( const QString & <i>name</i> ) const</li>
58
<li><div class="fn"/>bool <b><a href="qdir.html#exists-2">exists</a></b> () const</li>
59
<li><div class="fn"/>QString <b><a href="qdir.html#filePath">filePath</a></b> ( const QString & <i>fileName</i> ) const</li>
60
<li><div class="fn"/>Filters <b><a href="qdir.html#filter">filter</a></b> () const</li>
61
<li><div class="fn"/>bool <b><a href="qdir.html#isAbsolute">isAbsolute</a></b> () const</li>
62
<li><div class="fn"/>bool <b><a href="qdir.html#isReadable">isReadable</a></b> () const</li>
63
<li><div class="fn"/>bool <b><a href="qdir.html#isRelative">isRelative</a></b> () const</li>
64
<li><div class="fn"/>bool <b><a href="qdir.html#isRoot">isRoot</a></b> () const</li>
65
<li><div class="fn"/>bool <b><a href="qdir.html#makeAbsolute">makeAbsolute</a></b> ()</li>
66
<li><div class="fn"/>bool <b><a href="qdir.html#mkdir">mkdir</a></b> ( const QString & <i>dirName</i> ) const</li>
67
<li><div class="fn"/>bool <b><a href="qdir.html#mkpath">mkpath</a></b> ( const QString & <i>dirPath</i> ) const</li>
68
<li><div class="fn"/>QStringList <b><a href="qdir.html#nameFilters">nameFilters</a></b> () const</li>
69
<li><div class="fn"/>QString <b><a href="qdir.html#path">path</a></b> () const</li>
70
<li><div class="fn"/>void <b><a href="qdir.html#refresh">refresh</a></b> () const</li>
71
<li><div class="fn"/>QString <b><a href="qdir.html#relativeFilePath">relativeFilePath</a></b> ( const QString & <i>fileName</i> ) const</li>
72
<li><div class="fn"/>bool <b><a href="qdir.html#remove">remove</a></b> ( const QString & <i>fileName</i> )</li>
73
<li><div class="fn"/>bool <b><a href="qdir.html#rename">rename</a></b> ( const QString & <i>oldName</i>, const QString & <i>newName</i> )</li>
74
<li><div class="fn"/>bool <b><a href="qdir.html#rmdir">rmdir</a></b> ( const QString & <i>dirName</i> ) const</li>
75
<li><div class="fn"/>bool <b><a href="qdir.html#rmpath">rmpath</a></b> ( const QString & <i>dirPath</i> ) const</li>
76
<li><div class="fn"/>void <b><a href="qdir.html#setFilter">setFilter</a></b> ( Filters <i>filters</i> )</li>
77
<li><div class="fn"/>void <b><a href="qdir.html#setNameFilters">setNameFilters</a></b> ( const QStringList & <i>nameFilters</i> )</li>
78
<li><div class="fn"/>void <b><a href="qdir.html#setPath">setPath</a></b> ( const QString & <i>path</i> )</li>
79
<li><div class="fn"/>void <b><a href="qdir.html#setSorting">setSorting</a></b> ( SortFlags <i>sort</i> )</li>
80
<li><div class="fn"/>SortFlags <b><a href="qdir.html#sorting">sorting</a></b> () const</li>
81
<li><div class="fn"/>bool <b><a href="qdir.html#operator-not-eq">operator!=</a></b> ( const QDir & <i>dir</i> ) const</li>
82
<li><div class="fn"/>QDir & <b><a href="qdir.html#operator-eq">operator=</a></b> ( const QDir & <i>dir</i> )</li>
83
<li><div class="fn"/>bool <b><a href="qdir.html#operator-eq-eq">operator==</a></b> ( const QDir & <i>dir</i> ) const</li>
84
<li><div class="fn"/>QString <b><a href="qdir.html#operator-5b-5d">operator[]</a></b> ( int <i>pos</i> ) const</li>
86
<a name="static-public-members"></a>
87
<h3>Static Public Members</h3>
89
<li><div class="fn"/>void <b><a href="qdir.html#addResourceSearchPath">addResourceSearchPath</a></b> ( const QString & <i>path</i> )</li>
90
<li><div class="fn"/>QString <b><a href="qdir.html#cleanPath">cleanPath</a></b> ( const QString & <i>path</i> )</li>
91
<li><div class="fn"/>QString <b><a href="qdir.html#convertSeparators">convertSeparators</a></b> ( const QString & <i>pathName</i> )</li>
92
<li><div class="fn"/>QDir <b><a href="qdir.html#current">current</a></b> ()</li>
93
<li><div class="fn"/>QString <b><a href="qdir.html#currentPath">currentPath</a></b> ()</li>
94
<li><div class="fn"/>QFileInfoList <b><a href="qdir.html#drives">drives</a></b> ()</li>
95
<li><div class="fn"/>QDir <b><a href="qdir.html#home">home</a></b> ()</li>
96
<li><div class="fn"/>QString <b><a href="qdir.html#homePath">homePath</a></b> ()</li>
97
<li><div class="fn"/>bool <b><a href="qdir.html#isAbsolutePath">isAbsolutePath</a></b> ( const QString & <i>path</i> )</li>
98
<li><div class="fn"/>bool <b><a href="qdir.html#isRelativePath">isRelativePath</a></b> ( const QString & <i>path</i> )</li>
99
<li><div class="fn"/>bool <b><a href="qdir.html#match">match</a></b> ( const QString & <i>filter</i>, const QString & <i>fileName</i> )</li>
100
<li><div class="fn"/>bool <b><a href="qdir.html#match-2">match</a></b> ( const QStringList & <i>filters</i>, const QString & <i>fileName</i> )</li>
101
<li><div class="fn"/>QDir <b><a href="qdir.html#root">root</a></b> ()</li>
102
<li><div class="fn"/>QString <b><a href="qdir.html#rootPath">rootPath</a></b> ()</li>
103
<li><div class="fn"/>QChar <b><a href="qdir.html#separator">separator</a></b> ()</li>
104
<li><div class="fn"/>bool <b><a href="qdir.html#setCurrent">setCurrent</a></b> ( const QString & <i>path</i> )</li>
105
<li><div class="fn"/>QDir <b><a href="qdir.html#temp">temp</a></b> ()</li>
106
<li><div class="fn"/>QString <b><a href="qdir.html#tempPath">tempPath</a></b> ()</li>
108
<a name="details"></a>
110
<h2>Detailed Description</h2>
111
<p>The QDir class provides access to directory structures and their contents.</p>
112
<p>A QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. It can also be used to access Qt's <a href="resources.html#resource-system">resource system</a>.</p>
113
<p>A QDir can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator "/" (optionally preceded by a drive specification under Windows). If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system. Relative file names begin with a directory name or a file name and specify a path relative to the current directory.</p>
114
<p>An example of an absolute path is the string "/tmp/quartz", a relative path might look like "src/fatlib". You can use the <a href="qdir.html#isRelative">isRelative</a>() or <a href="qdir.html#isAbsolute">isAbsolute</a>() functions to check if a QDir is using a relative or an absolute file path. Call <a href="qdir.html#makeAbsolute">makeAbsolute</a>() to convert a relative QDir to an absolute one. For a simplified path use <a href="qdir.html#cleanPath">cleanPath</a>(). To obtain a path which has no symbolic links or redundant ".." elements use <a href="qdir.html#canonicalPath">canonicalPath</a>(). The path can be set with <a href="qdir.html#setPath">setPath</a>(), and changed with <a href="qdir.html#cd">cd</a>() and <a href="qdir.html#cdUp">cdUp</a>().</p>
115
<p>The <a href="qdir.html#current">current</a>() path (and <a href="qdir.html#currentPath">currentPath</a>()), refers to the application's working directory. A QDir's own path is set and retrieved with <a href="qdir.html#setPath">setPath</a>() and <a href="qdir.html#path">path</a>().</p>
116
<p>QDir provides several static convenience functions, for example, <a href="qdir.html#setCurrent">setCurrent</a>() to set the application's working directory and <a href="qdir.html#current">current</a>() and <a href="qdir.html#currentPath">currentPath</a>() to retrieve the application's working directory. Access to some common paths is provided with the static functions, <a href="qdir.html#home">home</a>(), <a href="qdir.html#root">root</a>(), and <a href="qdir.html#temp">temp</a>() which return QDir objects or <a href="qdir.html#homePath">homePath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), and <a href="qdir.html#tempPath">tempPath</a>() which return the path as a string. For the application's directory, see <a href="qcoreapplication.html#applicationDirPath">QApplication::applicationDirPath</a>().</p>
117
<p>The number of entries in a directory is returned by <a href="qdir.html#count">count</a>(). You can obtain a string list of the names of all the files and directories in a directory with <a href="qdir.html#entryList">entryList</a>(). If you prefer a list of <a href="qfileinfo.html">QFileInfo</a> pointers use <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>(). Both these functions can apply a name filter, an attributes filter (e.g. read-only, files not directories, etc.), and a sort order. The filters and sort may be set with calls to <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setFilter">setFilter</a>() and <a href="qdir.html#setSorting">setSorting</a>(). They may also be specified in the <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>()'s arguments. You can test to see if a filename matches a filter using <a href="qdir.html#match">match</a>().</p>
118
<p>Create a new directory with <a href="qdir.html#mkdir">mkdir</a>(), rename a directory with <a href="qdir.html#rename">rename</a>() and remove an existing directory with <a href="qdir.html#rmdir">rmdir</a>(). Remove a file with <a href="qdir.html#remove">remove</a>(). You can query a directory with <a href="qdir.html#exists">exists</a>(), <a href="qdir.html#isReadable">isReadable</a>(), <a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#isRoot">isRoot</a>(). You can use <a href="qdir.html#refresh">refresh</a>() to re-read the directory's data from disk.</p>
119
<p>To get a path with a filename use <a href="qdir.html#filePath">filePath</a>(), and to get a directory name use <a href="qdir.html#dirName">dirName</a>(); neither of these functions checks for the existence of the file or directory. The <a href="qdir.html#path">path</a>() (changeable with <a href="qdir.html#setPath">setPath</a>()), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>() are also available.</p>
120
<p>The list of root directories is provided by <a href="qdir.html#drives">drives</a>(); on Unix systems this returns a list containing a single root directory, "/"; on Windows the list will usually contain "C:/", and possibly "D:/", etc.</p>
121
<p>It is easiest to work with "/" separators in Qt code. If you need to present a path to the user or need a path in a form suitable for a function in the underlying operating system use <a href="qdir.html#convertSeparators">convertSeparators</a>().</p>
122
<p>Example (check if a directory exists):</p>
123
<pre> QDir dir("example");
125
qWarning("Cannot find the example directory");</pre>
126
<p>(We could also use the static convenience function <a href="qfile.html#exists">QFile::exists</a>().)</p>
127
<p>Example (traversing directories and reading a file):</p>
128
<pre> QDir dir = QDir::root(); // "/"
129
if (!dir.cd("tmp")) { // "/tmp"
130
qWarning("Cannot find the \"/tmp\" directory");
132
QFile file(dir.filePath("ex1.txt")); // "/tmp/ex1.txt"
133
if (!file.open(QIODevice::ReadWrite))
134
qWarning("Cannot create the file %s", file.name());
136
<p>A program that lists all the files in the current directory (excluding symbolic links), sorted by size, smallest first:</p>
137
<pre> #include <QDir>
139
#include <stdio.h>
141
int main(int argc, char *argv[])
144
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
145
dir.setSorting(QDir::Size | QDir::Reversed);
147
QFileInfoList list = dir.entryInfoList();
148
printf(" Bytes Filename\n");
149
for (int i = 0; i < list.size(); ++i) {
150
QFileInfo fileInfo = list.at(i);
151
printf("%10li %s\n", fileInfo.size(), qPrintable(fileInfo.fileName()));
155
<p>See also <a href="qfileinfo.html">QFileInfo</a>, <a href="qfile.html">QFile</a>, and <a href="qcoreapplication.html#applicationDirPath">QApplication::applicationDirPath</a>().</p>
157
<h2>Member Type Documentation</h2>
158
<h3 class="flags"><a name="Filter-enum"></a>enum QDir::Filter<br />flags QDir::Filters</h3>
159
<p>This enum describes the filtering options available to <a href="qdir.html">QDir</a>; e.g. for <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>(). The filter value is specified by combining values from the following list using the bitwise OR operator:</p>
160
<table border="1" cellpadding="2" cellspacing="1" width="100%">
161
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
162
<tr><td valign="top"><tt>QDir::Dirs</tt></td><td align="center" valign="top"><tt>0x001</tt></td><td valign="top">List directories that match the filters.</td></tr>
163
<tr><td valign="top"><tt>QDir::AllDirs</tt></td><td align="center" valign="top"><tt>0x400</tt></td><td valign="top">List all directories; i.e. don't apply the filters to directory names.</td></tr>
164
<tr><td valign="top"><tt>QDir::Files</tt></td><td align="center" valign="top"><tt>0x002</tt></td><td valign="top">List files only.</td></tr>
165
<tr><td valign="top"><tt>QDir::Drives</tt></td><td align="center" valign="top"><tt>0x004</tt></td><td valign="top">List disk drives (ignored under Unix).</td></tr>
166
<tr><td valign="top"><tt>QDir::NoSymLinks</tt></td><td align="center" valign="top"><tt>0x008</tt></td><td valign="top">Do not list symbolic links (ignored by operating systems that don't support symbolic links).</td></tr>
167
<tr><td valign="top"><tt>QDir::All</tt></td><td align="center" valign="top"><tt>TypeMask</tt></td><td valign="top">List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System). NoSymLinks flags.</td></tr>
168
<tr><td valign="top"><tt>QDir::Readable</tt></td><td align="center" valign="top"><tt>0x010</tt></td><td valign="top">List files for which the application has read access.</td></tr>
169
<tr><td valign="top"><tt>QDir::Writable</tt></td><td align="center" valign="top"><tt>0x020</tt></td><td valign="top">List files for which the application has write access.</td></tr>
170
<tr><td valign="top"><tt>QDir::Executable</tt></td><td align="center" valign="top"><tt>0x040</tt></td><td valign="top">List files for which the application has execute access. Executables needs to be combined with Dirs or Files.</td></tr>
171
<tr><td valign="top"><tt>QDir::Modified</tt></td><td align="center" valign="top"><tt>0x080</tt></td><td valign="top">Only list files that have been modified (ignored under Unix).</td></tr>
172
<tr><td valign="top"><tt>QDir::Hidden</tt></td><td align="center" valign="top"><tt>0x100</tt></td><td valign="top">List hidden files (on Unix, files starting with a .).</td></tr>
173
<tr><td valign="top"><tt>QDir::System</tt></td><td align="center" valign="top"><tt>0x200</tt></td><td valign="top">List system files (on Unix, FIFOs, sockets and device files)</td></tr>
174
<tr><td valign="top"><tt>QDir::CaseSensitive</tt></td><td align="center" valign="top"><tt>0x800</tt></td><td valign="top">The filter should be case sensitive if the file system is case sensitive.</td></tr>
176
<p>Functions that use <tt>Filter</tt> enum values to filter lists of files and directories will include symbolic links to files and directories unless you set the <tt>NoSymLinks</tt> value.</p>
177
<p>If you do not set any of <tt>Readable</tt>, <tt>Writable</tt>, or <tt>Executable</tt>, <a href="qdir.html">QDir</a> will set all three of them. This makes the default easy to write, and at the same time useful.</p>
178
<p>Examples: <tt>Readable|Writable</tt> means list all files for which the application has read access, write access or both. <tt>Dirs|Drives</tt> means list drives, directories, all files that the application can read, write or execute, and also symlinks to such files/directories.</p>
179
<p>The Filters type is a typedef for <a href="qflags.html">QFlags</a><Filter>. It stores an OR combination of Filter values.</p>
180
<h3 class="fn"><a name="FilterSpec-typedef"></a>typedef QDir::FilterSpec</h3>
181
<p>Use <a href="qdir.html#Filter-enum">QDir::Filters</a> instead.</p>
182
<h3 class="flags"><a name="SortFlag-enum"></a>enum QDir::SortFlag<br />flags QDir::SortFlags</h3>
183
<p>This enum describes the sort options available to <a href="qdir.html">QDir</a>, e.g. for <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>(). The sort value is specified by OR-ing together values from the following list:</p>
184
<table border="1" cellpadding="2" cellspacing="1" width="100%">
185
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
186
<tr><td valign="top"><tt>QDir::Name</tt></td><td align="center" valign="top"><tt>0x00</tt></td><td valign="top">Sort by name.</td></tr>
187
<tr><td valign="top"><tt>QDir::Time</tt></td><td align="center" valign="top"><tt>0x01</tt></td><td valign="top">Sort by time (modification time).</td></tr>
188
<tr><td valign="top"><tt>QDir::Size</tt></td><td align="center" valign="top"><tt>0x02</tt></td><td valign="top">Sort by file size.</td></tr>
189
<tr><td valign="top"><tt>QDir::Unsorted</tt></td><td align="center" valign="top"><tt>0x03</tt></td><td valign="top">Do not sort.</td></tr>
190
<tr><td valign="top"><tt>QDir::DirsFirst</tt></td><td align="center" valign="top"><tt>0x04</tt></td><td valign="top">Put the directories first, then the files.</td></tr>
191
<tr><td valign="top"><tt>QDir::DirsLast</tt></td><td align="center" valign="top"><tt>0x20</tt></td><td valign="top">Put the files first, then the directories.</td></tr>
192
<tr><td valign="top"><tt>QDir::Reversed</tt></td><td align="center" valign="top"><tt>0x08</tt></td><td valign="top">Reverse the sort order.</td></tr>
193
<tr><td valign="top"><tt>QDir::IgnoreCase</tt></td><td align="center" valign="top"><tt>0x10</tt></td><td valign="top">Sort case-insensitively.</td></tr>
195
<p>You can only specify one of the first four.</p>
196
<p>If you specify both <tt>DirsFirst</tt> and <tt>Reversed</tt>, directories are still put first, but in reverse order; the files will be listed after the directories, again in reverse order.</p>
197
<p>The SortFlags type is a typedef for <a href="qflags.html">QFlags</a><SortFlag>. It stores an OR combination of SortFlag values.</p>
198
<h3 class="fn"><a name="SortSpec-typedef"></a>typedef QDir::SortSpec</h3>
199
<p>Use <a href="qdir.html#SortFlag-enum">QDir::SortFlags</a> instead.</p>
201
<h2>Member Function Documentation</h2>
202
<h3 class="fn"><a name="QDir"></a>QDir::QDir ( const QDir & <i>dir</i> )</h3>
203
<p>Constructs a <a href="qdir.html">QDir</a> object that is a copy of the <a href="qdir.html">QDir</a> object for directory <i>dir</i>.</p>
204
<p>See also <a href="qdir.html#operator-eq">operator=</a>().</p>
205
<h3 class="fn"><a name="QDir-2"></a>QDir::QDir ( const <a href="qstring.html">QString</a> & <i>path</i> = QString() )</h3>
206
<p>Constructs a <a href="qdir.html">QDir</a> pointing to the given directory <i>path</i>. If path is empty the program's working directory, ("."), is used.</p>
207
<p>See also <a href="qdir.html#currentPath">currentPath</a>().</p>
208
<h3 class="fn"><a name="QDir-3"></a>QDir::QDir ( const <a href="qstring.html">QString</a> & <i>path</i>, const <a href="qstring.html">QString</a> & <i>nameFilter</i>, <a href="qdir.html#SortFlag-enum">SortFlags</a> <i>sort</i> = SortFlags( Name | IgnoreCase ), <a href="qdir.html#Filter-enum">Filters</a> <i>filters</i> = TypeMask )</h3>
209
<p>Constructs a <a href="qdir.html">QDir</a> with path <i>path</i>, that filters its entries by name using <i>nameFilter</i> and by attributes using <i>filters</i>. It also sorts the names using <i>sort</i>.</p>
210
<p>The default <i>nameFilter</i> is an empty string, which excludes nothing; the default <i>filters</i> is <tt>TypeMask</tt>, which also means exclude nothing. The default <i>sort</i> is <tt>Name|IgnoreCase</tt>, i.e. sort by name case-insensitively.</p>
211
<p>If <i>path</i> is an empty string, <a href="qdir.html">QDir</a> uses "." (the current directory). If <i>nameFilter</i> is an empty string, <a href="qdir.html">QDir</a> uses the name filter "*" (all files).</p>
212
<p>Note that <i>path</i> need not exist.</p>
213
<p>See also <a href="qdir.html#exists">exists</a>(), <a href="qdir.html#setPath">setPath</a>(), <a href="qdir-qt3.html#setNameFilter">setNameFilter</a>(), <a href="qdir.html#setFilter">setFilter</a>(), and <a href="qdir.html#setSorting">setSorting</a>().</p>
214
<h3 class="fn"><a name="dtor.QDir"></a>QDir::~QDir ()</h3>
215
<p>Destroys the <a href="qdir.html">QDir</a> object frees up its resources. This has no effect on the underlying directory in the file system.</p>
216
<h3 class="fn"><a name="absoluteFilePath"></a><a href="qstring.html">QString</a> QDir::absoluteFilePath ( const <a href="qstring.html">QString</a> & <i>fileName</i> ) const</h3>
217
<p>Returns the absolute path name of a file in the directory. Does <i>not</i> check if the file actually exists in the directory; but see <a href="qdir.html#exists">exists</a>(). Redundant multiple separators or "." and ".." directories in <i>fileName</i> are not removed (see <a href="qdir.html#cleanPath">cleanPath</a>()).</p>
218
<p>See also <a href="qdir.html#relativeFilePath">relativeFilePath</a>(), <a href="qdir.html#filePath">filePath</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
219
<h3 class="fn"><a name="absolutePath"></a><a href="qstring.html">QString</a> QDir::absolutePath () const</h3>
220
<p>Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.</p>
221
<p>See also <a href="qdir.html#setPath">setPath</a>(), <a href="qdir.html#canonicalPath">canonicalPath</a>(), <a href="qdir.html#exists">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>().</p>
222
<h3 class="fn"><a name="addResourceSearchPath"></a>void QDir::addResourceSearchPath ( const <a href="qstring.html">QString</a> & <i>path</i> ) <tt> [static]</tt></h3>
223
<p>Adds <i>path</i> to the search paths searched in to find resources that are not specified with an absolute path. The default search path is to search only in the root (<tt>:/</tt>).</p>
224
<p>See also <a href="resources.html">The Qt Resource System</a>.</p>
225
<h3 class="fn"><a name="canonicalPath"></a><a href="qstring.html">QString</a> QDir::canonicalPath () const</h3>
226
<p>Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.</p>
227
<p>On systems that do not have symbolic links this function will always return the same string that <a href="qdir.html#absolutePath">absolutePath</a>() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns an empty string.</p>
229
<pre> QString bin = "/local/bin"; // where /local/bin is a symlink to /usr/bin
231
QString canonicalBin = binDir.canonicalPath();
232
// canonicalBin now equals "/usr/bin"
234
QString ls = "/local/bin/ls"; // where ls is the executable "ls"
236
QString canonicalLs = lsDir.canonicalPath();
237
// canonicalLS now equals "/usr/bin/ls".</pre>
238
<p>See also <a href="qdir.html#path">path</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#exists">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>().</p>
239
<h3 class="fn"><a name="cd"></a>bool QDir::cd ( const <a href="qstring.html">QString</a> & <i>dirName</i> )</h3>
240
<p>Changes the <a href="qdir.html">QDir</a>'s directory to <i>dirName</i>.</p>
241
<p>Returns true if the new directory exists and is readable; otherwise returns false. Note that the logical cd() operation is not performed if the new directory does not exist.</p>
242
<p>Calling cd("..") is equivalent to calling <a href="qdir.html#cdUp">cdUp</a>().</p>
243
<p>See also <a href="qdir.html#cdUp">cdUp</a>(), <a href="qdir.html#isReadable">isReadable</a>(), <a href="qdir.html#exists">exists</a>(), and <a href="qdir.html#path">path</a>().</p>
244
<h3 class="fn"><a name="cdUp"></a>bool QDir::cdUp ()</h3>
245
<p>Changes directory by moving one directory up from the <a href="qdir.html">QDir</a>'s current directory.</p>
246
<p>Returns true if the new directory exists and is readable; otherwise returns false. Note that the logical cdUp() operation is not performed if the new directory does not exist.</p>
247
<p>See also <a href="qdir.html#cd">cd</a>(), <a href="qdir.html#isReadable">isReadable</a>(), <a href="qdir.html#exists">exists</a>(), and <a href="qdir.html#path">path</a>().</p>
248
<h3 class="fn"><a name="cleanPath"></a><a href="qstring.html">QString</a> QDir::cleanPath ( const <a href="qstring.html">QString</a> & <i>path</i> ) <tt> [static]</tt></h3>
249
<p>Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path, <i>path</i>.</p>
250
<p>Symbolic links are kept. This function does not return the canonical path, but rather the simplest version of the input. For example, "./local" becomes "local", "local/../bin" becomes "bin" and "/local/usr/../bin" becomes "/local/bin".</p>
251
<p>See also <a href="qdir.html#absolutePath">absolutePath</a>() and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
252
<h3 class="fn"><a name="convertSeparators"></a><a href="qstring.html">QString</a> QDir::convertSeparators ( const <a href="qstring.html">QString</a> & <i>pathName</i> ) <tt> [static]</tt></h3>
253
<p>Returns <i>pathName</i> with the '/' separators converted to separators that are appropriate for the underlying operating system.</p>
254
<p>On Windows, convertSeparators("c:/winnt/system32") returns "c:\winnt\system32".</p>
255
<p>The returned string may be the same as the argument on some operating systems, for example on Unix.</p>
256
<p>See also <a href="qdir.html#separator">separator</a>().</p>
257
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> QDir::count () const</h3>
258
<p>Returns the total number of directories and files in the directory.</p>
259
<p>Equivalent to <a href="qdir.html#entryList">entryList</a>().count().</p>
260
<p>See also <a href="qdir.html#operator-5b-5d">operator[]</a>() and <a href="qdir.html#entryList">entryList</a>().</p>
261
<h3 class="fn"><a name="current"></a>QDir QDir::current () <tt> [static]</tt></h3>
262
<p>Returns the absolute path of the application's current directory. See <a href="qdir.html#currentPath">currentPath</a>() for details.</p>
263
<p>See also <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#homePath">homePath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
264
<h3 class="fn"><a name="currentPath"></a><a href="qstring.html">QString</a> QDir::currentPath () <tt> [static]</tt></h3>
265
<p>Returns the absolute path of the application's current directory.</p>
266
<p>See also <a href="qdir.html#current">current</a>(), <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#homePath">homePath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
267
<h3 class="fn"><a name="dirName"></a><a href="qstring.html">QString</a> QDir::dirName () const</h3>
268
<p>Returns the name of the directory; this is <i>not</i> the same as the path, e.g. a directory with the name "mail", might have the path "/var/spool/mail". If the directory has no name (e.g. it is the root directory) an empty string is returned.</p>
269
<p>No check is made to ensure that a directory with this name actually exists; but see <a href="qdir.html#exists">exists</a>().</p>
270
<p>See also <a href="qdir.html#path">path</a>(), <a href="qdir.html#filePath">filePath</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>().</p>
271
<h3 class="fn"><a name="drives"></a>QFileInfoList QDir::drives () <tt> [static]</tt></h3>
272
<p>Returns a list of the root directories on this system. On Windows this returns a number of <a href="qfileinfo.html">QFileInfo</a> objects containing "C:/", "D:/", etc. On other operating systems, it returns a list containing just one root directory (i.e. "/").</p>
273
<h3 class="fn"><a name="entryInfoList-2"></a>QFileInfoList QDir::entryInfoList ( <a href="qdir.html#Filter-enum">Filters</a> <i>filters</i> = NoFilter, <a href="qdir.html#SortFlag-enum">SortFlags</a> <i>sort</i> = NoSort ) const</h3>
274
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
275
<p>Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and directories in the directory, ordered in accordance with <a href="qdir.html#setSorting">setSorting</a>() and filtered in accordance with <a href="qdir.html#setFilter">setFilter</a>() and <a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
276
<p>The filter and sorting specifications can be overridden using the <i>filters</i> and <i>sort</i> arguments.</p>
277
<p>Returns an empty list if the directory is unreadable or does not exist or if nothing matches the specification.</p>
278
<p>See also <a href="qdir.html#entryList">entryList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), <a href="qdir.html#setFilter">setFilter</a>(), <a href="qdir.html#isReadable">isReadable</a>(), and <a href="qdir.html#exists">exists</a>().</p>
279
<h3 class="fn"><a name="entryInfoList-3"></a>QFileInfoList QDir::entryInfoList ( const <a href="qstringlist.html">QStringList</a> & <i>nameFilters</i>, <a href="qdir.html#Filter-enum">Filters</a> <i>filters</i> = NoFilter, <a href="qdir.html#SortFlag-enum">SortFlags</a> <i>sort</i> = NoSort ) const</h3>
280
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
281
<p>Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and directories in the directory, ordered in accordance with <a href="qdir.html#setSorting">setSorting</a>() and filtered in accordance with <a href="qdir.html#setFilter">setFilter</a>() and <a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
282
<p>The name filter, file attributes filter, and sorting specifications can be overridden using the <i>nameFilters</i>, <i>filters</i>, and <i>sort</i> arguments.</p>
283
<p>Returns an empty list if the directory is unreadable or does not exist or if nothing matches the specification.</p>
284
<p>See also <a href="qdir.html#entryList">entryList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), <a href="qdir.html#setFilter">setFilter</a>(), <a href="qdir.html#isReadable">isReadable</a>(), and <a href="qdir.html#exists">exists</a>().</p>
285
<h3 class="fn"><a name="entryList"></a><a href="qstringlist.html">QStringList</a> QDir::entryList ( const <a href="qstringlist.html">QStringList</a> & <i>nameFilters</i>, <a href="qdir.html#Filter-enum">Filters</a> <i>filters</i> = NoFilter, <a href="qdir.html#SortFlag-enum">SortFlags</a> <i>sort</i> = NoSort ) const</h3>
286
<p>Returns a list of the names of all the files and directories in the directory, ordered in accordance with <a href="qdir.html#setSorting">setSorting</a>() and filtered in accordance with <a href="qdir.html#setFilter">setFilter</a>() and <a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
287
<p>The name filter, file attributes filter, and the sorting specifications can be overridden using the <i>nameFilters</i>, <i>filters</i> and <i>sort</i> arguments.</p>
288
<p>Returns an empty list if the directory is unreadable or does not exist or if nothing matches the specification.</p>
289
<p>See also <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), and <a href="qdir.html#setFilter">setFilter</a>().</p>
290
<h3 class="fn"><a name="entryList-3"></a><a href="qstringlist.html">QStringList</a> QDir::entryList ( <a href="qdir.html#Filter-enum">Filters</a> <i>filters</i> = NoFilter, <a href="qdir.html#SortFlag-enum">SortFlags</a> <i>sort</i> = NoSort ) const</h3>
291
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
292
<p>Returns a list of the names of all the files and directories in the directory, ordered in accordance with <a href="qdir.html#setSorting">setSorting</a>() and filtered in accordance with <a href="qdir.html#setFilter">setFilter</a>() and <a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
293
<p>The filter and sorting specifications can be overridden using the <i>filters</i> and <i>sort</i> arguments.</p>
294
<p>Returns an empty list if the directory is unreadable or does not exist or if nothing matches the specification.</p>
295
<p>See also <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), and <a href="qdir.html#setFilter">setFilter</a>().</p>
296
<h3 class="fn"><a name="exists"></a>bool QDir::exists ( const <a href="qstring.html">QString</a> & <i>name</i> ) const</h3>
297
<p>Returns true if the file called <i>name</i> exists; otherwise returns false.</p>
298
<p>See also <a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists">QFile::exists</a>().</p>
299
<h3 class="fn"><a name="exists-2"></a>bool QDir::exists () const</h3>
300
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
301
<p>Returns true if the <i>directory</i> exists; otherwise returns false. (If a file with the same name is found this function will return false).</p>
302
<p>See also <a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists">QFile::exists</a>().</p>
303
<h3 class="fn"><a name="filePath"></a><a href="qstring.html">QString</a> QDir::filePath ( const <a href="qstring.html">QString</a> & <i>fileName</i> ) const</h3>
304
<p>Returns the path name of a file in the directory. Does <i>not</i> check if the file actually exists in the directory; but see <a href="qdir.html#exists">exists</a>(). If the <a href="qdir.html">QDir</a> is relative the returned path name will also be relative. Redundant multiple separators or "." and ".." directories in <i>fileName</i> are not removed (see <a href="qdir.html#cleanPath">cleanPath</a>()).</p>
305
<p>See also <a href="qdir.html#dirName">dirName</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
306
<h3 class="fn"><a name="filter"></a><a href="qdir.html#Filter-enum">Filters</a> QDir::filter () const</h3>
307
<p>Returns the value set by <a href="qdir.html#setFilter">setFilter</a>()</p>
308
<h3 class="fn"><a name="home"></a>QDir QDir::home () <tt> [static]</tt></h3>
309
<p>Returns the user's home directory. See <a href="qdir.html#homePath">homePath</a>() for details.</p>
310
<p>See also <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
311
<h3 class="fn"><a name="homePath"></a><a href="qstring.html">QString</a> QDir::homePath () <tt> [static]</tt></h3>
312
<p>Returns the user's home directory.</p>
313
<p>Under Windows the <tt>HOME</tt> environment variable is used. If this does not exist the <tt>USERPROFILE</tt> environment variable is used. If that does not exist the path is formed by concatenating the <tt>HOMEDRIVE</tt> and <tt>HOMEPATH</tt> environment variables. If they don't exist the <a href="qdir.html#rootPath">rootPath</a>() is used (this uses the <tt>SystemDrive</tt> environment variable). If none of these exist "C:" is used.</p>
314
<p>Under non-Windows operating systems the <tt>HOME</tt> environment variable is used if it exists, otherwise <a href="qdir.html#rootPath">rootPath</a>() is used.</p>
315
<p>See also <a href="qdir.html#home">home</a>(), <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
316
<h3 class="fn"><a name="isAbsolute"></a>bool QDir::isAbsolute () const</h3>
317
<p>Returns true if the directory's path is absolute; otherwise returns false. See <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>().</p>
318
<p>See also <a href="qdir.html#isRelative">isRelative</a>(), <a href="qdir.html#makeAbsolute">makeAbsolute</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
319
<h3 class="fn"><a name="isAbsolutePath"></a>bool QDir::isAbsolutePath ( const <a href="qstring.html">QString</a> & <i>path</i> ) <tt> [static]</tt></h3>
320
<p>Returns true if <i>path</i> is absolute; returns false if it is relative.</p>
321
<p>See also <a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isRelativePath">isRelativePath</a>(), <a href="qdir.html#makeAbsolute">makeAbsolute</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
322
<h3 class="fn"><a name="isReadable"></a>bool QDir::isReadable () const</h3>
323
<p>Returns true if the directory is readable <i>and</i> we can open files by name; otherwise returns false.</p>
324
<p><b>Warning:</b> A false value from this function is not a guarantee that files in the directory are not accessible.</p>
325
<p>See also <a href="qfileinfo.html#isReadable">QFileInfo::isReadable</a>().</p>
326
<h3 class="fn"><a name="isRelative"></a>bool QDir::isRelative () const</h3>
327
<p>Returns true if the directory path is relative; otherwise returns false. (Under Unix a path is relative if it does not start with a "/").</p>
328
<p>See also <a href="qdir.html#makeAbsolute">makeAbsolute</a>(), <a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
329
<h3 class="fn"><a name="isRelativePath"></a>bool QDir::isRelativePath ( const <a href="qstring.html">QString</a> & <i>path</i> ) <tt> [static]</tt></h3>
330
<p>Returns true if <i>path</i> is relative; returns false if it is absolute.</p>
331
<p>See also <a href="qdir.html#isRelative">isRelative</a>(), <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>(), and <a href="qdir.html#makeAbsolute">makeAbsolute</a>().</p>
332
<h3 class="fn"><a name="isRoot"></a>bool QDir::isRoot () const</h3>
333
<p>Returns true if the directory is the root directory; otherwise returns false.</p>
334
<p>Note: If the directory is a symbolic link to the root directory this function returns false. If you want to test for this use <a href="qdir.html#canonicalPath">canonicalPath</a>(), e.g.</p>
335
<pre> QDir dir("/tmp/root_link");
336
dir = dir.canonicalPath();
338
qWarning("It is a root link");</pre>
339
<p>See also <a href="qdir.html#root">root</a>() and <a href="qdir.html#rootPath">rootPath</a>().</p>
340
<h3 class="fn"><a name="makeAbsolute"></a>bool QDir::makeAbsolute ()</h3>
341
<p>Converts the directory path to an absolute path. If it is already absolute nothing happens. Returns true if the conversion succeeded; otherwise returns false.</p>
342
<p>See also <a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
343
<h3 class="fn"><a name="match"></a>bool QDir::match ( const <a href="qstring.html">QString</a> & <i>filter</i>, const <a href="qstring.html">QString</a> & <i>fileName</i> ) <tt> [static]</tt></h3>
344
<p>Returns true if the <i>fileName</i> matches the wildcard (glob) pattern <i>filter</i>; otherwise returns false. The <i>filter</i> may contain multiple patterns separated by spaces or semicolons. The matching is case insensitive.</p>
345
<p>See also <a href="qregexp.html#qregexp-wildcard-matching">QRegExp wildcard matching</a>, <a href="qregexp.html#exactMatch">QRegExp::exactMatch</a>(), <a href="qdir.html#entryList">entryList</a>(), and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>().</p>
346
<h3 class="fn"><a name="match-2"></a>bool QDir::match ( const <a href="qstringlist.html">QStringList</a> & <i>filters</i>, const <a href="qstring.html">QString</a> & <i>fileName</i> ) <tt> [static]</tt></h3>
347
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
348
<p>Returns true if the <i>fileName</i> matches any of the wildcard (glob) patterns in the list of <i>filters</i>; otherwise returns false. The matching is case insensitive.</p>
349
<p>See also <a href="qregexp.html#qregexp-wildcard-matching">QRegExp wildcard matching</a>, <a href="qregexp.html#exactMatch">QRegExp::exactMatch</a>(), <a href="qdir.html#entryList">entryList</a>(), and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>().</p>
350
<h3 class="fn"><a name="mkdir"></a>bool QDir::mkdir ( const <a href="qstring.html">QString</a> & <i>dirName</i> ) const</h3>
351
<p>Creates a sub-directory called <i>dirName</i>.</p>
352
<p>Returns true on success; otherwise returns false.</p>
353
<p>See also <a href="qdir.html#rmdir">rmdir</a>().</p>
354
<h3 class="fn"><a name="mkpath"></a>bool QDir::mkpath ( const <a href="qstring.html">QString</a> & <i>dirPath</i> ) const</h3>
355
<p>Creates the directory path <i>dirPath</i>.</p>
356
<p>The function will create all parent directories necessary to create the directory.</p>
357
<p>Returns true if successful; otherwise returns false.</p>
358
<p>See also <a href="qdir.html#rmpath">rmpath</a>().</p>
359
<h3 class="fn"><a name="nameFilters"></a><a href="qstringlist.html">QStringList</a> QDir::nameFilters () const</h3>
360
<p>Returns the string list set by <a href="qdir.html#setNameFilters">setNameFilters</a>()</p>
361
<h3 class="fn"><a name="path"></a><a href="qstring.html">QString</a> QDir::path () const</h3>
362
<p>Returns the path. This may contain symbolic links, but never contains redundant ".", ".." or multiple separators.</p>
363
<p>The returned path can be either absolute or relative (see <a href="qdir.html#setPath">setPath</a>()).</p>
364
<p>See also <a href="qdir.html#setPath">setPath</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#exists">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#convertSeparators">convertSeparators</a>(), and <a href="qdir.html#makeAbsolute">makeAbsolute</a>().</p>
365
<h3 class="fn"><a name="refresh"></a>void QDir::refresh () const</h3>
366
<p>Refreshes the directory information.</p>
367
<h3 class="fn"><a name="relativeFilePath"></a><a href="qstring.html">QString</a> QDir::relativeFilePath ( const <a href="qstring.html">QString</a> & <i>fileName</i> ) const</h3>
368
<p>Returns the path to <i>fileName</i> relative to the directory.</p>
369
<pre> QDir dir("/home/bob");
372
s = dir.relativePath("images/file.jpg"); // s is "images/file.jpg"
373
s = dir.relativePath("/home/mary/file.txt"); // s is "../mary/file.txt"</pre>
374
<p>See also <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#filePath">filePath</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
375
<h3 class="fn"><a name="remove"></a>bool QDir::remove ( const <a href="qstring.html">QString</a> & <i>fileName</i> )</h3>
376
<p>Removes the file, <i>fileName</i>.</p>
377
<p>Returns true if the file is removed successfully; otherwise returns false.</p>
378
<h3 class="fn"><a name="rename"></a>bool QDir::rename ( const <a href="qstring.html">QString</a> & <i>oldName</i>, const <a href="qstring.html">QString</a> & <i>newName</i> )</h3>
379
<p>Renames a file or directory from <i>oldName</i> to <i>newName</i>, and returns true if successful; otherwise returns false.</p>
380
<p>On most file systems, rename() fails only if <i>oldName</i> does not exist or if <i>newName</i> and <i>oldName</i> are not on the same partition. On Windows, rename() will fail if <i>newName</i> already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if <i>newName</i> points to an open file.</p>
381
<h3 class="fn"><a name="rmdir"></a>bool QDir::rmdir ( const <a href="qstring.html">QString</a> & <i>dirName</i> ) const</h3>
382
<p>Removes the directory specified by <i>dirName</i>.</p>
383
<p>The directory must be empty for rmdir() to succeed.</p>
384
<p>Returns true if successful; otherwise returns false.</p>
385
<p>See also <a href="qdir.html#mkdir">mkdir</a>().</p>
386
<h3 class="fn"><a name="rmpath"></a>bool QDir::rmpath ( const <a href="qstring.html">QString</a> & <i>dirPath</i> ) const</h3>
387
<p>Removes the directory path <i>dirPath</i>.</p>
388
<p>The function will remove all parent directories in <i>dirPath</i>, provided that they are empty. This is the opposite of mkpath(dirPath).</p>
389
<p>Returns true if successful; otherwise returns false.</p>
390
<p>See also <a href="qdir.html#mkpath">mkpath</a>().</p>
391
<h3 class="fn"><a name="root"></a>QDir QDir::root () <tt> [static]</tt></h3>
392
<p>Returns the root directory. See <a href="qdir.html#rootPath">rootPath</a>() for details.</p>
393
<p>See also <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#current">current</a>(), <a href="qdir.html#home">home</a>(), and <a href="qdir.html#temp">temp</a>().</p>
394
<h3 class="fn"><a name="rootPath"></a><a href="qstring.html">QString</a> QDir::rootPath () <tt> [static]</tt></h3>
395
<p>Returns the absolute path for the root directory.</p>
396
<p>For Unix operating systems this returns "/". For Windows file systems this normally returns "c:/".</p>
397
<p>See also <a href="qdir.html#root">root</a>(), <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#homePath">homePath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
398
<h3 class="fn"><a name="separator"></a><a href="qchar.html">QChar</a> QDir::separator () <tt> [static]</tt></h3>
399
<p>Returns the native directory separator: "/" under Unix (including Mac OS X) and "" under Windows.</p>
400
<p>You do not need to use this function to build file paths. If you always use "/", Qt will translate your paths to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use <a href="qdir.html#convertSeparators">convertSeparators</a>().</p>
401
<h3 class="fn"><a name="setCurrent"></a>bool QDir::setCurrent ( const <a href="qstring.html">QString</a> & <i>path</i> ) <tt> [static]</tt></h3>
402
<p>Sets the application's current working directory to <i>path</i>. Returns true if the directory was successfully changed; otherwise returns false.</p>
403
<p>See also <a href="qdir.html#current">current</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#home">home</a>(), <a href="qdir.html#root">root</a>(), and <a href="qdir.html#temp">temp</a>().</p>
404
<h3 class="fn"><a name="setFilter"></a>void QDir::setFilter ( <a href="qdir.html#Filter-enum">Filters</a> <i>filters</i> )</h3>
405
<p>Sets the filter used by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>() to <i>filters</i>. The filter is used to specify the kind of files that should be returned by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>(). See <a href="qdir.html#Filter-enum">QDir::Filter</a>.</p>
406
<p>See also <a href="qdir.html#filter">filter</a>() and <a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
407
<h3 class="fn"><a name="setNameFilters"></a>void QDir::setNameFilters ( const <a href="qstringlist.html">QStringList</a> & <i>nameFilters</i> )</h3>
408
<p>Sets the name filters used by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>() to the list of filters specified by <i>nameFilters</i>.</p>
409
<p>See also <a href="qdir.html#nameFilters">nameFilters</a>() and <a href="qdir.html#setFilter">setFilter</a>().</p>
410
<h3 class="fn"><a name="setPath"></a>void QDir::setPath ( const <a href="qstring.html">QString</a> & <i>path</i> )</h3>
411
<p>Sets the path of the directory to <i>path</i>. The path is cleaned of redundant ".", ".." and of multiple separators. No check is made to see whether a directory with this path actually exists; but you can check for yourself using <a href="qdir.html#exists">exists</a>().</p>
412
<p>The path can be either absolute or relative. Absolute paths begin with the directory separator "/" (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory. An example of an absolute path is the string "/tmp/quartz", a relative path might look like "src/fatlib".</p>
413
<p>See also <a href="qdir.html#path">path</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#exists">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#makeAbsolute">makeAbsolute</a>().</p>
414
<h3 class="fn"><a name="setSorting"></a>void QDir::setSorting ( <a href="qdir.html#SortFlag-enum">SortFlags</a> <i>sort</i> )</h3>
415
<p>Sets the sort order used by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir-qt3.html#entryInfoList">entryInfoList</a>().</p>
416
<p>The <i>sort</i> is specified by OR-ing values from the enum <a href="qdir.html#SortFlag-enum">QDir::SortFlag</a>.</p>
417
<p>See also <a href="qdir.html#sorting">sorting</a>() and <a href="qdir.html#SortFlag-enum">SortFlag</a>.</p>
418
<h3 class="fn"><a name="sorting"></a><a href="qdir.html#SortFlag-enum">SortFlags</a> QDir::sorting () const</h3>
419
<p>Returns the value set by <a href="qdir.html#setSorting">setSorting</a>()</p>
420
<p>See also <a href="qdir.html#setSorting">setSorting</a>() and <a href="qdir.html#SortFlag-enum">SortFlag</a>.</p>
421
<h3 class="fn"><a name="temp"></a>QDir QDir::temp () <tt> [static]</tt></h3>
422
<p>Returns the system's temporary directory. See <a href="qdir.html#tempPath">tempPath</a>() for details.</p>
423
<p>See also <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#homePath">homePath</a>(), and <a href="qdir.html#rootPath">rootPath</a>().</p>
424
<h3 class="fn"><a name="tempPath"></a><a href="qstring.html">QString</a> QDir::tempPath () <tt> [static]</tt></h3>
425
<p>Returns the system's temporary directory.</p>
426
<p>On Unix/Linux systems this is usually <tt>/tmp</tt>; on Windows this is usually the path in the <tt>TEMP</tt> or <tt>TMP</tt> environment variable.</p>
427
<p>See also <a href="qdir.html#temp">temp</a>(), <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#homePath">homePath</a>(), and <a href="qdir.html#rootPath">rootPath</a>().</p>
428
<h3 class="fn"><a name="operator-not-eq"></a>bool QDir::operator!= ( const QDir & <i>dir</i> ) const</h3>
429
<p>Returns true if directory <i>dir</i> and this directory have different paths or different sort or filter settings; otherwise returns false.</p>
431
<pre> // The current directory is "/usr/local"
432
QDir d1("/usr/local/bin");
433
QDir d2("bin");
435
qDebug("They differ");</pre>
436
<h3 class="fn"><a name="operator-eq"></a>QDir & QDir::operator= ( const QDir & <i>dir</i> )</h3>
437
<p>Makes a copy of the <i>dir</i> object and assigns it to this <a href="qdir.html">QDir</a> object.</p>
438
<h3 class="fn"><a name="operator-eq-eq"></a>bool QDir::operator== ( const QDir & <i>dir</i> ) const</h3>
439
<p>Returns true if directory <i>dir</i> and this directory have the same path and their sort and filter settings are the same; otherwise returns false.</p>
441
<pre> // The current directory is "/usr/local"
442
QDir d1("/usr/local/bin");
443
QDir d2("bin");
445
qDebug("They're the same");</pre>
446
<h3 class="fn"><a name="operator-5b-5d"></a><a href="qstring.html">QString</a> QDir::operator[] ( int <i>pos</i> ) const</h3>
447
<p>Returns the file name at position <i>pos</i> in the list of file names. Equivalent to <a href="qdir.html#entryList">entryList</a>().at(index).</p>
448
<p>Returns an empty string if <i>pos</i> is out of range or if the <a href="qdir.html#entryList">entryList</a>() function failed.</p>
449
<p>See also <a href="qdir.html#count">count</a>() and <a href="qdir.html#entryList">entryList</a>().</p>
450
<p /><address><hr /><div align="center">
451
<table width="100%" cellspacing="0" border="0"><tr class="address">
452
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
453
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
454
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
455
</tr></table></div></address></body>