source: trunk/doc/html/qdir.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 51.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qdir.cpp:56 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QDir Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDir Class Reference</h1>
33
34<p>The QDir class provides access to directory structures and their contents in a platform-independent way.
35<a href="#details">More...</a>
36<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
37<p><tt>#include &lt;<a href="qdir-h.html">qdir.h</a>&gt;</tt>
38<p><a href="qdir-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn>enum <a href="#FilterSpec-enum"><b>FilterSpec</b></a> { Dirs = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008, All = 0x007, TypeMask = 0x00F, Readable = 0x010, Writable = 0x020, Executable = 0x040, RWEMask = 0x070, Modified = 0x080, Hidden = 0x100, System = 0x200, AccessMask = 0x3F0, DefaultFilter = -1 }</li>
42<li class=fn>enum <a href="#SortSpec-enum"><b>SortSpec</b></a> { Name = 0x00, Time = 0x01, Size = 0x02, Unsorted = 0x03, SortByMask = 0x03, DirsFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10, LocaleAware = 0x20, DefaultSort = -1 }</li>
43<li class=fn><a href="#QDir"><b>QDir</b></a> ()</li>
44<li class=fn><a href="#QDir-2"><b>QDir</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;path, const&nbsp;QString&nbsp;&amp;&nbsp;nameFilter = QString::null, int&nbsp;sortSpec = Name | IgnoreCase, int&nbsp;filterSpec = All )</li>
45<li class=fn><a href="#QDir-3"><b>QDir</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d )</li>
46<li class=fn>virtual <a href="#~QDir"><b>~QDir</b></a> ()</li>
47<li class=fn>QDir &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d )</li>
48<li class=fn>QDir &amp; <a href="#operator-eq-2"><b>operator=</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;path )</li>
49<li class=fn>virtual void <a href="#setPath"><b>setPath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;path )</li>
50<li class=fn>virtual QString <a href="#path"><b>path</b></a> () const</li>
51<li class=fn>virtual QString <a href="#absPath"><b>absPath</b></a> () const</li>
52<li class=fn>virtual QString <a href="#canonicalPath"><b>canonicalPath</b></a> () const</li>
53<li class=fn>virtual QString <a href="#dirName"><b>dirName</b></a> () const</li>
54<li class=fn>virtual QString <a href="#filePath"><b>filePath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, bool&nbsp;acceptAbsPath = TRUE ) const</li>
55<li class=fn>virtual QString <a href="#absFilePath"><b>absFilePath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, bool&nbsp;acceptAbsPath = TRUE ) const</li>
56<li class=fn>virtual bool <a href="#cd"><b>cd</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dirName, bool&nbsp;acceptAbsPath = TRUE )</li>
57<li class=fn>virtual bool <a href="#cdUp"><b>cdUp</b></a> ()</li>
58<li class=fn>QString <a href="#nameFilter"><b>nameFilter</b></a> () const</li>
59<li class=fn>virtual void <a href="#setNameFilter"><b>setNameFilter</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nameFilter )</li>
60<li class=fn>FilterSpec <a href="#filter"><b>filter</b></a> () const</li>
61<li class=fn>virtual void <a href="#setFilter"><b>setFilter</b></a> ( int&nbsp;filterSpec )</li>
62<li class=fn>SortSpec <a href="#sorting"><b>sorting</b></a> () const</li>
63<li class=fn>virtual void <a href="#setSorting"><b>setSorting</b></a> ( int&nbsp;sortSpec )</li>
64<li class=fn>bool <a href="#matchAllDirs"><b>matchAllDirs</b></a> () const</li>
65<li class=fn>virtual void <a href="#setMatchAllDirs"><b>setMatchAllDirs</b></a> ( bool&nbsp;enable )</li>
66<li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
67<li class=fn>QString <a href="#operator[]"><b>operator[]</b></a> ( int&nbsp;index ) const</li>
68<li class=fn>virtual QStrList encodedEntryList ( int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const &nbsp;<em>(obsolete)</em></li>
69<li class=fn>virtual QStrList encodedEntryList ( const&nbsp;QString&nbsp;&amp;&nbsp;nameFilter, int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const &nbsp;<em>(obsolete)</em></li>
70<li class=fn>virtual QStringList <a href="#entryList-2"><b>entryList</b></a> ( int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const</li>
71<li class=fn>virtual QStringList <a href="#entryList"><b>entryList</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nameFilter, int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const</li>
72<li class=fn>virtual const QFileInfoList * <a href="#entryInfoList-2"><b>entryInfoList</b></a> ( int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const</li>
73<li class=fn>virtual const QFileInfoList * <a href="#entryInfoList"><b>entryInfoList</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nameFilter, int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const</li>
74<li class=fn>virtual bool <a href="#mkdir"><b>mkdir</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dirName, bool&nbsp;acceptAbsPath = TRUE ) const</li>
75<li class=fn>virtual bool <a href="#rmdir"><b>rmdir</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dirName, bool&nbsp;acceptAbsPath = TRUE ) const</li>
76<li class=fn>virtual bool <a href="#isReadable"><b>isReadable</b></a> () const</li>
77<li class=fn>virtual bool <a href="#exists-2"><b>exists</b></a> () const</li>
78<li class=fn>virtual bool <a href="#isRoot"><b>isRoot</b></a> () const</li>
79<li class=fn>virtual bool <a href="#isRelative"><b>isRelative</b></a> () const</li>
80<li class=fn>virtual void <a href="#convertToAbs"><b>convertToAbs</b></a> ()</li>
81<li class=fn>virtual bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d ) const</li>
82<li class=fn>virtual bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d ) const</li>
83<li class=fn>virtual bool <a href="#remove"><b>remove</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, bool&nbsp;acceptAbsPath = TRUE )</li>
84<li class=fn>virtual bool <a href="#rename"><b>rename</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;oldName, const&nbsp;QString&nbsp;&amp;&nbsp;newName, bool&nbsp;acceptAbsPaths = TRUE )</li>
85<li class=fn>virtual bool <a href="#exists"><b>exists</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, bool&nbsp;acceptAbsPath = TRUE )</li>
86<li class=fn>void <a href="#refresh"><b>refresh</b></a> () const</li>
87</ul>
88<h2>Static Public Members</h2>
89<ul>
90<li class=fn>QString <a href="#convertSeparators"><b>convertSeparators</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;pathName )</li>
91<li class=fn>const QFileInfoList * <a href="#drives"><b>drives</b></a> ()</li>
92<li class=fn>char <a href="#separator"><b>separator</b></a> ()</li>
93<li class=fn>bool <a href="#setCurrent"><b>setCurrent</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;path )</li>
94<li class=fn>QDir <a href="#current"><b>current</b></a> ()</li>
95<li class=fn>QDir <a href="#home"><b>home</b></a> ()</li>
96<li class=fn>QDir <a href="#root"><b>root</b></a> ()</li>
97<li class=fn>QString <a href="#currentDirPath"><b>currentDirPath</b></a> ()</li>
98<li class=fn>QString <a href="#homeDirPath"><b>homeDirPath</b></a> ()</li>
99<li class=fn>QString <a href="#rootDirPath"><b>rootDirPath</b></a> ()</li>
100<li class=fn>bool <a href="#match-2"><b>match</b></a> ( const&nbsp;QStringList&nbsp;&amp;&nbsp;filters, const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
101<li class=fn>bool <a href="#match"><b>match</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filter, const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
102<li class=fn>QString <a href="#cleanDirPath"><b>cleanDirPath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filePath )</li>
103<li class=fn>bool <a href="#isRelativePath"><b>isRelativePath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;path )</li>
104</ul>
105<hr><a name="details"></a><h2>Detailed Description</h2>
106
107
108
109The QDir class provides access to directory structures and their contents in a platform-independent way.
110<p>
111
112<p> A QDir is used to manipulate path names, access information
113regarding paths and files, and manipulate the underlying file
114system.
115<p> A QDir can point to a file using either a relative or an absolute
116path. Absolute paths begin with the directory separator "/"
117(optionally preceded by a drive specification under Windows). If
118you always use "/" as a directory separator, Qt will translate
119your paths to conform to the underlying operating system. Relative
120file names begin with a directory name or a file name and specify
121a path relative to the current directory.
122<p> The "current" path refers to the application's working directory.
123A QDir's own path is set and retrieved with <a href="#setPath">setPath</a>() and <a href="#path">path</a>().
124<p> An example of an absolute path is the string "/tmp/quartz", a
125relative path might look like "src/fatlib". You can use the
126function <a href="#isRelative">isRelative</a>() to check if a QDir is using a relative or an
127absolute file path. Call <a href="#convertToAbs">convertToAbs</a>() to convert a relative QDir
128to an absolute one. For a simplified path use <a href="#cleanDirPath">cleanDirPath</a>(). To
129obtain a path which has no symbolic links or redundant ".."
130elements use <a href="#canonicalPath">canonicalPath</a>(). The path can be set with setPath(),
131and changed with <a href="#cd">cd</a>() and <a href="#cdUp">cdUp</a>().
132<p> QDir provides several static functions, for example, <a href="#setCurrent">setCurrent</a>()
133to set the application's working directory and <a href="#currentDirPath">currentDirPath</a>() to
134retrieve the application's working directory. Access to some
135common paths is provided with the static functions, <a href="#current">current</a>(),
136<a href="#home">home</a>() and <a href="#root">root</a>() which return QDir objects or currentDirPath(),
137<a href="#homeDirPath">homeDirPath</a>() and <a href="#rootDirPath">rootDirPath</a>() which return the path as a string.
138If you want to know about your application's path use
139<a href="qapplication.html#applicationDirPath">QApplication::applicationDirPath</a>().
140<p> The number of entries in a directory is returned by <a href="#count">count</a>().
141Obtain a string list of the names of all the files and directories
142in a directory with <a href="#entryList">entryList</a>(). If you prefer a list of <a href="qfileinfo.html">QFileInfo</a>
143pointers use <a href="#entryInfoList">entryInfoList</a>(). Both these functions can apply a
144name filter, an attributes filter (e.g. read-only, files not
145directories, etc.), and a sort order. The filters and sort may be
146set with calls to <a href="#setNameFilter">setNameFilter</a>(), <a href="#setFilter">setFilter</a>() and <a href="#setSorting">setSorting</a>().
147They may also be specified in the entryList() and
148entryInfoList()'s arguments.
149<p> Create a new directory with <a href="#mkdir">mkdir</a>(), rename a directory with
150<a href="#rename">rename</a>() and remove an existing directory with <a href="#rmdir">rmdir</a>(). Remove a
151file with <a href="#remove">remove</a>(). You can interrogate a directory with <a href="#exists">exists</a>(),
152<a href="#isReadable">isReadable</a>() and <a href="#isRoot">isRoot</a>().
153<p> To get a path with a filename use <a href="#filePath">filePath</a>(), and to get a
154directory name use <a href="#dirName">dirName</a>(); neither of these functions checks
155for the existence of the file or directory.
156<p> The list of root directories is provided by <a href="#drives">drives</a>(); on Unix
157systems this returns a list containing one root directory, "/"; on
158Windows the list will usually contain "C:/", and possibly "D:/",
159etc.
160<p> It is easiest to work with "/" separators in Qt code. If you need
161to present a path to the user or need a path in a form suitable
162for a function in the underlying operating system use
163<a href="#convertSeparators">convertSeparators</a>().
164<p> Examples:
165<p> See if a directory exists.
166<pre>
167 QDir d( "example" ); // "./example"
168 if ( !d.<a href="#exists">exists</a>() )
169 <a href="qapplication.html#qWarning">qWarning</a>( "Cannot find the example directory" );
170 </pre>
171
172<p> Traversing directories and reading a file.
173<pre>
174 QDir d = QDir::<a href="#root">root</a>(); // "/"
175 if ( !d.<a href="#cd">cd</a>("tmp") ) { // "/tmp"
176 <a href="qapplication.html#qWarning">qWarning</a>( "Cannot find the \"/tmp\" directory" );
177 } else {
178 <a href="qfile.html">QFile</a> f( d.<a href="#filePath">filePath</a>("ex1.txt") ); // "/tmp/ex1.txt"
179 if ( !f.<a href="qfile.html#open">open</a>(IO_ReadWrite) )
180 <a href="qapplication.html#qWarning">qWarning</a>( "Cannot create the file %s", f.<a href="qfile.html#name">name</a>() );
181 }
182 </pre>
183
184<p> A program that lists all the files in the current directory
185(excluding symbolic links), sorted by size, smallest first:
186<pre>
187 #include &lt;stdio.h&gt;
188 #include &lt;<a href="qdir-h.html">qdir.h</a>&gt;
189
190 int main( int argc, char **argv )
191 {
192 QDir d;
193 d.<a href="#setFilter">setFilter</a>( QDir::<a href="#FilterSpec-enum">Files</a> | QDir::<a href="#FilterSpec-enum">Hidden</a> | QDir::<a href="#FilterSpec-enum">NoSymLinks</a> );
194 d.<a href="#setSorting">setSorting</a>( QDir::<a href="#SortSpec-enum">Size</a> | QDir::<a href="#SortSpec-enum">Reversed</a> );
195
196 const QFileInfoList *list = d.<a href="#entryInfoList">entryInfoList</a>();
197 QFileInfoListIterator it( *list );
198 <a href="qfileinfo.html">QFileInfo</a> *fi;
199
200 printf( " Bytes Filename\n" );
201 while ( (fi = it.current()) != 0 ) {
202 printf( "%10li %s\n", fi-&gt;<a href="qfileinfo.html#size">size</a>(), fi-&gt;<a href="qfileinfo.html#fileName">fileName</a>().latin1() );
203 ++it;
204 }
205 return 0;
206 }
207 </pre>
208
209<p> <p>See also <a href="qapplication.html#applicationDirPath">QApplication::applicationDirPath</a>() and <a href="io.html">Input/Output and Networking</a>.
210
211<hr><h2>Member Type Documentation</h2>
212<h3 class=fn><a name="FilterSpec-enum"></a>QDir::FilterSpec</h3>
213
214<p> This enum describes the filtering options available to QDir, e.g.
215for <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>(). The filter value is specified
216by OR-ing together values from the following list:
217<ul>
218<li><tt>QDir::Dirs</tt> - List directories only.
219<li><tt>QDir::Files</tt> - List files only.
220<li><tt>QDir::Drives</tt> - List disk drives (ignored under Unix).
221<li><tt>QDir::NoSymLinks</tt> - Do not list symbolic links (ignored by operating
222systems that don't support symbolic links).
223<li><tt>QDir::All</tt> - List directories, files, drives and symlinks (this does not list
224broken symlinks unless you specify System).
225<li><tt>QDir::TypeMask</tt> - A mask for the the Dirs, Files, Drives and
226NoSymLinks flags.
227<li><tt>QDir::Readable</tt> - List files for which the application has read access.
228<li><tt>QDir::Writable</tt> - List files for which the application has write access.
229<li><tt>QDir::Executable</tt> - List files for which the application has execute
230access. Executables needs to be combined with Dirs or Files.
231<li><tt>QDir::RWEMask</tt> - A mask for the Readable, Writable and Executable flags.
232<li><tt>QDir::Modified</tt> - Only list files that have been modified (ignored
233under Unix).
234<li><tt>QDir::Hidden</tt> - List hidden files (on Unix, files starting with a .).
235<li><tt>QDir::System</tt> - List system files (on Unix, FIFOs, sockets and
236device files)
237<li><tt>QDir::AccessMask</tt> - A mask for the Readable, Writable, Executable
238Modified, Hidden and System flags
239<li><tt>QDir::DefaultFilter</tt> - Internal flag.
240</ul><p> If you do not set any of <a href="#FilterSpec-enum">Readable</a>, <a href="#FilterSpec-enum">Writable</a> or <a href="#FilterSpec-enum">Executable</a>, QDir will set all three of them. This makes the
241default easy to write and at the same time useful.
242<p> Examples: <tt>Readable|Writable</tt> means list all files for which the
243application has read access, write access or both. <tt>Dirs|Drives</tt>
244means list drives, directories, all files that the application can
245read, write or execute, and also symlinks to such
246files/directories.
247
248<h3 class=fn><a name="SortSpec-enum"></a>QDir::SortSpec</h3>
249
250<p> This enum describes the sort options available to QDir, e.g. for
251<a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>(). The sort value is specified by
252OR-ing together values from the following list:
253<ul>
254<li><tt>QDir::Name</tt> - Sort by name.
255<li><tt>QDir::Time</tt> - Sort by time (modification time).
256<li><tt>QDir::Size</tt> - Sort by file size.
257<li><tt>QDir::Unsorted</tt> - Do not sort.
258<li><tt>QDir::SortByMask</tt> - A mask for Name, Time and Size.
259<li><tt>QDir::DirsFirst</tt> - Put the directories first, then the files.
260<li><tt>QDir::Reversed</tt> - Reverse the sort order.
261<li><tt>QDir::IgnoreCase</tt> - Sort case-insensitively.
262<li><tt>QDir::LocaleAware</tt> - Sort names using locale aware compares
263<li><tt>QDir::DefaultSort</tt> - Internal flag.
264</ul><p> You can only specify one of the first four.
265<p> If you specify both <a href="#SortSpec-enum">DirsFirst</a> and <a href="#SortSpec-enum">Reversed</a>, directories are
266still put first, but in reverse order; the files will be listed
267after the directories, again in reverse order.
268
269<hr><h2>Member Function Documentation</h2>
270<h3 class=fn><a name="QDir"></a>QDir::QDir ()
271</h3>
272Constructs a QDir pointing to the current directory (".").
273<p> <p>See also <a href="#currentDirPath">currentDirPath</a>().
274
275<h3 class=fn><a name="QDir-2"></a>QDir::QDir ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nameFilter = QString::null, int&nbsp;sortSpec = Name | IgnoreCase, int&nbsp;filterSpec = All )
276</h3>
277Constructs a QDir with path <em>path</em>, that filters its entries by
278name using <em>nameFilter</em> and by attributes using <em>filterSpec</em>. It
279also sorts the names using <em>sortSpec</em>.
280<p> The default <em>nameFilter</em> is an empty string, which excludes
281nothing; the default <em>filterSpec</em> is <a href="#FilterSpec-enum">All</a>, which also means
282exclude nothing. The default <em>sortSpec</em> is <tt>Name|IgnoreCase</tt>,
283i.e. sort by name case-insensitively.
284<p> Example that lists all the files in "/tmp":
285<pre>
286 QDir d( "/tmp" );
287 for ( int i = 0; i &lt; d.<a href="#count">count</a>(); i++ )
288 printf( "%s\n", d[i] );
289 </pre>
290
291<p> If <em>path</em> is "" or <a href="qstring.html#QString-null">QString::null</a>, QDir uses "." (the current
292directory). If <em>nameFilter</em> is "" or QString::null, QDir uses the
293name filter "*" (all files).
294<p> Note that <em>path</em> need not exist.
295<p> <p>See also <a href="#exists">exists</a>(), <a href="#setPath">setPath</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setFilter">setFilter</a>(), and <a href="#setSorting">setSorting</a>().
296
297<h3 class=fn><a name="QDir-3"></a>QDir::QDir ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;d )
298</h3>
299Constructs a QDir that is a copy of the directory <em>d</em>.
300<p> <p>See also <a href="#operator-eq">operator=</a>().
301
302<h3 class=fn><a name="~QDir"></a>QDir::~QDir ()<tt> [virtual]</tt>
303</h3>
304Destroys the QDir frees up its resources.
305
306<h3 class=fn><a href="qstring.html">QString</a> <a name="absFilePath"></a>QDir::absFilePath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, bool&nbsp;acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
307</h3>
308Returns the absolute path name of a file in the directory. Does <em>not</em> check if the file actually exists in the directory. Redundant
309multiple separators or "." and ".." directories in <em>fileName</em>
310will not be removed (see <a href="#cleanDirPath">cleanDirPath</a>()).
311<p> If <em>acceptAbsPath</em> is TRUE a <em>fileName</em> starting with a
312separator "/" will be returned without change. If <em>acceptAbsPath</em>
313is FALSE an absolute path will be prepended to the fileName and
314the resultant string returned.
315<p> <p>See also <a href="#filePath">filePath</a>().
316
317<h3 class=fn><a href="qstring.html">QString</a> <a name="absPath"></a>QDir::absPath () const<tt> [virtual]</tt>
318</h3>
319Returns the absolute path (a path that starts with "/" or with a
320drive specification), which may contain symbolic links, but never
321contains redundant ".", ".." or multiple separators.
322<p> <p>See also <a href="#setPath">setPath</a>(), <a href="#canonicalPath">canonicalPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), and <a href="#absFilePath">absFilePath</a>().
323
324<p>Example: <a href="fileiconview-example.html#x810">fileiconview/qfileiconview.cpp</a>.
325<h3 class=fn><a href="qstring.html">QString</a> <a name="canonicalPath"></a>QDir::canonicalPath () const<tt> [virtual]</tt>
326</h3>
327Returns the canonical path, i.e. a path without symbolic links or
328redundant "." or ".." elements.
329<p> On systems that do not have symbolic links this function will
330always return the same string that <a href="#absPath">absPath</a>() returns. If the
331canonical path does not exist (normally due to dangling symbolic
332links) <a href="#canonicalPath">canonicalPath</a>() returns <a href="qstring.html#QString-null">QString::null</a>.
333<p> <p>See also <a href="#path">path</a>(), <a href="#absPath">absPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), <a href="#absFilePath">absFilePath</a>(), and <a href="qstring.html#isNull">QString::isNull</a>().
334
335<h3 class=fn>bool <a name="cd"></a>QDir::cd ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dirName, bool&nbsp;acceptAbsPath = TRUE )<tt> [virtual]</tt>
336</h3>
337Changes the QDir's directory to <em>dirName</em>.
338<p> If <em>acceptAbsPath</em> is TRUE a path starting with separator "/"
339will cause the function to change to the absolute directory. If <em>acceptAbsPath</em> is FALSE any number of separators at the beginning
340of <em>dirName</em> will be removed and the function will descend into
341<em>dirName</em>.
342<p> Returns TRUE if the new directory exists and is readable;
343otherwise returns FALSE. Note that the logical <a href="#cd">cd</a>() operation is
344not performed if the new directory does not exist.
345<p> Calling cd( ".." ) is equivalent to calling <a href="#cdUp">cdUp</a>().
346<p> <p>See also <a href="#cdUp">cdUp</a>(), <a href="#isReadable">isReadable</a>(), <a href="#exists">exists</a>(), and <a href="#path">path</a>().
347
348<p>Example: <a href="fileiconview-example.html#x883">fileiconview/mainwindow.cpp</a>.
349<h3 class=fn>bool <a name="cdUp"></a>QDir::cdUp ()<tt> [virtual]</tt>
350</h3>
351Changes directory by moving one directory up from the QDir's
352current directory.
353<p> Returns TRUE if the new directory exists and is readable;
354otherwise returns FALSE. Note that the logical <a href="#cdUp">cdUp</a>() operation is
355not performed if the new directory does not exist.
356<p> <p>See also <a href="#cd">cd</a>(), <a href="#isReadable">isReadable</a>(), <a href="#exists">exists</a>(), and <a href="#path">path</a>().
357
358<h3 class=fn><a href="qstring.html">QString</a> <a name="cleanDirPath"></a>QDir::cleanDirPath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filePath )<tt> [static]</tt>
359</h3>
360Removes all multiple directory separators "/" and resolves any
361"."s or ".."s found in the path, <em>filePath</em>.
362<p> Symbolic links are kept. This function does not return the
363canonical path, but rather the simplest version of the input.
364For example, "./local" becomes "local", "local/../bin" becomes
365"bin" and "/local/usr/../bin" becomes "/local/bin".
366<p> <p>See also <a href="#absPath">absPath</a>() and <a href="#canonicalPath">canonicalPath</a>().
367
368<h3 class=fn><a href="qstring.html">QString</a> <a name="convertSeparators"></a>QDir::convertSeparators ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;pathName )<tt> [static]</tt>
369</h3>
370Returns <em>pathName</em> with the '/' separators converted to
371separators that are appropriate for the underlying operating
372system.
373<p> On Windows, <a href="#convertSeparators">convertSeparators</a>("c:/winnt/system32") returns
374"c:\winnt\system32".
375<p> The returned string may be the same as the argument on some
376operating systems, for example on Unix.
377
378<p>Examples: <a href="dirview-example.html#x1664">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x811">fileiconview/qfileiconview.cpp</a>.
379<h3 class=fn>void <a name="convertToAbs"></a>QDir::convertToAbs ()<tt> [virtual]</tt>
380</h3>
381Converts the directory path to an absolute path. If it is already
382absolute nothing is done.
383<p> <p>See also <a href="#isRelative">isRelative</a>().
384
385<h3 class=fn>uint <a name="count"></a>QDir::count () const
386</h3>
387Returns the total number of directories and files that were found.
388<p> Equivalent to <a href="#entryList">entryList</a>().<a href="#count">count</a>().
389<p> <p>See also <a href="#operator[]">operator[]</a>() and <a href="#entryList">entryList</a>().
390
391<h3 class=fn><a href="qdir.html">QDir</a> <a name="current"></a>QDir::current ()<tt> [static]</tt>
392</h3>
393Returns the application's current directory.
394<p> Use <a href="#path">path</a>() to access a QDir object's path.
395<p> <p>See also <a href="#currentDirPath">currentDirPath</a>() and <a href="#QDir">QDir::QDir</a>().
396
397<h3 class=fn><a href="qstring.html">QString</a> <a name="currentDirPath"></a>QDir::currentDirPath ()<tt> [static]</tt>
398</h3>
399Returns the absolute path of the application's current directory.
400<p> <p>See also <a href="#current">current</a>().
401
402<p>Examples: <a href="dirview-example.html#x1665">dirview/dirview.cpp</a>, <a href="helpviewer-example.html#x986">helpviewer/helpwindow.cpp</a>, and <a href="qdir-example.html#x1813">qdir/qdir.cpp</a>.
403<h3 class=fn><a href="qstring.html">QString</a> <a name="dirName"></a>QDir::dirName () const<tt> [virtual]</tt>
404</h3>
405Returns the name of the directory; this is <em>not</em> the same as the
406path, e.g. a directory with the name "mail", might have the path
407"/var/spool/mail". If the directory has no name (e.g. it is the
408root directory) <a href="qstring.html#QString-null">QString::null</a> is returned.
409<p> No check is made to ensure that a directory with this name
410actually exists.
411<p> <p>See also <a href="#path">path</a>(), <a href="#absPath">absPath</a>(), <a href="#absFilePath">absFilePath</a>(), <a href="#exists">exists</a>(), and <a href="qstring.html#isNull">QString::isNull</a>().
412
413<h3 class=fn>const QFileInfoList * <a name="drives"></a>QDir::drives ()<tt> [static]</tt>
414</h3>
415Returns a list of the root directories on this system. On Windows
416this returns a number of <a href="qfileinfo.html">QFileInfo</a> objects containing "C:/", "D:/"
417etc. On other operating systems, it returns a list containing just
418one root directory (e.g. "/").
419<p> The returned pointer is owned by Qt. Callers should <em>not</em> delete
420or modify it.
421
422<p>Example: <a href="dirview-example.html#x1712">dirview/main.cpp</a>.
423<h3 class=fn><a href="qstrlist.html">QStrList</a> <a name="encodedEntryList"></a>QDir::encodedEntryList ( int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const<tt> [virtual]</tt>
424</h3>
425<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
426<p> This function is included to easy porting from Qt 1.x to Qt 2.0,
427it is the same as <a href="#entryList">entryList</a>(), but encodes the filenames as 8-bit
428strings using QFile::encodedName().
429<p> It is more efficient to use entryList().
430
431<h3 class=fn><a href="qstrlist.html">QStrList</a> <a name="encodedEntryList-2"></a>QDir::encodedEntryList ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nameFilter, int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const<tt> [virtual]</tt>
432</h3>
433<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
434<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
435<p> This function is included to easy porting from Qt 1.x to Qt 2.0,
436it is the same as <a href="#entryList">entryList</a>(), but encodes the filenames as 8-bit
437strings using QFile::encodedName().
438<p> It is more efficient to use entryList().
439
440<h3 class=fn>const QFileInfoList * <a name="entryInfoList"></a>QDir::entryInfoList ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nameFilter, int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const<tt> [virtual]</tt>
441</h3>
442Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and
443directories in the directory, ordered in accordance with
444<a href="#setSorting">setSorting</a>() and filtered in accordance with <a href="#setFilter">setFilter</a>() and
445<a href="#setNameFilter">setNameFilter</a>().
446<p> The filter and sorting specifications can be overridden using the
447<em>nameFilter</em>, <em>filterSpec</em> and <em>sortSpec</em> arguments.
448<p> Returns 0 if the directory is unreadable or does not exist.
449<p> The returned pointer is a const pointer to a QFileInfoList. The
450list is owned by the QDir object and will be reused on the next
451call to <a href="#entryInfoList">entryInfoList</a>() for the same QDir instance. If you want to
452keep the entries of the list after a subsequent call to this
453function you must copy them.
454<p> Note: QFileInfoList is really a <a href="qptrlist.html">QPtrList</a><QFileInfo>.
455<p> <p>See also <a href="#entryList">entryList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
456
457<p>Examples: <a href="dirview-example.html#x1666">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x812">fileiconview/qfileiconview.cpp</a>.
458<h3 class=fn>const QFileInfoList * <a name="entryInfoList-2"></a>QDir::entryInfoList ( int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const<tt> [virtual]</tt>
459</h3>
460This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
461<p> Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and
462directories in the directory, ordered in accordance with
463<a href="#setSorting">setSorting</a>() and filtered in accordance with <a href="#setFilter">setFilter</a>() and
464<a href="#setNameFilter">setNameFilter</a>().
465<p> The filter and sorting specifications can be overridden using the
466<em>filterSpec</em> and <em>sortSpec</em> arguments.
467<p> Returns 0 if the directory is unreadable or does not exist.
468<p> The returned pointer is a const pointer to a QFileInfoList. The
469list is owned by the QDir object and will be reused on the next
470call to <a href="#entryInfoList">entryInfoList</a>() for the same QDir instance. If you want to
471keep the entries of the list after a subsequent call to this
472function you must copy them.
473<p> Note: QFileInfoList is really a <a href="qptrlist.html">QPtrList</a><QFileInfo>.
474<p> <p>See also <a href="#entryList">entryList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
475
476<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="entryList"></a>QDir::entryList ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nameFilter, int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const<tt> [virtual]</tt>
477</h3>
478Returns a list of the names of all the files and directories in
479the directory, ordered in accordance with <a href="#setSorting">setSorting</a>() and
480filtered in accordance with <a href="#setFilter">setFilter</a>() and <a href="#setNameFilter">setNameFilter</a>().
481<p> The filter and sorting specifications can be overridden using the
482<em>nameFilter</em>, <em>filterSpec</em> and <em>sortSpec</em> arguments.
483<p> Returns an empty list if the directory is unreadable or does not
484exist.
485<p> <p>See also <a href="#entryInfoList">entryInfoList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
486
487<p>Example: <a href="statistics-example.html#x2780">table/statistics/statistics.cpp</a>.
488<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="entryList-2"></a>QDir::entryList ( int&nbsp;filterSpec = DefaultFilter, int&nbsp;sortSpec = DefaultSort ) const<tt> [virtual]</tt>
489</h3>
490This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
491<p> Returns a list of the names of all the files and directories in
492the directory, ordered in accordance with <a href="#setSorting">setSorting</a>() and
493filtered in accordance with <a href="#setFilter">setFilter</a>() and <a href="#setNameFilter">setNameFilter</a>().
494<p> The filter and sorting specifications can be overridden using the
495<em>filterSpec</em> and <em>sortSpec</em> arguments.
496<p> Returns an empty list if the directory is unreadable or does not
497exist.
498<p> <p>See also <a href="#entryInfoList">entryInfoList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
499
500<h3 class=fn>bool <a name="exists"></a>QDir::exists ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, bool&nbsp;acceptAbsPath = TRUE )<tt> [virtual]</tt>
501</h3>
502Checks for the existence of the file <em>name</em>.
503<p> If <em>acceptAbsPath</em> is TRUE a path starting with separator "/"
504will check the file with the absolute path. If <em>acceptAbsPath</em> is
505FALSE any number of separators at the beginning of <em>name</em> will be
506removed and the resultant file name will be checked.
507<p> Returns TRUE if the file exists; otherwise returns FALSE.
508<p> <p>See also <a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists">QFile::exists</a>().
509
510<h3 class=fn>bool <a name="exists-2"></a>QDir::exists () const<tt> [virtual]</tt>
511</h3>
512This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
513<p> Returns TRUE if the <em>directory</em> exists; otherwise returns FALSE.
514(If a file with the same name is found this function will return
515FALSE).
516<p> <p>See also <a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists">QFile::exists</a>().
517
518<h3 class=fn><a href="qstring.html">QString</a> <a name="filePath"></a>QDir::filePath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, bool&nbsp;acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
519</h3>
520Returns the path name of a file in the directory. Does <em>not</em>
521check if the file actually exists in the directory. If the QDir is
522relative the returned path name will also be relative. Redundant
523multiple separators or "." and ".." directories in <em>fileName</em>
524will not be removed (see <a href="#cleanDirPath">cleanDirPath</a>()).
525<p> If <em>acceptAbsPath</em> is TRUE a <em>fileName</em> starting with a
526separator "/" will be returned without change. If <em>acceptAbsPath</em>
527is FALSE an absolute path will be prepended to the fileName and
528the resultant string returned.
529<p> <p>See also <a href="#absFilePath">absFilePath</a>(), <a href="#isRelative">isRelative</a>(), and <a href="#canonicalPath">canonicalPath</a>().
530
531<h3 class=fn><a href="qdir.html#FilterSpec-enum">FilterSpec</a> <a name="filter"></a>QDir::filter () const
532</h3>
533
534<p> Returns the value set by <a href="#setFilter">setFilter</a>()
535
536<h3 class=fn><a href="qdir.html">QDir</a> <a name="home"></a>QDir::home ()<tt> [static]</tt>
537</h3>
538Returns the home directory.
539<p> Under Windows the <tt>HOME</tt> environment variable is used. If this
540does not exist the <tt>USERPROFILE</tt> environment variable is used. If
541that does not exist the path is formed by concatenating the <tt>HOMEDRIVE</tt> and <tt>HOMEPATH</tt> environment variables. If they don't
542exist the <a href="#rootDirPath">rootDirPath</a>() is used (this uses the <tt>SystemDrive</tt>
543environment variable). If none of these exist "C:&#92;" is used.
544<p> Under non-Windows operating systems the <tt>HOME</tt> environment
545variable is used if it exists, otherwise rootDirPath() is used.
546<p> <p>See also <a href="#homeDirPath">homeDirPath</a>().
547
548<h3 class=fn><a href="qstring.html">QString</a> <a name="homeDirPath"></a>QDir::homeDirPath ()<tt> [static]</tt>
549</h3>
550
551<p> Returns the absolute path of the user's home directory.
552<p> <p>See also <a href="#home">home</a>().
553
554<h3 class=fn>bool <a name="isReadable"></a>QDir::isReadable () const<tt> [virtual]</tt>
555</h3>
556Returns TRUE if the directory is readable <em>and</em> we can open files
557by name; otherwise returns FALSE.
558<p> <b>Warning:</b> A FALSE value from this function is not a guarantee that
559files in the directory are not accessible.
560<p> <p>See also <a href="qfileinfo.html#isReadable">QFileInfo::isReadable</a>().
561
562<p>Examples: <a href="dirview-example.html#x1667">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x813">fileiconview/qfileiconview.cpp</a>.
563<h3 class=fn>bool <a name="isRelative"></a>QDir::isRelative () const<tt> [virtual]</tt>
564</h3>
565Returns TRUE if the directory path is relative to the current
566directory and returns FALSE if the path is absolute (e.g. under
567UNIX a path is relative if it does not start with a "/").
568<p> <p>See also <a href="#convertToAbs">convertToAbs</a>().
569
570<h3 class=fn>bool <a name="isRelativePath"></a>QDir::isRelativePath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path )<tt> [static]</tt>
571</h3>
572Returns TRUE if <em>path</em> is relative; returns FALSE if it is
573absolute.
574<p> <p>See also <a href="#isRelative">isRelative</a>().
575
576<h3 class=fn>bool <a name="isRoot"></a>QDir::isRoot () const<tt> [virtual]</tt>
577</h3>
578Returns TRUE if the directory is the root directory; otherwise
579returns FALSE.
580<p> Note: If the directory is a symbolic link to the root directory
581this function returns FALSE. If you want to test for this use
582<a href="#canonicalPath">canonicalPath</a>(), e.g.
583<pre>
584 QDir d( "/tmp/root_link" );
585 d = d.<a href="#canonicalPath">canonicalPath</a>();
586 if ( d.<a href="#isRoot">isRoot</a>() )
587 <a href="qapplication.html#qWarning">qWarning</a>( "It is a root link" );
588 </pre>
589
590<p> <p>See also <a href="#root">root</a>() and <a href="#rootDirPath">rootDirPath</a>().
591
592<h3 class=fn>bool <a name="match"></a>QDir::match ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )<tt> [static]</tt>
593</h3>
594Returns TRUE if the <em>fileName</em> matches the wildcard (glob)
595pattern <em>filter</em>; otherwise returns FALSE. The <em>filter</em> may
596contain multiple patterns separated by spaces or semicolons.
597<p> (See <a href="qregexp.html#wildcard-matching">QRegExp wildcard
598 matching.</a>)
599<p>See also <a href="qregexp.html#match">QRegExp::match</a>().
600
601<h3 class=fn>bool <a name="match-2"></a>QDir::match ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;filters, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )<tt> [static]</tt>
602</h3>
603This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
604<p> Returns TRUE if the <em>fileName</em> matches any of the wildcard (glob)
605patterns in the list of <em>filters</em>; otherwise returns FALSE.
606<p> (See <a href="qregexp.html#wildcard-matching">QRegExp wildcard
607 matching.</a>)
608<p>See also <a href="qregexp.html#match">QRegExp::match</a>().
609
610<h3 class=fn>bool <a name="matchAllDirs"></a>QDir::matchAllDirs () const
611</h3>
612
613<p> Returns the value set by <a href="#setMatchAllDirs">setMatchAllDirs</a>()
614<p> <p>See also <a href="#setMatchAllDirs">setMatchAllDirs</a>().
615
616<h3 class=fn>bool <a name="mkdir"></a>QDir::mkdir ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dirName, bool&nbsp;acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
617</h3>
618Creates a directory.
619<p> If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
620will create the absolute directory; if <em>acceptAbsPath</em> is FALSE
621any number of separators at the beginning of <em>dirName</em> will be
622removed.
623<p> Returns TRUE if successful; otherwise returns FALSE.
624<p> <p>See also <a href="#rmdir">rmdir</a>().
625
626<h3 class=fn><a href="qstring.html">QString</a> <a name="nameFilter"></a>QDir::nameFilter () const
627</h3>
628
629<p> Returns the string set by <a href="#setNameFilter">setNameFilter</a>()
630
631<h3 class=fn>bool <a name="operator!-eq"></a>QDir::operator!= ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;d ) const<tt> [virtual]</tt>
632</h3>
633
634<p> Returns TRUE if directory <em>d</em> and this directory have different
635paths or different sort or filter settings; otherwise returns
636FALSE.
637<p> Example:
638<pre>
639 // The current directory is "/usr/local"
640 QDir d1( "/usr/local/bin" );
641 QDir d2( "bin" );
642 if ( d1 != d2 )
643 <a href="qapplication.html#qDebug">qDebug</a>( "They differ" );
644 </pre>
645
646
647<h3 class=fn><a href="qdir.html">QDir</a>&nbsp;&amp; <a name="operator-eq"></a>QDir::operator= ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;d )
648</h3>
649Makes a copy of QDir <em>d</em> and assigns it to this QDir.
650
651<h3 class=fn><a href="qdir.html">QDir</a>&nbsp;&amp; <a name="operator-eq-2"></a>QDir::operator= ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path )
652</h3>
653This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
654<p> Sets the directory path to be the given <em>path</em>.
655
656<h3 class=fn>bool <a name="operator-eq-eq"></a>QDir::operator== ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;d ) const<tt> [virtual]</tt>
657</h3>
658Returns TRUE if directory <em>d</em> and this directory have the same
659path and their sort and filter settings are the same; otherwise
660returns FALSE.
661<p> Example:
662<pre>
663 // The current directory is "/usr/local"
664 QDir d1( "/usr/local/bin" );
665 QDir d2( "bin" );
666 d2.<a href="#convertToAbs">convertToAbs</a>();
667 if ( d1 == d2 )
668 <a href="qapplication.html#qDebug">qDebug</a>( "They're the same" );
669 </pre>
670
671
672<h3 class=fn><a href="qstring.html">QString</a> <a name="operator[]"></a>QDir::operator[] ( int&nbsp;index ) const
673</h3>
674Returns the file name at position <em>index</em> in the list of file
675names. Equivalent to <a href="#entryList">entryList</a>().at(index).
676<p> Returns a <a href="qstring.html#QString-null">QString::null</a> if the <em>index</em> is out of range or if the
677entryList() function failed.
678<p> <p>See also <a href="#count">count</a>() and <a href="#entryList">entryList</a>().
679
680<h3 class=fn><a href="qstring.html">QString</a> <a name="path"></a>QDir::path () const<tt> [virtual]</tt>
681</h3>
682
683<p> Returns the path, this may contain symbolic links, but never
684contains redundant ".", ".." or multiple separators.
685<p> The returned path can be either absolute or relative (see
686<a href="#setPath">setPath</a>()).
687<p> <p>See also <a href="#setPath">setPath</a>(), <a href="#absPath">absPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), <a href="#absFilePath">absFilePath</a>(), and <a href="#convertSeparators">convertSeparators</a>().
688
689<h3 class=fn>void <a name="refresh"></a>QDir::refresh () const
690</h3>
691Refreshes the directory information.
692
693<h3 class=fn>bool <a name="remove"></a>QDir::remove ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, bool&nbsp;acceptAbsPath = TRUE )<tt> [virtual]</tt>
694</h3>
695Removes the file, <em>fileName</em>.
696<p> If <em>acceptAbsPath</em> is TRUE a path starting with separator "/"
697will remove the file with the absolute path. If <em>acceptAbsPath</em>
698is FALSE any number of separators at the beginning of <em>fileName</em>
699will be removed and the resultant file name will be removed.
700<p> Returns TRUE if the file is removed successfully; otherwise
701returns FALSE.
702
703<h3 class=fn>bool <a name="rename"></a>QDir::rename ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;oldName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;newName, bool&nbsp;acceptAbsPaths = TRUE )<tt> [virtual]</tt>
704</h3>
705Renames a file or directory.
706<p> If <em>acceptAbsPaths</em> is TRUE a path starting with a separator
707('/') will rename the file with the absolute path; if <em>acceptAbsPaths</em> is FALSE any number of separators at the beginning
708of the names will be removed.
709<p> Returns TRUE if successful; otherwise returns FALSE.
710<p> On most file systems, <a href="#rename">rename</a>() fails only if <em>oldName</em> does not
711exist or if <em>newName</em> and <em>oldName</em> are not on the same
712partition. On Windows, rename() will fail if <em>newName</em> already
713exists. However, there are also other reasons why rename() can
714fail. For example, on at least one file system rename() fails if
715<em>newName</em> points to an open file.
716
717<p>Example: <a href="fileiconview-example.html#x814">fileiconview/qfileiconview.cpp</a>.
718<h3 class=fn>bool <a name="rmdir"></a>QDir::rmdir ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dirName, bool&nbsp;acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
719</h3>
720Removes a directory.
721<p> If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
722will remove the absolute directory; if <em>acceptAbsPath</em> is FALSE
723any number of separators at the beginning of <em>dirName</em> will be
724removed.
725<p> The directory must be empty for <a href="#rmdir">rmdir</a>() to succeed.
726<p> Returns TRUE if successful; otherwise returns FALSE.
727<p> <p>See also <a href="#mkdir">mkdir</a>().
728
729<h3 class=fn><a href="qdir.html">QDir</a> <a name="root"></a>QDir::root ()<tt> [static]</tt>
730</h3>
731Returns the root directory.
732<p> <p>See also <a href="#rootDirPath">rootDirPath</a>() and <a href="#drives">drives</a>().
733
734<h3 class=fn><a href="qstring.html">QString</a> <a name="rootDirPath"></a>QDir::rootDirPath ()<tt> [static]</tt>
735</h3>
736Returns the absolute path for the root directory.
737<p> For UNIX operating systems this returns "/". For Windows file
738systems this normally returns "c:/".
739<p> <p>See also <a href="#root">root</a>() and <a href="#drives">drives</a>().
740
741<h3 class=fn>char <a name="separator"></a>QDir::separator ()<tt> [static]</tt>
742</h3>
743Returns the native directory separator; "/" under UNIX (including
744Mac OS X) and "&#92;" under Windows.
745<p> You do not need to use this function to build file paths. If you
746always use "/", Qt will translate your paths to conform to the
747underlying operating system.
748
749<h3 class=fn>bool <a name="setCurrent"></a>QDir::setCurrent ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path )<tt> [static]</tt>
750</h3>
751Sets the application's current working directory to <em>path</em>.
752Returns TRUE if the directory was successfully changed; otherwise
753returns FALSE.
754
755<h3 class=fn>void <a name="setFilter"></a>QDir::setFilter ( int&nbsp;filterSpec )<tt> [virtual]</tt>
756</h3>
757Sets the filter used by <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>() to <em>filterSpec</em>. The filter is used to specify the kind of files that
758should be returned by entryList() and entryInfoList(). See
759<a href="#FilterSpec-enum">QDir::FilterSpec</a>.
760<p> <p>See also <a href="#filter">filter</a>() and <a href="#setNameFilter">setNameFilter</a>().
761
762<h3 class=fn>void <a name="setMatchAllDirs"></a>QDir::setMatchAllDirs ( bool&nbsp;enable )<tt> [virtual]</tt>
763</h3>
764If <em>enable</em> is TRUE then all directories are included (e.g. in
765<a href="#entryList">entryList</a>()), and the <a href="#nameFilter">nameFilter</a>() is only applied to the files.
766If <em>enable</em> is FALSE then the nameFilter() is applied to both
767directories and files.
768<p> <p>See also <a href="#matchAllDirs">matchAllDirs</a>().
769
770<h3 class=fn>void <a name="setNameFilter"></a>QDir::setNameFilter ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nameFilter )<tt> [virtual]</tt>
771</h3>
772Sets the name filter used by <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>() to <em>nameFilter</em>.
773<p> The <em>nameFilter</em> is a wildcard (globbing) filter that understands
774"*" and "?" wildcards. (See <a href="qregexp.html#wildcard-matching">QRegExp wildcard matching</a>.) You may specify several filter
775entries all separated by a single space " " or by a semi-colon
776";".
777<p> For example, if you want entryList() and entryInfoList() to list
778all files ending with either ".cpp" or ".h", you would use either
779dir.<a href="#setNameFilter">setNameFilter</a>("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h").
780<p> <p>See also <a href="#nameFilter">nameFilter</a>() and <a href="#setFilter">setFilter</a>().
781
782<h3 class=fn>void <a name="setPath"></a>QDir::setPath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path )<tt> [virtual]</tt>
783</h3>
784Sets the path of the directory to <em>path</em>. The path is cleaned of
785redundant ".", ".." and of multiple separators. No check is made
786to ensure that a directory with this path exists.
787<p> The path can be either absolute or relative. Absolute paths begin
788with the directory separator "/" (optionally preceded by a drive
789specification under Windows). Relative file names begin with a
790directory name or a file name and specify a path relative to the
791current directory. An example of an absolute path is the string
792"/tmp/quartz", a relative path might look like "src/fatlib".
793<p> <p>See also <a href="#path">path</a>(), <a href="#absPath">absPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), <a href="#absFilePath">absFilePath</a>(), <a href="#isRelative">isRelative</a>(), and <a href="#convertToAbs">convertToAbs</a>().
794
795<h3 class=fn>void <a name="setSorting"></a>QDir::setSorting ( int&nbsp;sortSpec )<tt> [virtual]</tt>
796</h3>
797Sets the sort order used by <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>().
798<p> The <em>sortSpec</em> is specified by OR-ing values from the enum
799<a href="#SortSpec-enum">QDir::SortSpec</a>.
800<p> <p>See also <a href="#sorting">sorting</a>() and <a href="#SortSpec-enum">SortSpec</a>.
801
802<h3 class=fn><a href="qdir.html#SortSpec-enum">SortSpec</a> <a name="sorting"></a>QDir::sorting () const
803</h3>
804
805<p> Returns the value set by <a href="#setSorting">setSorting</a>()
806<p> <p>See also <a href="#setSorting">setSorting</a>() and <a href="#SortSpec-enum">SortSpec</a>.
807
808<!-- eof -->
809<hr><p>
810This file is part of the <a href="index.html">Qt toolkit</a>.
811Copyright &copy; 1995-2007
812<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
813<table width=100% cellspacing=0 border=0><tr>
814<td>Copyright &copy; 2007
815<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
816<td align=right><div align=right>Qt 3.3.8</div>
817</table></div></address></body>
818</html>
Note: See TracBrowser for help on using the repository browser.