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