1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QDir Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QDir Class Reference</h1><br clear="all">
<p>
Traverses directory structures and contents in a platform-independent way.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qdir-h.html">qdir.h</a>></code>
<p><a href="qdir-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn">enum<a href="#FilterSpec"><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}</div>
<li><div class="fn">enum<a href="#SortSpec"><b>SortSpec</b></a>{Name=0x00, Time=0x01, Size=0x02, Unsorted=0x03, SortByMask=0x03, DirsFirst=0x04, Reversed=0x08, IgnoreCase=0x10, DefaultSort=-1}</div>
<li><div class="fn"><a href="#b10816"><b>QDir</b></a>()</div>
<li><div class="fn"><a href="#2b09fb"><b>QDir</b></a>(constQString&path, constQString&nameFilter=QString::null, intsortSpec=Name|IgnoreCase, intfilterSpec=All)</div>
<li><div class="fn"><a href="#5aea25"><b>QDir</b></a>(constQDir&)</div>
<li><div class="fn">virtual<a href="#1fc49a"><b>~QDir</b></a>()</div>
<li><div class="fn">QDir&<a href="#c8eb7a"><b>operator=</b></a>(constQDir&)</div>
<li><div class="fn">QDir&<a href="#305f8d"><b>operator=</b></a>(constQString&path)</div>
<li><div class="fn">virtualvoid<a href="#ca643e"><b>setPath</b></a>(constQString&path)</div>
<li><div class="fn">virtualQString<a href="#f7ebde"><b>path</b></a>()const</div>
<li><div class="fn">virtualQString<a href="#bf5f8c"><b>absPath</b></a>()const</div>
<li><div class="fn">virtualQString<a href="#631a70"><b>canonicalPath</b></a>()const</div>
<li><div class="fn">virtualQString<a href="#96243a"><b>dirName</b></a>()const</div>
<li><div class="fn">virtualQString<a href="#89e03a"><b>filePath</b></a>(constQString&fileName, boolacceptAbsPath=TRUE)const</div>
<li><div class="fn">virtualQString<a href="#1719a2"><b>absFilePath</b></a>(constQString&fileName, boolacceptAbsPath=TRUE)const</div>
<li><div class="fn">virtualbool<a href="#f0fc10"><b>cd</b></a>(constQString&dirName, boolacceptAbsPath=TRUE)</div>
<li><div class="fn">virtualbool<a href="#f3b312"><b>cdUp</b></a>()</div>
<li><div class="fn">QString<a href="#cee483"><b>nameFilter</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#7e369a"><b>setNameFilter</b></a>(constQString&nameFilter)</div>
<li><div class="fn">FilterSpec<a href="#fd8686"><b>filter</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#a96204"><b>setFilter</b></a>(intfilterSpec)</div>
<li><div class="fn">SortSpec<a href="#a6d587"><b>sorting</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#9155b3"><b>setSorting</b></a>(intsortSpec)</div>
<li><div class="fn">bool<a href="#43f4f9"><b>matchAllDirs</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#d205dd"><b>setMatchAllDirs</b></a>(bool)</div>
<li><div class="fn">uint<a href="#c4eb7d"><b>count</b></a>()const</div>
<li><div class="fn">QString<a href="#54898d"><b>operator[]</b></a>(int)const</div>
<li><div class="fn">virtualQStrList<a href="#94521a"><b>encodedEntryList</b></a>(intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const</div>
<li><div class="fn">virtualQStrList<a href="#317a83"><b>encodedEntryList</b></a>(constQString&nameFilter, intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const</div>
<li><div class="fn">virtualQStringList<a href="#94f61d"><b>entryList</b></a>(intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const</div>
<li><div class="fn">virtualQStringList<a href="#2f79b2"><b>entryList</b></a>(constQString&nameFilter, intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const</div>
<li><div class="fn">virtualconstQFileInfoList*<a href="#789222"><b>entryInfoList</b></a>(intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const</div>
<li><div class="fn">virtualconstQFileInfoList*<a href="#fd6c87"><b>entryInfoList</b></a>(constQString&nameFilter, intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const</div>
<li><div class="fn">virtualbool<a href="#7397c3"><b>mkdir</b></a>(constQString&dirName, boolacceptAbsPath=TRUE)const</div>
<li><div class="fn">virtualbool<a href="#753b37"><b>rmdir</b></a>(constQString&dirName, boolacceptAbsPath=TRUE)const</div>
<li><div class="fn">virtualbool<a href="#6dc6f9"><b>isReadable</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#ffe704"><b>exists</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#e40b71"><b>isRoot</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#4f10b1"><b>isRelative</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#48abfa"><b>convertToAbs</b></a>()</div>
<li><div class="fn">virtualbool<a href="#a0e236"><b>operator==</b></a>(constQDir&)const</div>
<li><div class="fn">virtualbool<a href="#707dfc"><b>operator!=</b></a>(constQDir&)const</div>
<li><div class="fn">virtualbool<a href="#14c4f4"><b>remove</b></a>(constQString&fileName, boolacceptAbsPath=TRUE)</div>
<li><div class="fn">virtualbool<a href="#a7d8c0"><b>rename</b></a>(constQString&name, constQString&newName, boolacceptAbsPaths=TRUE)</div>
<li><div class="fn">virtualbool<a href="#26eec3"><b>exists</b></a>(constQString&name, boolacceptAbsPath=TRUE)</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">QString<a href="#91f780"><b>convertSeparators</b></a>(constQString&pathName)</div>
<li><div class="fn">constQFileInfoList*<a href="#308bab"><b>drives</b></a>()</div>
<li><div class="fn">char<a href="#682599"><b>separator</b></a>()</div>
<li><div class="fn">bool<a href="#5faf24"><b>setCurrent</b></a>(constQString&path)</div>
<li><div class="fn">QDir<a href="#9ddfe3"><b>current</b></a>()</div>
<li><div class="fn">QDir<a href="#15d497"><b>home</b></a>()</div>
<li><div class="fn">QDir<a href="#a62796"><b>root</b></a>()</div>
<li><div class="fn">QString<a href="#2ec6fd"><b>currentDirPath</b></a>()</div>
<li><div class="fn">QString<a href="#b3b787"><b>homeDirPath</b></a>()</div>
<li><div class="fn">QString<a href="#d0fb47"><b>rootDirPath</b></a>()</div>
<li><div class="fn">bool<a href="#16e80b"><b>match</b></a>(constQStringList&filters, constQString&fileName)</div>
<li><div class="fn">bool<a href="#4a6938"><b>match</b></a>(constQString&filter, constQString&fileName)</div>
<li><div class="fn">QString<a href="#d17301"><b>cleanDirPath</b></a>(constQString&dirPath)</div>
<li><div class="fn">bool<a href="#221836"><b>isRelativePath</b></a>(constQString&path)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
Traverses directory structures and contents in a platform-independent way.
<p>
A QDir can point to a file using either a relative or an absolute file
path. Absolute file paths begin with the directory separator ('/') or a
drive specification (not applicable to UNIX). Relative file names begin
with a directory name or a file name and specify a path relative to the
current directory.
<p>An example of an absolute path is the string "/tmp/quartz", a relative
path might look like "src/fatlib". You can use the function <a href="#4f10b1">isRelative</a>()
to check if a QDir is using a relative or an absolute file path. You can
call the function <a href="#48abfa">convertToAbs</a>() to convert a relative QDir to an
absolute one.
<p>The directory "example" under the current directory is checked for existence
in the example below:
<p><pre> <a href="qdir.html">QDir</a> d( "example" ); // "./example"
if ( !d.<a href="#26eec3">exists</a>() )
<a href="qapplication.html#290ef4">qWarning</a>( "Cannot find the example directory" );
</pre>
<p>If you always use '/' as a directory separator, Qt will translate your
paths to conform to the underlying operating system.
<p><a href="#f0fc10">cd</a>() and <a href="#f3b312">cdUp</a>() can be used to navigate the directory tree. Note that the
logical cd and cdUp operations are not performed if the new directory does
not exist.
<p>Example:
<pre> <a href="qdir.html">QDir</a> d = QDir::root(); // "/"
if ( !d.<a href="#f0fc10">cd</a>("tmp") ) { // "/tmp"
<a href="qapplication.html#290ef4">qWarning</a>( "Cannot find the \"/tmp\" directory" );
} else {
<a href="qfile.html">QFile</a> f( d.<a href="#89e03a">filePath</a>("ex1.txt") ); // "/tmp/ex1.txt"
if ( !f.<a href="qfile.html#255995">open</a>(IO_ReadWrite) )
<a href="qapplication.html#290ef4">qWarning</a>( "Cannot create the file %s", f.<a href="qfile.html#f6ec78">name</a>() );
}
</pre>
<p>To read the contents of a directory you can use the <a href="#2f79b2">entryList</a>() and
<a href="#789222">entryInfoList</a>() functions.
<p>Example:
<pre> #include <stdio.h>
#include <qdir.h>
//
// This program scans the current directory and lists all files
// that are not symbolic links, sorted by size with the smallest files
// first.
//
int main( int argc, char **argv )
{
<a href="qdir.html">QDir</a> d;
d.<a href="#a96204">setFilter</a>( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
d.<a href="#9155b3">setSorting</a>( QDir::Size | QDir::Reversed );
const QFileInfoList *list = d.<a href="#789222">entryInfoList</a>();
QFileInfoListIterator it( *list ); // create list iterator
<a href="qfileinfo.html">QFileInfo</a> *fi; // pointer for traversing
printf( " BYTES FILENAME\n" ); // print header
while ( (fi=it.current()) ) { // for each file...
printf( "%10li %s\n", fi-><a href="qfileinfo.html#75b7f4">size</a>(), fi-><a href="qfileinfo.html#a9e3d2">fileName</a>().data() );
++it; // goto next list element
}
}
</pre>
<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="FilterSpec">QDir::FilterSpec</a></h3>
This enum describes how QDir is to select what entries in a
directory to return. The filter value is specified by or-ing
together values from the following list: <ul>
<li> <code>Dirs</code> - List directories only
<li> <code>Files</code> - List files only
<li> <code>Drives</code> - List disk drives (does nothing under unix)
<li> <code>NoSymLinks</code> - Do not list symbolic links (where they exist)
<li> <code>Readable</code> - List files for which the application has read access.
<li> <code>Writable</code> - List files for which the application has write access.
<li> <code>Executable</code> - List files for which the application has execute access
<li> <code>Modified</code> - Only list files that have been modified (does nothing
under unix)
<li> <code>Hidden</code> - List hidden files (on unix, files starting with a .)
<li> <code>System</code> - List system files (on unix, FIFOs, sockets and device files)
</ul>
<p>If you do not set any of <code>Readable, Writable</code> or <code>Executable,</code>
QDir will set all three of them. This makes the default easy to
write and at the same time useful.
<p>Examples: <code>Readable|Writable</code> means list all files for which the
application has read access, write access or both. <code>Dirs|Drives</code>
means list drives, directories, all files that the application can
read, write or execute, and also symlinks to such files/directories.
<h3 class="fn"><a name="SortSpec">QDir::SortSpec</a></h3>
This enum describes how QDir is to sort entries in a directory when
it returns a list of them. The sort value is specified by or-ing
together values from the following list: <ul>
<li> <code>Name</code> - sort by name
<li> <code>Time</code> - sort by time (modification time)
<li> <code>Size</code> - sort by file size
<li> <code>Unsorted</code> - do not sort
<li> <code>DirsFirst</code> - put all directories first in the list
<li> <code>Reversed</code> - reverse the sort order
<li> <code>IgnoreCase</code> - sort case-insensitively
<p></ul>
<p>You can only specify one of the first four. If you specify both <code>DirsFirst</code> and <code>Reversed,</code> directories are still put first but the
list is otherwise reversed.
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="b10816"></a>QDir::QDir()</h3>
<p>Constructs a QDir pointing to the current directory.
<p>See also <a href="#2ec6fd">currentDirPath</a>().
<h3 class="fn"><a name="2b09fb"></a>QDir::QDir(const<a href="qstring.html">QString</a>&path, const<a href="qstring.html">QString</a>&nameFilter=QString::null, intsortSpec=Name|IgnoreCase, intfilterSpec=All)</h3>
<p>Constructs a QDir.
<p>Arguments:
<ul>
<li><em>path</em> is the directory.
<li><em>nameFilter</em> is the file name filter.
<li><em>sortSpec</em> is the sort specification, which describes how to
sort the files in the directory.
<li><em>filterSpec</em> is the filter specification, which describes how
to filter the files in the directory.
</ul>
Most of these arguments (except <em>path)</em> have optional values.
<p>Example:
<pre> // lists all files in /tmp
<a href="qdir.html">QDir</a> d( "/tmp" );
for ( int i=0; i<d.<a href="#c4eb7d">count</a>(); i++ )
printf( "%s\n", d[i] );
</pre>
<p>If <em>path</em> is "" or null, the directory is set to "." (the current
directory). If <em>nameFilter</em> is "" or null, it is set to "*" (all
files).
<p>No check is made to ensure that the directory exists.
<p>See also <a href="#26eec3">exists</a>(), <a href="#ca643e">setPath</a>(), <a href="#7e369a">setNameFilter</a>(), <a href="#a96204">setFilter</a>() and <a href="#9155b3">setSorting</a>().
<h3 class="fn"><a name="5aea25"></a>QDir::QDir(constQDir&d)</h3>
<p>Constructs a QDir that is a copy of the given directory.
<p>See also <a href="#305f8d">operator=</a>().
<h3 class="fn"><a name="1fc49a"></a>QDir::~QDir() <code>[virtual]</code></h3>
<p>Destructs the QDir and cleans up.
<h3 class="fn"><a href="qstring.html">QString</a><a name="1719a2"></a>QDir::absFilePath(const<a href="qstring.html">QString</a>&fileName, boolacceptAbsPath=TRUE)const <code>[virtual]</code></h3>
<p>Returns the absolute path name of a file in the directory. Does NOT check if
the file actually exists in the directory. Redundant multiple separators
or "." and ".." directories in <em>fileName</em> will NOT be removed (see
<a href="#d17301">cleanDirPath</a>()).
<p>If <em>acceptAbsPath</em> is TRUE a <em>fileName</em> starting with a separator
('/') will be returned without change.
if <em>acceptAbsPath</em> is FALSE an absolute path will be appended to
the directory path.
<p>See also <a href="#89e03a">filePath</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="bf5f8c"></a>QDir::absPath()const <code>[virtual]</code></h3>
<p>Returns the absolute (a path that starts with '/') path, which may
contain symbolic links, but never contains redundant ".", ".." or
multiple separators.
<p>See also <a href="#ca643e">setPath</a>(), <a href="#631a70">canonicalPath</a>(), <a href="#26eec3">exists</a>(), <a href="#d17301">cleanDirPath</a>(), <a href="#96243a">dirName</a>() and <a href="#1719a2">absFilePath</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="631a70"></a>QDir::canonicalPath()const <code>[virtual]</code></h3>
<p>Returns the canonical path, i.e. a path without symbolic links or
redundant "." or ".." elements.
<p>On systems that do not have symbolic links this function will always
return the same string that absPath returns. If the canonical path
does not exist (normally due to dangling symbolic links)
canonicalPath() returns a null string.
<p>See also <a href="#f7ebde">path</a>(), <a href="#bf5f8c">absPath</a>(), <a href="#26eec3">exists</a>(), <a href="#d17301">cleanDirPath</a>(), <a href="#96243a">dirName</a>(), <a href="#1719a2">absFilePath</a>() and <a href="qstring.html#7a8210">QString::isNull</a>().
<h3 class="fn">bool<a name="f0fc10"></a>QDir::cd(const<a href="qstring.html">QString</a>&dirName, boolacceptAbsPath=TRUE) <code>[virtual]</code></h3>
<p>Changes directory by descending into the given directory. Returns
TRUE if the new directory exists and is readable. Note that the logical
cd operation is NOT performed if the new directory does not exist.
<p>If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
will cd to the absolute directory, if <em>acceptAbsPath</em> is FALSE
any number of separators at the beginning of <em>dirName</em> will be removed.
<p>Example:
<pre> <a href="qdir.html">QDir</a> d = QDir::home(); // now points to home directory
if ( !d.<a href="#f0fc10">cd</a>("c++") ) { // now points to "c++" under home directory if OK
<a href="qfileinfo.html">QFileInfo</a> fi( d, "c++" );
if ( fi.<a href="qfileinfo.html#a1625c">exists</a>() ) {
if ( fi.<a href="qfileinfo.html#70e102">isDir</a>() )
<a href="qapplication.html#290ef4">qWarning</a>( "Cannot cd into \"%s\".", (char*)d.<a href="#1719a2">absFilePath</a>("c++") );
else
<a href="qapplication.html#290ef4">qWarning</a>( "Cannot create directory \"%s\"\n"
"A file named \"c++\" already exists in \"%s\"",
(const char *)d.<a href="#1719a2">absFilePath</a>("c++"),
(const char *)d.<a href="#f7ebde">path</a>() );
return;
} else {
<a href="qapplication.html#290ef4">qWarning</a>( "Creating directory \"%s\"",
(const char *) d.<a href="#1719a2">absFilePath</a>("c++") );
if ( !d.<a href="#7397c3">mkdir</a>( "c++" ) ) {
<a href="qapplication.html#290ef4">qWarning</a>("Could not create directory \"%s\"",
(const char *)d.<a href="#1719a2">absFilePath</a>("c++") );
return;
}
}
}
</pre>
<p>Calling cd( ".." ) is equivalent to calling <a href="#f3b312">cdUp</a>().
<p>See also <a href="#f3b312">cdUp</a>(), <a href="#6dc6f9">isReadable</a>(), <a href="#26eec3">exists</a>() and <a href="#f7ebde">path</a>().
<h3 class="fn">bool<a name="f3b312"></a>QDir::cdUp() <code>[virtual]</code></h3>
<p>Changes directory by moving one directory up the path followed to arrive
at the current directory.
<p>Returns TRUE if the new directory exists and is readable. Note that the
logical cdUp() operation is not performed if the new directory does not
exist.
<p>See also <a href="#f0fc10">cd</a>(), <a href="#6dc6f9">isReadable</a>(), <a href="#26eec3">exists</a>() and <a href="#f7ebde">path</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="d17301"></a>QDir::cleanDirPath(const<a href="qstring.html">QString</a>&filePath) <code>[static]</code></h3>
<p>Removes all multiple directory separators ('/') and resolves
any "." or ".." found in the path.
<p>Symbolic links are kept. This function does not return the
canonical path, but rather the most simplified version of the input.
"../stuff" becomes "stuff", "stuff/../nonsense" becomes "nonsense"
and "\\stuff\\more\\..\\nonsense" becomes "\\stuff\\nonsense".
<p>See also <a href="#bf5f8c">absPath</a>() and <a href="#631a70">canonicalPath</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="91f780"></a>QDir::convertSeparators(const<a href="qstring.html">QString</a>&pathName) <code>[static]</code></h3>
<p>Converts the '/' separators in <em>pathName</em> to system native
separators. Returns the translated string.
<p>On Windows, convertSeparators("c:/winnt/system32") returns
"c:\winnt\system32".
<p>No conversion is done on UNIX.
<h3 class="fn">void<a name="48abfa"></a>QDir::convertToAbs() <code>[virtual]</code></h3>
<p>Converts the directory path to an absolute path. If it is already
absolute nothing is done.
<p>See also <a href="#4f10b1">isRelative</a>().
<h3 class="fn">uint<a name="c4eb7d"></a>QDir::count()const</h3>
<p>Returns the number of files that was found.
Equivalent to <a href="#2f79b2">entryList</a>().count().
<p>See also <a href="#54898d">operator[]</a>() and <a href="#2f79b2">entryList</a>().
<h3 class="fn">QDir<a name="9ddfe3"></a>QDir::current() <code>[static]</code></h3>
<p>Returns the current directory.
<p>See also <a href="#2ec6fd">currentDirPath</a>() and <a href="#2b09fb">QDir::QDir</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="2ec6fd"></a>QDir::currentDirPath() <code>[static]</code></h3>
<p>Returns the absolute path of the current directory.
<p>See also <a href="#9ddfe3">current</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="96243a"></a>QDir::dirName()const <code>[virtual]</code></h3>
<p>Returns the name of the directory, this is NOT 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. the root directory) a null string is
returned.
<p>No check is made to ensure that a directory with this name actually exists.
<p>See also <a href="#f7ebde">path</a>(), <a href="#bf5f8c">absPath</a>(), <a href="#1719a2">absFilePath</a>(), <a href="#26eec3">exists</a>() and <a href="qstring.html#7a8210">QString::isNull</a>().
<h3 class="fn">constQFileInfoList*<a name="308bab"></a>QDir::drives() <code>[static]</code></h3>
<p>Returns a list of the root directories on this system. On
win32, 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 (e.g. "/").
<p>The returned pointer is owned by Qt. Callers should <em>not</em> delete or
modify it.
<h3 class="fn"><a href="qstrlist.html">QStrList</a><a name="317a83"></a>QDir::encodedEntryList(const<a href="qstring.html">QString</a>&nameFilter, intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const <code>[virtual]</code></h3>
<p>This function is included to easy porting from Qt 1.x to Qt 2.0,
it is the same as <a href="#2f79b2">entryList</a>(), but encodes the filenames as 8-bit
strings using QFile::encodedName().
<p>It is more efficient to use entryList().
<h3 class="fn"><a href="qstrlist.html">QStrList</a><a name="94521a"></a>QDir::encodedEntryList(intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const <code>[virtual]</code></h3>
<p>This function is included to easy porting from Qt 1.x to Qt 2.0,
it is the same as <a href="#2f79b2">entryList</a>(), but encodes the filenames as 8-bit
strings using QFile::encodedName().
<p>It is more efficient to use entryList().
<h3 class="fn">constQFileInfoList*<a name="fd6c87"></a>QDir::entryInfoList(const<a href="qstring.html">QString</a>&nameFilter, intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const <code>[virtual]</code></h3>
<p>Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all files and directories in
the directory pointed to using the <a href="#9155b3">setSorting</a>(), <a href="#a96204">setFilter</a>() and
<a href="#7e369a">setNameFilter</a>() specifications.
<p>The the filter and sorting specifications can be overridden using the
<em>nameFilter, filterSpec</em> and <em>sortSpec</em> arguments.
<p>Returns 0 if the directory is unreadable or does not exist.
<p>The returned pointer is a const pointer to a QFileInfoList. The list is
owned by the QDir object and will be reused on the next call to
<a href="#789222">entryInfoList</a>() for the same QDir instance. If you want to keep the
entries of the list after a subsequent call to this function you will
need to copy them.
<p>See also <a href="#2f79b2">entryList</a>(), <a href="#7e369a">setNameFilter</a>(), <a href="#9155b3">setSorting</a>() and <a href="#a96204">setFilter</a>().
<h3 class="fn">constQFileInfoList*<a name="789222"></a>QDir::entryInfoList(intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const <code>[virtual]</code></h3>
<p>Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all files and directories in
the directory pointed to using the <a href="#9155b3">setSorting</a>(), <a href="#a96204">setFilter</a>() and
<a href="#7e369a">setNameFilter</a>() specifications.
<p>The the filter and sorting specifications can be overridden using the
<em>filterSpec</em> and <em>sortSpec</em> arguments.
<p>Returns 0 if the directory is unreadable or does not exist.
<p>The returned pointer is a const pointer to a QFileInfoList. The list is
owned by the QDir object and will be reused on the next call to
entryInfoList() for the same QDir instance. If you want to keep the
entries of the list after a subsequent call to this function you will
need to copy them.
<p>See also <a href="#2f79b2">entryList</a>(), <a href="#7e369a">setNameFilter</a>(), <a href="#9155b3">setSorting</a>() and <a href="#a96204">setFilter</a>().
<h3 class="fn"><a href="qstringlist.html">QStringList</a><a name="2f79b2"></a>QDir::entryList(const<a href="qstring.html">QString</a>&nameFilter, intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const <code>[virtual]</code></h3>
<p>Returns a list of the names of all files and directories in the directory
indicated by the <a href="#9155b3">setSorting</a>(), <a href="#a96204">setFilter</a>() and <a href="#7e369a">setNameFilter</a>()
specifications.
<p>The the filter and sorting specifications can be overridden using the
<em>nameFilter, filterSpec</em> and <em>sortSpec</em> arguments.
<p>Returns and empty list if the directory is unreadable or does not exist.
<p>See also <a href="#789222">entryInfoList</a>(), <a href="#7e369a">setNameFilter</a>(), <a href="#9155b3">setSorting</a>(), <a href="#a96204">setFilter</a>() and <a href="#317a83">encodedEntryList</a>().
<h3 class="fn"><a href="qstringlist.html">QStringList</a><a name="94f61d"></a>QDir::entryList(intfilterSpec=DefaultFilter, intsortSpec=DefaultSort)const <code>[virtual]</code></h3>
<p>Returns a list of the names of all files and directories in the directory
indicated by the <a href="#9155b3">setSorting</a>(), <a href="#a96204">setFilter</a>() and <a href="#7e369a">setNameFilter</a>()
specifications.
<p>The the filter and sorting specifications can be overridden using the
<em>filterSpec</em> and <em>sortSpec</em> arguments.
<p>Returns an empty list if the directory is unreadable or does not exist.
<p>See also <a href="#789222">entryInfoList</a>(), <a href="#7e369a">setNameFilter</a>(), <a href="#9155b3">setSorting</a>(), <a href="#a96204">setFilter</a>() and <a href="#317a83">encodedEntryList</a>().
<h3 class="fn">bool<a name="ffe704"></a>QDir::exists()const <code>[virtual]</code></h3>
<p>Returns TRUE if the directory exists. (If a file with the same
name is found this function will of course return FALSE).
<p>See also <a href="qfileinfo.html#a1625c">QFileInfo::exists</a>() and <a href="qfile.html#900285">QFile::exists</a>().
<h3 class="fn">bool<a name="26eec3"></a>QDir::exists(const<a href="qstring.html">QString</a>&name, boolacceptAbsPath=TRUE) <code>[virtual]</code></h3>
<p>Checks for existence of a file.
<p>If <em>acceptAbsPaths</em> is TRUE a path starting with a separator ('/')
will check the file with the absolute path, if <em>acceptAbsPath</em> is FALSE
any number of separators at the beginning of <em>name</em> will be removed.
<p>Returns TRUE if the file exists, otherwise FALSE.
<p>See also <a href="qfileinfo.html#a1625c">QFileInfo::exists</a>() and <a href="qfile.html#900285">QFile::exists</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="89e03a"></a>QDir::filePath(const<a href="qstring.html">QString</a>&fileName, boolacceptAbsPath=TRUE)const <code>[virtual]</code></h3>
<p>Returns the path name of a file in the directory. Does NOT check if
the file actually exists in the directory. If the QDir is relative
the returned path name will also be relative. Redundant multiple separators
or "." and ".." directories in <em>fileName</em> will not be removed (see
<a href="#d17301">cleanDirPath</a>()).
<p>If <em>acceptAbsPath</em> is TRUE a <em>fileName</em> starting with a separator
('/') will be returned without change.
If <em>acceptAbsPath</em> is FALSE an absolute path will be appended to
the directory path.
<p>See also <a href="#1719a2">absFilePath</a>(), <a href="#4f10b1">isRelative</a>() and <a href="#631a70">canonicalPath</a>().
<h3 class="fn">QDir::FilterSpec<a name="fd8686"></a>QDir::filter()const</h3>
<p>Returns the value set by <a href="#a96204">setFilter</a>().
<h3 class="fn">QDir<a name="15d497"></a>QDir::home() <code>[static]</code></h3>
<p>Returns the home directory.
<p>See also <a href="#b3b787">homeDirPath</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="b3b787"></a>QDir::homeDirPath() <code>[static]</code></h3>
<p>Returns the absolute path for the user's home directory,
<p>See also <a href="#15d497">home</a>().
<h3 class="fn">bool<a name="6dc6f9"></a>QDir::isReadable()const <code>[virtual]</code></h3>
<p>Returns TRUE if the directory is readable AND we can open files by
name. This function will return FALSE if only one of these is present.<p><b>Warning:</b> A FALSE value from this function is not a guarantee that files
in the directory are not accessible.
<p>See also <a href="qfileinfo.html#aea2a7">QFileInfo::isReadable</a>().
<h3 class="fn">bool<a name="4f10b1"></a>QDir::isRelative()const <code>[virtual]</code></h3>
<p>Returns TRUE if the directory path is relative to the current directory,
FALSE if the path is absolute (e.g. under UNIX a path is relative if it
does not start with a '/').
<p>According to Einstein this function should always return TRUE.
<p>See also <a href="#48abfa">convertToAbs</a>().
<h3 class="fn">bool<a name="221836"></a>QDir::isRelativePath(const<a href="qstring.html">QString</a>&path) <code>[static]</code></h3>
<p>Returns TRUE if the path is relative, FALSE if it is absolute.
<p>See also <a href="#4f10b1">isRelative</a>().
<h3 class="fn">bool<a name="e40b71"></a>QDir::isRoot()const <code>[virtual]</code></h3>
<p>Returns TRUE if the directory is the root directory, otherwise FALSE.
<p>Note: If the directory is a symbolic link to the root directory this
function returns FALSE. If you want to test for this you can use
<a href="#631a70">canonicalPath</a>():
<p>Example:
<pre> <a href="qdir.html">QDir</a> d( "/tmp/root_link" );
d = d.<a href="#631a70">canonicalPath</a>();
if ( d.<a href="#e40b71">isRoot</a>() )
<a href="qapplication.html#290ef4">qWarning</a>( "It IS a root link!" );
</pre>
<p>See also <a href="#a62796">root</a>() and <a href="#d0fb47">rootDirPath</a>().
<h3 class="fn">bool<a name="4a6938"></a>QDir::match(const<a href="qstring.html">QString</a>&filter, const<a href="qstring.html">QString</a>&fileName) <code>[static]</code></h3>
<p>Returns TRUE if the <em>fileName</em> matches the wildcard <em>filter. Filter</em> may also contain multiple wildcards separated by spaces or
semicolons.
<p>See also <a href="qregexp.html">QRegExp</a>.
<h3 class="fn">bool<a name="16e80b"></a>QDir::match(const<a href="qstringlist.html">QStringList</a>&filters, const<a href="qstring.html">QString</a>&fileName) <code>[static]</code></h3>
<p>Returns TRUE if the <em>fileName</em> matches one of the wildcards in the list <em>filters.</em>
<p>See also <a href="qregexp.html">QRegExp</a>.
<h3 class="fn">bool<a name="43f4f9"></a>QDir::matchAllDirs()const</h3>
<p>Returns the value set by <a href="#d205dd">setMatchAllDirs</a>()
<p>See also <a href="#d205dd">setMatchAllDirs</a>().
<h3 class="fn">bool<a name="7397c3"></a>QDir::mkdir(const<a href="qstring.html">QString</a>&dirName, boolacceptAbsPath=TRUE)const <code>[virtual]</code></h3>
<p>Creates a directory.
<p>If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
will create the absolute directory, if <em>acceptAbsPath</em> is FALSE
any number of separators at the beginning of <em>dirName</em> will be removed.
<p>Returns TRUE if successful, otherwise FALSE.
<p>See also <a href="#753b37">rmdir</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="cee483"></a>QDir::nameFilter()const</h3>
<p>Returns the string set by <a href="#7e369a">setNameFilter</a>().
<h3 class="fn">bool<a name="707dfc"></a>QDir::operator!=(constQDir&d)const <code>[virtual]</code></h3>
<p>Returns TRUE if the <em>d</em> and this dir have different path or
different sort/filter settings, otherwise FALSE.
<h3 class="fn">QDir&<a name="305f8d"></a>QDir::operator=(const<a href="qstring.html">QString</a>&path)</h3>
<p>Sets the directory path to be the given path.
<h3 class="fn">QDir&<a name="c8eb7a"></a>QDir::operator=(constQDir&d)</h3>
<p>Makes a copy of d and assigns it to this QDir.
<h3 class="fn">bool<a name="a0e236"></a>QDir::operator==(constQDir&d)const <code>[virtual]</code></h3>
<p>Returns TRUE if the <em>d</em> and this dir have the same path and all sort
and filter settings are equal, otherwise FALSE.
<h3 class="fn"><a href="qstring.html">QString</a><a name="54898d"></a>QDir::operator[](intindex)const</h3>
<p>Returns the file name at position <em>index</em> in the list of found file
names.
Equivalent to <a href="#2f79b2">entryList</a>().at(index).
<p>Returns null if the <em>index</em> is out of range or if the entryList()
function failed.
<p>See also <a href="#c4eb7d">count</a>() and <a href="#2f79b2">entryList</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="f7ebde"></a>QDir::path()const <code>[virtual]</code></h3>
<p>Returns the path, this may contain symbolic links, but never contains
redundant ".", ".." or multiple separators.
<p>The returned path can be either absolute or relative (see <a href="#ca643e">setPath</a>()).
<p>See also <a href="#ca643e">setPath</a>(), <a href="#bf5f8c">absPath</a>(), <a href="#26eec3">exists</a>(), <a href="#d17301">cleanDirPath</a>(), <a href="#96243a">dirName</a>(), <a href="#1719a2">absFilePath</a>() and <a href="#91f780">convertSeparators</a>().
<h3 class="fn">bool<a name="14c4f4"></a>QDir::remove(const<a href="qstring.html">QString</a>&fileName, boolacceptAbsPath=TRUE) <code>[virtual]</code></h3>
<p>Removes a file.
<p>If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
will remove the file with the absolute path, if <em>acceptAbsPath</em> is FALSE
any number of separators at the beginning of <em>fileName</em> will be removed.
<p>Returns TRUE if successful, otherwise FALSE.
<h3 class="fn">bool<a name="a7d8c0"></a>QDir::rename(const<a href="qstring.html">QString</a>&name, const<a href="qstring.html">QString</a>&newName, boolacceptAbsPaths=TRUE) <code>[virtual]</code></h3>
<p>Renames a file.
<p>If <em>acceptAbsPaths</em> is TRUE a path starting with a separator ('/')
will rename the file with the absolute path, if <em>acceptAbsPath</em> is FALSE
any number of separators at the beginning of <em>name</em> will be removed.
<p>Returns TRUE if successful, otherwise FALSE.
<p>On most file systems, rename() fails only if oldName does not exist
or if <em>newName</em> and <em>oldName</em> are not on the same partition.
On Windows, rename() will fail if <em>newName</em> already exists. However,
there are also other reasons why rename() can fail. For example, on
at least one file system rename() fails if newName points to an open
file.
<h3 class="fn">bool<a name="753b37"></a>QDir::rmdir(const<a href="qstring.html">QString</a>&dirName, boolacceptAbsPath=TRUE)const <code>[virtual]</code></h3>
<p>Removes a directory.
<p>If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
will remove the absolute directory, if <em>acceptAbsPath</em> is FALSE
any number of separators at the beginning of <em>dirName</em> will be removed.
<p>The directory must be empty for rmdir() to succeed.
<p>Returns TRUE if successful, otherwise FALSE.
<p>See also <a href="#7397c3">mkdir</a>().
<h3 class="fn">QDir<a name="a62796"></a>QDir::root() <code>[static]</code></h3>
<p>Returns the root directory.
<p>See also <a href="#d0fb47">rootDirPath</a>() and <a href="#308bab">drives</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="d0fb47"></a>QDir::rootDirPath() <code>[static]</code></h3>
<p>Returns the absolute path for the root directory ("/" under UNIX).
<p>See also <a href="#a62796">root</a>() and <a href="#308bab">drives</a>().
<h3 class="fn">char<a name="682599"></a>QDir::separator() <code>[static]</code></h3>
<p>Returns the native directory separator; '/' under UNIX and '\' under
MS-DOS, Windows NT and OS/2.
<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.
<h3 class="fn">bool<a name="5faf24"></a>QDir::setCurrent(const<a href="qstring.html">QString</a>&path) <code>[static]</code></h3>
<p>Sets the the current directory. Returns TRUE if successful.
<h3 class="fn">void<a name="a96204"></a>QDir::setFilter(intfilterSpec) <code>[virtual]</code></h3>
<p>Sets the filter used by <a href="#2f79b2">entryList</a>() and <a href="#789222">entryInfoList</a>(). The filter is used
to specify the kind of files that should be returned by entryList() and
entryInfoList().
<p>See also <a href="#fd8686">filter</a>() and <a href="#7e369a">setNameFilter</a>().
<h3 class="fn">void<a name="d205dd"></a>QDir::setMatchAllDirs(boolenable) <code>[virtual]</code></h3>
<p>If <em>enable</em> is TRUE, all directories will be listed (even if they do not
match the filter or the name filter), otherwise only matched directories
will be listed.
<p>See also <a href="#43f4f9">matchAllDirs</a>().
<p>Bugs and limitations:
<ul>
<li>Currently, directories that do not match the filter will not be
included (the name filter will be ignored as expected).
</ul>
<h3 class="fn">void<a name="7e369a"></a>QDir::setNameFilter(const<a href="qstring.html">QString</a>&nameFilter) <code>[virtual]</code></h3>
<p>Sets the name filter used by <a href="#2f79b2">entryList</a>() and <a href="#789222">entryInfoList</a>().
<p>The name filter is a wildcarding filter that understands "*" and "?"
wildcards, You may specify several filter entries separated by a " " or a ";". If
you want entryList() and entryInfoList() to list all files ending with
".cpp" and all files ending with ".h", you simply call
dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h")
<p>See also <a href="#cee483">nameFilter</a>() and <a href="#a96204">setFilter</a>().
<h3 class="fn">void<a name="ca643e"></a>QDir::setPath(const<a href="qstring.html">QString</a>&path) <code>[virtual]</code></h3>
<p>Sets the path of the directory. The path is cleaned of redundant ".", ".."
and multiple separators. No check is made to ensure that a directory
with this path exists.
<p>The path can be either absolute or relative. Absolute paths begin with the
directory separator ('/') or a drive specification (not
applicable to UNIX).
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". You can use the function <a href="#4f10b1">isRelative</a>() to check if a QDir
is using a relative or an absolute file path. You can call the function
<a href="#48abfa">convertToAbs</a>() to convert a relative QDir to an absolute one.
<p>See also <a href="#f7ebde">path</a>(), <a href="#bf5f8c">absPath</a>(), <a href="#26eec3">exists</a>(), <a href="#d17301">cleanDirPath</a>(), <a href="#96243a">dirName</a>(), <a href="#1719a2">absFilePath</a>(), <a href="#4f10b1">isRelative</a>() and <a href="#48abfa">convertToAbs</a>().
<h3 class="fn">void<a name="9155b3"></a>QDir::setSorting(intsortSpec) <code>[virtual]</code></h3>
<p>Sets the sorting order used by <a href="#2f79b2">entryList</a>() and <a href="#789222">entryInfoList</a>().
<p>The <em>sortSpec</em> is specified by or-ing values from the enum
<a href="#SortSpec">SortSpec</a>. The different values are:
<p>One of these:
<dl compact>
<dt>Name<dd> Sort by name (alphabetical order).
<dt>Time<dd> Sort by time (most recent first).
<dt>Size<dd> Sort by size (largest first).
<dt>Unsorted<dd> Use the operating system order (UNIX does NOT sort
alphabetically).
<p>ORed with zero or more of these:
<p><dt>DirsFirst<dd> Always put directory names first.
<dt>Reversed<dd> Reverse sort order.
<dt>IgnoreCase<dd> Ignore case when sorting by name.
</dl>
<h3 class="fn">QDir::SortSpec<a name="a6d587"></a>QDir::sorting()const</h3>
<p>Returns the value set by <a href="#9155b3">setSorting</a>()
<p>See also <a href="#9155b3">setSorting</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|