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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
|
'\" t
.TH QDir 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QDir \- Access to directory structures and their contents in a platform-independent way
.SH SYNOPSIS
All the functions in this class are reentrant when TQt is built with thread support.</p>
.PP
\fC#include <ntqdir.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "enum \fBFilterSpec\fR { 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 }"
.br
.ti -1c
.BI "enum \fBSortSpec\fR { Name = 0x00, Time = 0x01, Size = 0x02, Unsorted = 0x03, SortByMask = 0x03, DirsFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10, LocaleAware = 0x20, DefaultSort = -1 }"
.br
.ti -1c
.BI "\fBQDir\fR ()"
.br
.ti -1c
.BI "\fBQDir\fR ( const TQString & path, const TQString & nameFilter = TQString::null, int sortSpec = Name | IgnoreCase, int filterSpec = All )"
.br
.ti -1c
.BI "\fBQDir\fR ( const QDir & d )"
.br
.ti -1c
.BI "virtual \fB~QDir\fR ()"
.br
.ti -1c
.BI "QDir & \fBoperator=\fR ( const QDir & d )"
.br
.ti -1c
.BI "QDir & \fBoperator=\fR ( const TQString & path )"
.br
.ti -1c
.BI "virtual void \fBsetPath\fR ( const TQString & path )"
.br
.ti -1c
.BI "virtual TQString \fBpath\fR () const"
.br
.ti -1c
.BI "virtual TQString \fBabsPath\fR () const"
.br
.ti -1c
.BI "virtual TQString \fBcanonicalPath\fR () const"
.br
.ti -1c
.BI "virtual TQString \fBdirName\fR () const"
.br
.ti -1c
.BI "virtual TQString \fBfilePath\fR ( const TQString & fileName, bool acceptAbsPath = TRUE ) const"
.br
.ti -1c
.BI "virtual TQString \fBabsFilePath\fR ( const TQString & fileName, bool acceptAbsPath = TRUE ) const"
.br
.ti -1c
.BI "virtual bool \fBcd\fR ( const TQString & dirName, bool acceptAbsPath = TRUE )"
.br
.ti -1c
.BI "virtual bool \fBcdUp\fR ()"
.br
.ti -1c
.BI "TQString \fBnameFilter\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetNameFilter\fR ( const TQString & nameFilter )"
.br
.ti -1c
.BI "FilterSpec \fBfilter\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetFilter\fR ( int filterSpec )"
.br
.ti -1c
.BI "SortSpec \fBsorting\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetSorting\fR ( int sortSpec )"
.br
.ti -1c
.BI "bool \fBmatchAllDirs\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetMatchAllDirs\fR ( bool enable )"
.br
.ti -1c
.BI "uint \fBcount\fR () const"
.br
.ti -1c
.BI "TQString \fBoperator[]\fR ( int index ) const"
.br
.ti -1c
.BI "virtual TQStrList encodedEntryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const \fI(obsolete)\fR"
.br
.ti -1c
.BI "virtual TQStrList encodedEntryList ( const TQString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const \fI(obsolete)\fR"
.br
.ti -1c
.BI "virtual TQStringList \fBentryList\fR ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const"
.br
.ti -1c
.BI "virtual TQStringList \fBentryList\fR ( const TQString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const"
.br
.ti -1c
.BI "virtual const QFileInfoList * \fBentryInfoList\fR ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const"
.br
.ti -1c
.BI "virtual const QFileInfoList * \fBentryInfoList\fR ( const TQString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const"
.br
.ti -1c
.BI "virtual bool \fBmkdir\fR ( const TQString & dirName, bool acceptAbsPath = TRUE ) const"
.br
.ti -1c
.BI "virtual bool \fBrmdir\fR ( const TQString & dirName, bool acceptAbsPath = TRUE ) const"
.br
.ti -1c
.BI "virtual bool \fBisReadable\fR () const"
.br
.ti -1c
.BI "virtual bool \fBexists\fR () const"
.br
.ti -1c
.BI "virtual bool \fBisRoot\fR () const"
.br
.ti -1c
.BI "virtual bool \fBisRelative\fR () const"
.br
.ti -1c
.BI "virtual void \fBconvertToAbs\fR ()"
.br
.ti -1c
.BI "virtual bool \fBoperator==\fR ( const QDir & d ) const"
.br
.ti -1c
.BI "virtual bool \fBoperator!=\fR ( const QDir & d ) const"
.br
.ti -1c
.BI "virtual bool \fBremove\fR ( const TQString & fileName, bool acceptAbsPath = TRUE )"
.br
.ti -1c
.BI "virtual bool \fBrename\fR ( const TQString & oldName, const TQString & newName, bool acceptAbsPaths = TRUE )"
.br
.ti -1c
.BI "virtual bool \fBexists\fR ( const TQString & name, bool acceptAbsPath = TRUE )"
.br
.ti -1c
.BI "void \fBrefresh\fR () const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "TQString \fBconvertSeparators\fR ( const TQString & pathName )"
.br
.ti -1c
.BI "const QFileInfoList * \fBdrives\fR ()"
.br
.ti -1c
.BI "char \fBseparator\fR ()"
.br
.ti -1c
.BI "bool \fBsetCurrent\fR ( const TQString & path )"
.br
.ti -1c
.BI "QDir \fBcurrent\fR ()"
.br
.ti -1c
.BI "QDir \fBhome\fR ()"
.br
.ti -1c
.BI "QDir \fBroot\fR ()"
.br
.ti -1c
.BI "TQString \fBcurrentDirPath\fR ()"
.br
.ti -1c
.BI "TQString \fBhomeDirPath\fR ()"
.br
.ti -1c
.BI "TQString \fBrootDirPath\fR ()"
.br
.ti -1c
.BI "bool \fBmatch\fR ( const TQStringList & filters, const TQString & fileName )"
.br
.ti -1c
.BI "bool \fBmatch\fR ( const TQString & filter, const TQString & fileName )"
.br
.ti -1c
.BI "TQString \fBcleanDirPath\fR ( const TQString & filePath )"
.br
.ti -1c
.BI "bool \fBisRelativePath\fR ( const TQString & path )"
.br
.in -1c
.SH DESCRIPTION
The QDir class provides access to directory structures and their contents in a platform-independent way.
.PP
A QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system.
.PP
A QDir can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator "/" (optionally preceded by a drive specification under Windows). If you always use "/" as a directory separator, TQt will translate your paths to conform to the underlying operating system. Relative file names begin with a directory name or a file name and specify a path relative to the current directory.
.PP
The "current" path refers to the application's working directory. A QDir's own path is set and retrieved with setPath() and path().
.PP
An example of an absolute path is the string "/tmp/quartz", a relative path might look like "src/fatlib". You can use the function isRelative() to check if a QDir is using a relative or an absolute file path. Call convertToAbs() to convert a relative QDir to an absolute one. For a simplified path use cleanDirPath(). To obtain a path which has no symbolic links or redundant ".." elements use canonicalPath(). The path can be set with setPath(), and changed with cd() and cdUp().
.PP
QDir provides several static functions, for example, setCurrent() to set the application's working directory and currentDirPath() to retrieve the application's working directory. Access to some common paths is provided with the static functions, current(), home() and root() which return QDir objects or currentDirPath(), homeDirPath() and rootDirPath() which return the path as a string. If you want to know about your application's path use QApplication::applicationDirPath().
.PP
The number of entries in a directory is returned by count(). Obtain a string list of the names of all the files and directories in a directory with entryList(). If you prefer a list of QFileInfo pointers use entryInfoList(). Both these functions can apply a name filter, an attributes filter (e.g. read-only, files not directories, etc.), and a sort order. The filters and sort may be set with calls to setNameFilter(), setFilter() and setSorting(). They may also be specified in the entryList() and entryInfoList()'s arguments.
.PP
Create a new directory with mkdir(), rename a directory with rename() and remove an existing directory with rmdir(). Remove a file with remove(). You can interrogate a directory with exists(), isReadable() and isRoot().
.PP
To get a path with a filename use filePath(), and to get a directory name use dirName(); neither of these functions checks for the existence of the file or directory.
.PP
The list of root directories is provided by drives(); on Unix systems this returns a list containing one root directory, "/"; on Windows the list will usually contain "C:/", and possibly "D:/", etc.
.PP
It is easiest to work with "/" separators in TQt code. If you need to present a path to the user or need a path in a form suitable for a function in the underlying operating system use convertSeparators().
.PP
Examples:
.)l
.PP
See if a directory exists.
.PP
.nf
.br
QDir d( "example" ); // "./example"
.br
if ( !d.exists() )
.br
tqWarning( "Cannot find the example directory" );
.br
.fi
.PP
Traversing directories and reading a file.
.PP
.nf
.br
QDir d = QDir::root(); // "/"
.br
if ( !d.cd("tmp") ) { // "/tmp"
.br
tqWarning( "Cannot find the \\"/tmp\\" directory" );
.br
} else {
.br
QFile f( d.filePath("ex1.txt") ); // "/tmp/ex1.txt"
.br
if ( !f.open(IO_ReadWrite) )
.br
tqWarning( "Cannot create the file %s", f.name() );
.br
}
.br
.fi
.PP
A program that lists all the files in the current directory (excluding symbolic links), sorted by size, smallest first:
.PP
.nf
.br
#include <stdio.h>
.br
#include <ntqdir.h>
.br
.br
int main( int argc, char **argv )
.br
{
.br
QDir d;
.br
d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
.br
d.setSorting( QDir::Size | QDir::Reversed );
.br
.br
const QFileInfoList *list = d.entryInfoList();
.br
QFileInfoListIterator it( *list );
.br
QFileInfo *fi;
.br
.br
printf( " Bytes Filename\\n" );
.br
while ( (fi = it.current()) != 0 ) {
.br
printf( "%10li %s\\n", fi->size(), fi->fileName().latin1() );
.br
++it;
.br
}
.br
return 0;
.br
}
.br
.fi
.PP
See also QApplication::applicationDirPath() and Input/Output and Networking.
.SS "Member Type Documentation"
.SH "QDir::FilterSpec"
This enum describes the filtering options available to QDir, e.g. for entryList() and entryInfoList(). The filter value is specified by OR-ing together values from the following list:
.TP
\fCQDir::Dirs\fR - List directories only.
.TP
\fCQDir::Files\fR - List files only.
.TP
\fCQDir::Drives\fR - List disk drives (ignored under Unix).
.TP
\fCQDir::NoSymLinks\fR - Do not list symbolic links (ignored by operating systems that don't support symbolic links).
.TP
\fCQDir::All\fR - List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System).
.TP
\fCQDir::TypeMask\fR - A mask for the the Dirs, Files, Drives and NoSymLinks flags.
.TP
\fCQDir::Readable\fR - List files for which the application has read access.
.TP
\fCQDir::Writable\fR - List files for which the application has write access.
.TP
\fCQDir::Executable\fR - List files for which the application has execute access. Executables needs to be combined with Dirs or Files.
.TP
\fCQDir::RWEMask\fR - A mask for the Readable, Writable and Executable flags.
.TP
\fCQDir::Modified\fR - Only list files that have been modified (ignored under Unix).
.TP
\fCQDir::Hidden\fR - List hidden files (on Unix, files starting with a .).
.TP
\fCQDir::System\fR - List system files (on Unix, FIFOs, sockets and device files)
.TP
\fCQDir::AccessMask\fR - A mask for the Readable, Writable, Executable Modified, Hidden and System flags
.TP
\fCQDir::DefaultFilter\fR - Internal flag.
.PP
If you do not set any of Readable, Writable or Executable, QDir will set all three of them. This makes the default easy to write and at the same time useful.
.PP
Examples:
.)l \fCReadable|Writable\fR means list all files for which the
application has read access, write access or both. \fCDirs|Drives\fR means list drives, directories, all files that the application can read, write or execute, and also symlinks to such files/directories.
.SH "QDir::SortSpec"
This enum describes the sort options available to QDir, e.g. for entryList() and entryInfoList(). The sort value is specified by OR-ing together values from the following list:
.TP
\fCQDir::Name\fR - Sort by name.
.TP
\fCQDir::Time\fR - Sort by time (modification time).
.TP
\fCQDir::Size\fR - Sort by file size.
.TP
\fCQDir::Unsorted\fR - Do not sort.
.TP
\fCQDir::SortByMask\fR - A mask for Name, Time and Size.
.TP
\fCQDir::DirsFirst\fR - Put the directories first, then the files.
.TP
\fCQDir::Reversed\fR - Reverse the sort order.
.TP
\fCQDir::IgnoreCase\fR - Sort case-insensitively.
.TP
\fCQDir::LocaleAware\fR - Sort names using locale aware compares
.TP
\fCQDir::DefaultSort\fR - Internal flag.
.PP
You can only specify one of the first four.
.PP
If you specify both DirsFirst and Reversed, directories are still put first, but in reverse order; the files will be listed after the directories, again in reverse order.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QDir::QDir ()"
Constructs a QDir pointing to the current directory (".").
.PP
See also currentDirPath().
.SH "QDir::QDir ( const TQString & path, const TQString & nameFilter = TQString::null, int sortSpec = Name | IgnoreCase, int filterSpec = All )"
Constructs a QDir with path \fIpath\fR, that filters its entries by name using \fInameFilter\fR and by attributes using \fIfilterSpec\fR. It also sorts the names using \fIsortSpec\fR.
.PP
The default \fInameFilter\fR is an empty string, which excludes nothing; the default \fIfilterSpec\fR is All, which also means exclude nothing. The default \fIsortSpec\fR is \fCName|IgnoreCase\fR, i.e. sort by name case-insensitively.
.PP
Example that lists all the files in "/tmp":
.PP
.nf
.br
QDir d( "/tmp" );
.br
for ( int i = 0; i < d.count(); i++ )
.br
printf( "%s\\n", d[i] );
.br
.fi
.PP
If \fIpath\fR is "" or TQString::null, QDir uses "." (the current directory). If \fInameFilter\fR is "" or TQString::null, QDir uses the name filter "*" (all files).
.PP
Note that \fIpath\fR need not exist.
.PP
See also exists(), setPath(), setNameFilter(), setFilter(), and setSorting().
.SH "QDir::QDir ( const QDir & d )"
Constructs a QDir that is a copy of the directory \fId\fR.
.PP
See also operator=().
.SH "QDir::~QDir ()\fC [virtual]\fR"
Destroys the QDir frees up its resources.
.SH "TQString QDir::absFilePath ( const TQString & fileName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"
Returns the absolute path name of a file in the directory. Does \fInot\fR check if the file actually exists in the directory. Redundant multiple separators or "." and ".." directories in \fIfileName\fR will not be removed (see cleanDirPath()).
.PP
If \fIacceptAbsPath\fR is TRUE a \fIfileName\fR starting with a separator "/" will be returned without change. If \fIacceptAbsPath\fR is FALSE an absolute path will be prepended to the fileName and the resultant string returned.
.PP
See also filePath().
.SH "TQString QDir::absPath () const\fC [virtual]\fR"
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
.PP
See also setPath(), canonicalPath(), exists(), cleanDirPath(), dirName(), and absFilePath().
.PP
Example: fileiconview/qfileiconview.cpp.
.SH "TQString QDir::canonicalPath () const\fC [virtual]\fR"
Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.
.PP
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 TQString::null.
.PP
See also path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), and TQString::isNull().
.SH "bool QDir::cd ( const TQString & dirName, bool acceptAbsPath = TRUE )\fC [virtual]\fR"
Changes the QDir's directory to \fIdirName\fR.
.PP
If \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will cause the function to change to the absolute directory. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed and the function will descend into \fIdirName\fR.
.PP
Returns TRUE if the new directory exists and is readable; otherwise returns FALSE. Note that the logical cd() operation is not performed if the new directory does not exist.
.PP
Calling cd( ".." ) is equivalent to calling cdUp().
.PP
See also cdUp(), isReadable(), exists(), and path().
.PP
Example: fileiconview/mainwindow.cpp.
.SH "bool QDir::cdUp ()\fC [virtual]\fR"
Changes directory by moving one directory up from the QDir's current directory.
.PP
Returns TRUE if the new directory exists and is readable; otherwise returns FALSE. Note that the logical cdUp() operation is not performed if the new directory does not exist.
.PP
See also cd(), isReadable(), exists(), and path().
.SH "TQString QDir::cleanDirPath ( const TQString & filePath )\fC [static]\fR"
Removes all multiple directory separators "/" and resolves any"
."s or ".."s found in the path, \fIfilePath\fR.
.PP
Symbolic links are kept. This function does not return the canonical path, but rather the simplest version of the input. For example, "./local" becomes "local", "local/../bin" becomes" bin" and "/local/usr/../bin" becomes "/local/bin".
.PP
See also absPath() and canonicalPath().
.SH "TQString QDir::convertSeparators ( const TQString & pathName )\fC [static]\fR"
Returns \fIpathName\fR with the '/' separators converted to separators that are appropriate for the underlying operating system.
.PP
On Windows, convertSeparators("c:/winnt/system32") returns" c:\\winnt\\system32".
.PP
The returned string may be the same as the argument on some operating systems, for example on Unix.
.PP
Examples:
.)l dirview/dirview.cpp and fileiconview/qfileiconview.cpp.
.SH "void QDir::convertToAbs ()\fC [virtual]\fR"
Converts the directory path to an absolute path. If it is already absolute nothing is done.
.PP
See also isRelative().
.SH "uint QDir::count () const"
Returns the total number of directories and files that were found.
.PP
Equivalent to entryList().count().
.PP
See also operator[]() and entryList().
.SH "QDir QDir::current ()\fC [static]\fR"
Returns the application's current directory.
.PP
Use path() to access a QDir object's path.
.PP
See also currentDirPath() and QDir::QDir().
.SH "TQString QDir::currentDirPath ()\fC [static]\fR"
Returns the absolute path of the application's current directory.
.PP
See also current().
.PP
Examples:
.)l dirview/dirview.cpp, helpviewer/helpwindow.cpp, and qdir/qdir.cpp.
.SH "TQString QDir::dirName () const\fC [virtual]\fR"
Returns the name of the directory; this is \fInot\fR the same as the path, e.g. a directory with the name "mail", might have the path" /var/spool/mail". If the directory has no name (e.g. it is the root directory) TQString::null is returned.
.PP
No check is made to ensure that a directory with this name actually exists.
.PP
See also path(), absPath(), absFilePath(), exists(), and TQString::isNull().
.SH "const QFileInfoList * QDir::drives ()\fC [static]\fR"
Returns a list of the root directories on this system. On Windows this returns a number of QFileInfo objects containing "C:/", "D:/" etc. On other operating systems, it returns a list containing just one root directory (e.g. "/").
.PP
The returned pointer is owned by Qt. Callers should \fInot\fR delete or modify it.
.PP
Example: dirview/main.cpp.
.SH "TQStrList QDir::encodedEntryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This function is included to easy porting from TQt 1.x to TQt 2.0, it is the same as entryList(), but encodes the filenames as 8-bit strings using QFile::encodedName().
.PP
It is more efficient to use entryList().
.SH "TQStrList QDir::encodedEntryList ( const TQString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
This function is included to easy porting from TQt 1.x to TQt 2.0, it is the same as entryList(), but encodes the filenames as 8-bit strings using QFile::encodedName().
.PP
It is more efficient to use entryList().
.SH "const QFileInfoList * QDir::entryInfoList ( const TQString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
.PP
The filter and sorting specifications can be overridden using the \fInameFilter\fR, \fIfilterSpec\fR and \fIsortSpec\fR arguments.
.PP
Returns 0 if the directory is unreadable or does not exist.
.PP
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 must copy them.
.PP
Note: QFileInfoList is really a TQPtrList<QFileInfo>.
.PP
See also entryList(), setNameFilter(), setSorting(), and setFilter().
.PP
Examples:
.)l dirview/dirview.cpp and fileiconview/qfileiconview.cpp.
.SH "const QFileInfoList * QDir::entryInfoList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
.PP
The filter and sorting specifications can be overridden using the \fIfilterSpec\fR and \fIsortSpec\fR arguments.
.PP
Returns 0 if the directory is unreadable or does not exist.
.PP
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 must copy them.
.PP
Note: QFileInfoList is really a TQPtrList<QFileInfo>.
.PP
See also entryList(), setNameFilter(), setSorting(), and setFilter().
.SH "TQStringList QDir::entryList ( const TQString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"
Returns a list of the names of all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
.PP
The filter and sorting specifications can be overridden using the \fInameFilter\fR, \fIfilterSpec\fR and \fIsortSpec\fR arguments.
.PP
Returns an empty list if the directory is unreadable or does not exist.
.PP
See also entryInfoList(), setNameFilter(), setSorting(), and setFilter().
.PP
Example: table/statistics/statistics.cpp.
.SH "TQStringList QDir::entryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns a list of the names of all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
.PP
The filter and sorting specifications can be overridden using the \fIfilterSpec\fR and \fIsortSpec\fR arguments.
.PP
Returns an empty list if the directory is unreadable or does not exist.
.PP
See also entryInfoList(), setNameFilter(), setSorting(), and setFilter().
.SH "bool QDir::exists ( const TQString & name, bool acceptAbsPath = TRUE )\fC [virtual]\fR"
Checks for the existence of the file \fIname\fR.
.PP
If \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will check the file with the absolute path. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIname\fR will be removed and the resultant file name will be checked.
.PP
Returns TRUE if the file exists; otherwise returns FALSE.
.PP
See also QFileInfo::exists() and QFile::exists().
.SH "bool QDir::exists () const\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns TRUE if the \fIdirectory\fR exists; otherwise returns FALSE. (If a file with the same name is found this function will return FALSE).
.PP
See also QFileInfo::exists() and QFile::exists().
.SH "TQString QDir::filePath ( const TQString & fileName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"
Returns the path name of a file in the directory. Does \fInot\fR 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 \fIfileName\fR will not be removed (see cleanDirPath()).
.PP
If \fIacceptAbsPath\fR is TRUE a \fIfileName\fR starting with a separator "/" will be returned without change. If \fIacceptAbsPath\fR is FALSE an absolute path will be prepended to the fileName and the resultant string returned.
.PP
See also absFilePath(), isRelative(), and canonicalPath().
.SH "FilterSpec QDir::filter () const"
Returns the value set by setFilter()
.SH "QDir QDir::home ()\fC [static]\fR"
Returns the home directory.
.PP
Under Windows the \fCHOME\fR environment variable is used. If this does not exist the \fCUSERPROFILE\fR environment variable is used. If that does not exist the path is formed by concatenating the \fCHOMEDRIVE\fR and \fCHOMEPATH\fR environment variables. If they don't exist the rootDirPath() is used (this uses the \fCSystemDrive\fR environment variable). If none of these exist "C:\" is used.
.PP
Under non-Windows operating systems the \fCHOME\fR environment variable is used if it exists, otherwise rootDirPath() is used.
.PP
See also homeDirPath().
.SH "TQString QDir::homeDirPath ()\fC [static]\fR"
Returns the absolute path of the user's home directory.
.PP
See also home().
.SH "bool QDir::isReadable () const\fC [virtual]\fR"
Returns TRUE if the directory is readable \fIand\fR we can open files by name; otherwise returns FALSE.
.PP
\fBWarning:\fR A FALSE value from this function is not a guarantee that files in the directory are not accessible.
.PP
See also QFileInfo::isReadable().
.PP
Examples:
.)l dirview/dirview.cpp and fileiconview/qfileiconview.cpp.
.SH "bool QDir::isRelative () const\fC [virtual]\fR"
Returns TRUE if the directory path is relative to the current directory and returns FALSE if the path is absolute (e.g. under UNIX a path is relative if it does not start with a "/").
.PP
See also convertToAbs().
.SH "bool QDir::isRelativePath ( const TQString & path )\fC [static]\fR"
Returns TRUE if \fIpath\fR is relative; returns FALSE if it is absolute.
.PP
See also isRelative().
.SH "bool QDir::isRoot () const\fC [virtual]\fR"
Returns TRUE if the directory is the root directory; otherwise returns FALSE.
.PP
Note: If the directory is a symbolic link to the root directory this function returns FALSE. If you want to test for this use canonicalPath(), e.g.
.PP
.nf
.br
QDir d( "/tmp/root_link" );
.br
d = d.canonicalPath();
.br
if ( d.isRoot() )
.br
tqWarning( "It is a root link" );
.br
.fi
.PP
See also root() and rootDirPath().
.SH "bool QDir::match ( const TQString & filter, const TQString & fileName )\fC [static]\fR"
Returns TRUE if the \fIfileName\fR matches the wildcard (glob) pattern \fIfilter\fR; otherwise returns FALSE. The \fIfilter\fR may contain multiple patterns separated by spaces or semicolons.
.PP
(See TQRegExp wildcard matching.)
.PP
See also TQRegExp::match().
.SH "bool QDir::match ( const TQStringList & filters, const TQString & fileName )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns TRUE if the \fIfileName\fR matches any of the wildcard (glob) patterns in the list of \fIfilters\fR; otherwise returns FALSE.
.PP
(See TQRegExp wildcard matching.)
.PP
See also TQRegExp::match().
.SH "bool QDir::matchAllDirs () const"
Returns the value set by setMatchAllDirs()
.PP
See also setMatchAllDirs().
.SH "bool QDir::mkdir ( const TQString & dirName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"
Creates a directory.
.PP
If \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will create the absolute directory; if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed.
.PP
Returns TRUE if successful; otherwise returns FALSE.
.PP
See also rmdir().
.SH "TQString QDir::nameFilter () const"
Returns the string set by setNameFilter()
.SH "bool QDir::operator!= ( const QDir & d ) const\fC [virtual]\fR"
Returns TRUE if directory \fId\fR and this directory have different paths or different sort or filter settings; otherwise returns FALSE.
.PP
Example:
.PP
.nf
.br
// The current directory is "/usr/local"
.br
QDir d1( "/usr/local/bin" );
.br
QDir d2( "bin" );
.br
if ( d1 != d2 )
.br
tqDebug( "They differ" );
.br
.fi
.SH "QDir & QDir::operator= ( const QDir & d )"
Makes a copy of QDir \fId\fR and assigns it to this QDir.
.SH "QDir & QDir::operator= ( const TQString & path )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the directory path to be the given \fIpath\fR.
.SH "bool QDir::operator== ( const QDir & d ) const\fC [virtual]\fR"
Returns TRUE if directory \fId\fR and this directory have the same path and their sort and filter settings are the same; otherwise returns FALSE.
.PP
Example:
.PP
.nf
.br
// The current directory is "/usr/local"
.br
QDir d1( "/usr/local/bin" );
.br
QDir d2( "bin" );
.br
d2.convertToAbs();
.br
if ( d1 == d2 )
.br
tqDebug( "They're the same" );
.br
.fi
.SH "TQString QDir::operator[] ( int index ) const"
Returns the file name at position \fIindex\fR in the list of file names. Equivalent to entryList().at(index).
.PP
Returns a TQString::null if the \fIindex\fR is out of range or if the entryList() function failed.
.PP
See also count() and entryList().
.SH "TQString QDir::path () const\fC [virtual]\fR"
Returns the path, this may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
.PP
The returned path can be either absolute or relative (see setPath()).
.PP
See also setPath(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), and convertSeparators().
.SH "void QDir::refresh () const"
Refreshes the directory information.
.SH "bool QDir::remove ( const TQString & fileName, bool acceptAbsPath = TRUE )\fC [virtual]\fR"
Removes the file, \fIfileName\fR.
.PP
If \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will remove the file with the absolute path. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIfileName\fR will be removed and the resultant file name will be removed.
.PP
Returns TRUE if the file is removed successfully; otherwise returns FALSE.
.SH "bool QDir::rename ( const TQString & oldName, const TQString & newName, bool acceptAbsPaths = TRUE )\fC [virtual]\fR"
Renames a file or directory.
.PP
If \fIacceptAbsPaths\fR is TRUE a path starting with a separator ('/') will rename the file with the absolute path; if \fIacceptAbsPaths\fR is FALSE any number of separators at the beginning of the names will be removed.
.PP
Returns TRUE if successful; otherwise returns FALSE.
.PP
On most file systems, rename() fails only if \fIoldName\fR does not exist or if \fInewName\fR and \fIoldName\fR are not on the same partition. On Windows, rename() will fail if \fInewName\fR already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if \fInewName\fR points to an open file.
.PP
Example: fileiconview/qfileiconview.cpp.
.SH "bool QDir::rmdir ( const TQString & dirName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"
Removes a directory.
.PP
If \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will remove the absolute directory; if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed.
.PP
The directory must be empty for rmdir() to succeed.
.PP
Returns TRUE if successful; otherwise returns FALSE.
.PP
See also mkdir().
.SH "QDir QDir::root ()\fC [static]\fR"
Returns the root directory.
.PP
See also rootDirPath() and drives().
.SH "TQString QDir::rootDirPath ()\fC [static]\fR"
Returns the absolute path for the root directory.
.PP
For UNIX operating systems this returns "/". For Windows file systems this normally returns "c:/".
.PP
See also root() and drives().
.SH "char QDir::separator ()\fC [static]\fR"
Returns the native directory separator; "/" under UNIX (including Mac OS X) and "\" under Windows.
.PP
You do not need to use this function to build file paths. If you always use "/", TQt will translate your paths to conform to the underlying operating system.
.SH "bool QDir::setCurrent ( const TQString & path )\fC [static]\fR"
Sets the application's current working directory to \fIpath\fR. Returns TRUE if the directory was successfully changed; otherwise returns FALSE.
.SH "void QDir::setFilter ( int filterSpec )\fC [virtual]\fR"
Sets the filter used by entryList() and entryInfoList() to \fIfilterSpec\fR. The filter is used to specify the kind of files that should be returned by entryList() and entryInfoList(). See QDir::FilterSpec.
.PP
See also filter() and setNameFilter().
.SH "void QDir::setMatchAllDirs ( bool enable )\fC [virtual]\fR"
If \fIenable\fR is TRUE then all directories are included (e.g. in entryList()), and the nameFilter() is only applied to the files. If \fIenable\fR is FALSE then the nameFilter() is applied to both directories and files.
.PP
See also matchAllDirs().
.SH "void QDir::setNameFilter ( const TQString & nameFilter )\fC [virtual]\fR"
Sets the name filter used by entryList() and entryInfoList() to \fInameFilter\fR.
.PP
The \fInameFilter\fR is a wildcard (globbing) filter that understands" *" and "?" wildcards. (See TQRegExp wildcard matching.) You may specify several filter entries all separated by a single space " " or by a semi-colon" ;".
.PP
For example, if you want entryList() and entryInfoList() to list all files ending with either ".cpp" or ".h", you would use either dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h").
.PP
See also nameFilter() and setFilter().
.SH "void QDir::setPath ( const TQString & path )\fC [virtual]\fR"
Sets the path of the directory to \fIpath\fR. The path is cleaned of redundant ".", ".." and of multiple separators. No check is made to ensure that a directory with this path exists.
.PP
The path can be either absolute or relative. Absolute paths begin with the directory separator "/" (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory. An example of an absolute path is the string" /tmp/quartz", a relative path might look like "src/fatlib".
.PP
See also path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), isRelative(), and convertToAbs().
.SH "void QDir::setSorting ( int sortSpec )\fC [virtual]\fR"
Sets the sort order used by entryList() and entryInfoList().
.PP
The \fIsortSpec\fR is specified by OR-ing values from the enum QDir::SortSpec.
.PP
See also sorting() and SortSpec.
.SH "SortSpec QDir::sorting () const"
Returns the value set by setSorting()
.PP
See also setSorting() and SortSpec.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqdir.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR [email protected] .
Please include the name of the manual page (tqdir.3qt) and the Qt
version (3.3.8).
|