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