source: trunk/doc/html/qfileinfo.html

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

reference documentation added

File size: 29.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qfileinfo.cpp:52 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QFileInfo Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QFileInfo Class Reference</h1>
33
34<p>The QFileInfo class provides system-independent file information.
35<a href="#details">More...</a>
36<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
37<p><tt>#include &lt;<a href="qfileinfo-h.html">qfileinfo.h</a>&gt;</tt>
38<p><a href="qfileinfo-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn>enum <a href="#PermissionSpec-enum"><b>PermissionSpec</b></a> { ReadOwner = 04000, WriteOwner = 02000, ExeOwner = 01000, ReadUser = 00400, WriteUser = 00200, ExeUser = 00100, ReadGroup = 00040, WriteGroup = 00020, ExeGroup = 00010, ReadOther = 00004, WriteOther = 00002, ExeOther = 00001 }</li>
42<li class=fn><a href="#QFileInfo"><b>QFileInfo</b></a> ()</li>
43<li class=fn><a href="#QFileInfo-2"><b>QFileInfo</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file )</li>
44<li class=fn><a href="#QFileInfo-3"><b>QFileInfo</b></a> ( const&nbsp;QFile&nbsp;&amp;&nbsp;file )</li>
45<li class=fn><a href="#QFileInfo-4"><b>QFileInfo</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d, const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
46<li class=fn><a href="#QFileInfo-5"><b>QFileInfo</b></a> ( const&nbsp;QFileInfo&nbsp;&amp;&nbsp;fi )</li>
47<li class=fn><a href="#~QFileInfo"><b>~QFileInfo</b></a> ()</li>
48<li class=fn>QFileInfo &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QFileInfo&nbsp;&amp;&nbsp;fi )</li>
49<li class=fn>void <a href="#setFile"><b>setFile</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file )</li>
50<li class=fn>void <a href="#setFile-2"><b>setFile</b></a> ( const&nbsp;QFile&nbsp;&amp;&nbsp;file )</li>
51<li class=fn>void <a href="#setFile-3"><b>setFile</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d, const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
52<li class=fn>bool <a href="#exists"><b>exists</b></a> () const</li>
53<li class=fn>void <a href="#refresh"><b>refresh</b></a> () const</li>
54<li class=fn>bool <a href="#caching"><b>caching</b></a> () const</li>
55<li class=fn>void <a href="#setCaching"><b>setCaching</b></a> ( bool&nbsp;enable )</li>
56<li class=fn>QString <a href="#filePath"><b>filePath</b></a> () const</li>
57<li class=fn>QString <a href="#fileName"><b>fileName</b></a> () const</li>
58<li class=fn>QString <a href="#absFilePath"><b>absFilePath</b></a> () const</li>
59<li class=fn>QString <a href="#baseName"><b>baseName</b></a> ( bool&nbsp;complete = FALSE ) const</li>
60<li class=fn>QString <a href="#extension"><b>extension</b></a> ( bool&nbsp;complete = TRUE ) const</li>
61<li class=fn>QString <a href="#dirPath"><b>dirPath</b></a> ( bool&nbsp;absPath = FALSE ) const</li>
62<li class=fn>QDir <a href="#dir"><b>dir</b></a> ( bool&nbsp;absPath = FALSE ) const</li>
63<li class=fn>bool <a href="#isReadable"><b>isReadable</b></a> () const</li>
64<li class=fn>bool <a href="#isWritable"><b>isWritable</b></a> () const</li>
65<li class=fn>bool <a href="#isExecutable"><b>isExecutable</b></a> () const</li>
66<li class=fn>bool <a href="#isHidden"><b>isHidden</b></a> () const</li>
67<li class=fn>bool <a href="#isRelative"><b>isRelative</b></a> () const</li>
68<li class=fn>bool <a href="#convertToAbs"><b>convertToAbs</b></a> ()</li>
69<li class=fn>bool <a href="#isFile"><b>isFile</b></a> () const</li>
70<li class=fn>bool <a href="#isDir"><b>isDir</b></a> () const</li>
71<li class=fn>bool <a href="#isSymLink"><b>isSymLink</b></a> () const</li>
72<li class=fn>QString <a href="#readLink"><b>readLink</b></a> () const</li>
73<li class=fn>QString <a href="#owner"><b>owner</b></a> () const</li>
74<li class=fn>uint <a href="#ownerId"><b>ownerId</b></a> () const</li>
75<li class=fn>QString <a href="#group"><b>group</b></a> () const</li>
76<li class=fn>uint <a href="#groupId"><b>groupId</b></a> () const</li>
77<li class=fn>bool <a href="#permission"><b>permission</b></a> ( int&nbsp;permissionSpec ) const</li>
78<li class=fn>uint <a href="#size"><b>size</b></a> () const</li>
79<li class=fn>QDateTime <a href="#created"><b>created</b></a> () const</li>
80<li class=fn>QDateTime <a href="#lastModified"><b>lastModified</b></a> () const</li>
81<li class=fn>QDateTime <a href="#lastRead"><b>lastRead</b></a> () const</li>
82</ul>
83<hr><a name="details"></a><h2>Detailed Description</h2>
84
85
86
87The QFileInfo class provides system-independent file information.
88<p>
89<p> QFileInfo provides information about a file's name and position
90(path) in the file system, its access rights and whether it is a
91directory or symbolic link, etc. The file's size and last
92modified/read times are also available.
93<p> A QFileInfo can point to a file with either a relative or an
94absolute file path. Absolute file paths begin with the directory
95separator "/" (or with a drive specification on Windows). Relative
96file names begin with a directory name or a file name and specify
97a path relative to the current working directory. An example of an
98absolute path is the string "/tmp/quartz". A relative path might
99look like "src/fatlib". You can use the function <a href="#isRelative">isRelative</a>() to
100check whether a QFileInfo is using a relative or an absolute file
101path. You can call the function <a href="#convertToAbs">convertToAbs</a>() to convert a
102relative QFileInfo's path to an absolute path.
103<p> The file that the QFileInfo works on is set in the constructor or
104later with <a href="#setFile">setFile</a>(). Use <a href="#exists">exists</a>() to see if the file exists and
105<a href="#size">size</a>() to get its size.
106<p> To speed up performance, QFileInfo caches information about the
107file. Because files can be changed by other users or programs, or
108even by other parts of the same program, there is a function that
109refreshes the file information: <a href="#refresh">refresh</a>(). If you want to switch
110off a QFileInfo's caching and force it to access the file system
111every time you request information from it call <a href="#setCaching">setCaching</a>(FALSE).
112<p> The file's type is obtained with <a href="#isFile">isFile</a>(), <a href="#isDir">isDir</a>() and
113<a href="#isSymLink">isSymLink</a>(). The <a href="#readLink">readLink</a>() function provides the name of the file
114the symlink points to.
115<p> Elements of the file's name can be extracted with <a href="#dirPath">dirPath</a>() and
116<a href="#fileName">fileName</a>(). The fileName()'s parts can be extracted with
117<a href="#baseName">baseName</a>() and <a href="#extension">extension</a>().
118<p> The file's dates are returned by <a href="#created">created</a>(), <a href="#lastModified">lastModified</a>() and
119<a href="#lastRead">lastRead</a>(). Information about the file's access permissions is
120obtained with <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and <a href="#isExecutable">isExecutable</a>(). The
121file's ownership is available from <a href="#owner">owner</a>(), <a href="#ownerId">ownerId</a>(), <a href="#group">group</a>() and
122<a href="#groupId">groupId</a>(). You can examine a file's permissions and ownership in a
123single statement using the <a href="#permission">permission</a>() function.
124<p> If you need to read and traverse directories, see the <a href="qdir.html">QDir</a> class.
125<p>See also <a href="io.html">Input/Output and Networking</a>.
126
127<hr><h2>Member Type Documentation</h2>
128<h3 class=fn><a name="PermissionSpec-enum"></a>QFileInfo::PermissionSpec</h3>
129
130<p> This enum is used by the <a href="#permission">permission</a>() function to report the
131permissions and ownership of a file. The values may be OR-ed
132together to test multiple permissions and ownership values.
133<ul>
134<li><tt>QFileInfo::ReadOwner</tt> - The file is readable by the owner of the file.
135<li><tt>QFileInfo::WriteOwner</tt> - The file is writable by the owner of the file.
136<li><tt>QFileInfo::ExeOwner</tt> - The file is executable by the owner of the file.
137<li><tt>QFileInfo::ReadUser</tt> - The file is readable by the user.
138<li><tt>QFileInfo::WriteUser</tt> - The file is writable by the user.
139<li><tt>QFileInfo::ExeUser</tt> - The file is executable by the user.
140<li><tt>QFileInfo::ReadGroup</tt> - The file is readable by the group.
141<li><tt>QFileInfo::WriteGroup</tt> - The file is writable by the group.
142<li><tt>QFileInfo::ExeGroup</tt> - The file is executable by the group.
143<li><tt>QFileInfo::ReadOther</tt> - The file is readable by anyone.
144<li><tt>QFileInfo::WriteOther</tt> - The file is writable by anyone.
145<li><tt>QFileInfo::ExeOther</tt> - The file is executable by anyone.
146</ul><p> <b>Warning:</b> The semantics of <a href="#PermissionSpec-enum">ReadUser</a>, <a href="#PermissionSpec-enum">WriteUser</a> and <a href="#PermissionSpec-enum">ExeUser</a> are
147unfortunately not platform independent: on Unix, the rights of the owner of
148the file are returned and on Windows the rights of the current user are
149returned. This behavior might change in a future Qt version. If you want to
150find the rights of the owner of the file, you should use the flags <a href="#PermissionSpec-enum">ReadOwner</a>, <a href="#PermissionSpec-enum">WriteOwner</a> and <a href="#PermissionSpec-enum">ExeOwner</a>. If you want to find out the
151rights of the current user, you should use <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and
152<a href="#isExecutable">isExecutable</a>().
153
154<hr><h2>Member Function Documentation</h2>
155<h3 class=fn><a name="QFileInfo"></a>QFileInfo::QFileInfo ()
156</h3>
157Constructs a new empty QFileInfo.
158
159<h3 class=fn><a name="QFileInfo-2"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file )
160</h3>
161Constructs a new QFileInfo that gives information about the given
162file. The <em>file</em> can also include an absolute or relative path.
163<p> <b>Warning:</b> Some functions might behave in a counter-intuitive way
164if <em>file</em> has a trailing directory separator.
165<p> <p>See also <a href="#setFile">setFile</a>(), <a href="#isRelative">isRelative</a>(), <a href="qdir.html#setCurrent">QDir::setCurrent</a>(), and <a href="qdir.html#isRelativePath">QDir::isRelativePath</a>().
166
167<h3 class=fn><a name="QFileInfo-3"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qfile.html">QFile</a>&nbsp;&amp;&nbsp;file )
168</h3>
169Constructs a new QFileInfo that gives information about file <em>file</em>.
170<p> If the <em>file</em> has a relative path, the QFileInfo will also have a
171relative path.
172<p> <p>See also <a href="#isRelative">isRelative</a>().
173
174<h3 class=fn><a name="QFileInfo-4"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;d, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )
175</h3>
176Constructs a new QFileInfo that gives information about the file
177called <em>fileName</em> in the directory <em>d</em>.
178<p> If <em>d</em> has a relative path, the QFileInfo will also have a
179relative path.
180<p> <p>See also <a href="#isRelative">isRelative</a>().
181
182<h3 class=fn><a name="QFileInfo-5"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qfileinfo.html">QFileInfo</a>&nbsp;&amp;&nbsp;fi )
183</h3>
184Constructs a new QFileInfo that is a copy of <em>fi</em>.
185
186<h3 class=fn><a name="~QFileInfo"></a>QFileInfo::~QFileInfo ()
187</h3>
188Destroys the QFileInfo and frees its resources.
189
190<h3 class=fn><a href="qstring.html">QString</a> <a name="absFilePath"></a>QFileInfo::absFilePath () const
191</h3>
192Returns the absolute path including the file name.
193<p> The absolute path name consists of the full path and the file
194name. On Unix this will always begin with the root, '/',
195directory. On Windows this will always begin 'D:/' where D is a
196drive letter, except for network shares that are not mapped to a
197drive letter, in which case the path will begin '//sharename/'.
198<p> This function returns the same as <a href="#filePath">filePath</a>(), unless <a href="#isRelative">isRelative</a>()
199is TRUE.
200<p> If the QFileInfo is empty it returns <a href="qdir.html#currentDirPath">QDir::currentDirPath</a>().
201<p> This function can be time consuming under Unix (in the order of
202milliseconds).
203<p> <p>See also <a href="#isRelative">isRelative</a>() and <a href="#filePath">filePath</a>().
204
205<p>Examples: <a href="biff-example.html#x1954">biff/biff.cpp</a> and <a href="fileiconview-example.html#x820">fileiconview/qfileiconview.cpp</a>.
206<h3 class=fn><a href="qstring.html">QString</a> <a name="baseName"></a>QFileInfo::baseName ( bool&nbsp;complete = FALSE ) const
207</h3>
208Returns the base name of the file.
209<p> If <em>complete</em> is FALSE (the default) the base name consists of
210all characters in the file name up to (but not including) the <em>first</em> '.' character.
211<p> If <em>complete</em> is TRUE the base name consists of all characters in
212the file up to (but not including) the <em>last</em> '.' character.
213<p> The path is not included in either case.
214<p> Example:
215<pre>
216 QFileInfo fi( "/tmp/archive.tar.gz" );
217 <a href="qstring.html">QString</a> base = fi.<a href="#baseName">baseName</a>(); // base = "archive"
218 base = fi.<a href="#baseName">baseName</a>( TRUE ); // base = "archive.tar"
219 </pre>
220
221<p> <p>See also <a href="#fileName">fileName</a>() and <a href="#extension">extension</a>().
222
223<h3 class=fn>bool <a name="caching"></a>QFileInfo::caching () const
224</h3>
225
226<p> Returns TRUE if caching is enabled; otherwise returns FALSE.
227<p> <p>See also <a href="#setCaching">setCaching</a>() and <a href="#refresh">refresh</a>().
228
229<h3 class=fn>bool <a name="convertToAbs"></a>QFileInfo::convertToAbs ()
230</h3>
231Converts the file's path to an absolute path.
232<p> If it is already absolute, nothing is done.
233<p> <p>See also <a href="#filePath">filePath</a>() and <a href="#isRelative">isRelative</a>().
234
235<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="created"></a>QFileInfo::created () const
236</h3>
237Returns the date and time when the file was created.
238<p> On platforms where this information is not available, returns the
239same as <a href="#lastModified">lastModified</a>().
240<p> <p>See also <a href="#lastModified">lastModified</a>() and <a href="#lastRead">lastRead</a>().
241
242<h3 class=fn><a href="qdir.html">QDir</a> <a name="dir"></a>QFileInfo::dir ( bool&nbsp;absPath = FALSE ) const
243</h3>
244Returns the file's path as a <a href="qdir.html">QDir</a> object.
245<p> If the QFileInfo is relative and <em>absPath</em> is FALSE, the QDir
246will be relative; otherwise it will be absolute.
247<p> <p>See also <a href="#dirPath">dirPath</a>(), <a href="#filePath">filePath</a>(), <a href="#fileName">fileName</a>(), and <a href="#isRelative">isRelative</a>().
248
249<p>Example: <a href="fileiconview-example.html#x821">fileiconview/qfileiconview.cpp</a>.
250<h3 class=fn><a href="qstring.html">QString</a> <a name="dirPath"></a>QFileInfo::dirPath ( bool&nbsp;absPath = FALSE ) const
251</h3>
252Returns the file's path.
253<p> If <em>absPath</em> is TRUE an absolute path is returned.
254<p> <p>See also <a href="#dir">dir</a>(), <a href="#filePath">filePath</a>(), <a href="#fileName">fileName</a>(), and <a href="#isRelative">isRelative</a>().
255
256<p>Example: <a href="fileiconview-example.html#x822">fileiconview/qfileiconview.cpp</a>.
257<h3 class=fn>bool <a name="exists"></a>QFileInfo::exists () const
258</h3>
259Returns TRUE if the file exists; otherwise returns FALSE.
260
261<p>Examples: <a href="biff-example.html#x1955">biff/biff.cpp</a>, <a href="distributor-example.html#x2661">distributor/distributor.ui.h</a>, and <a href="i18n-example.html#x1937">i18n/main.cpp</a>.
262<h3 class=fn><a href="qstring.html">QString</a> <a name="extension"></a>QFileInfo::extension ( bool&nbsp;complete = TRUE ) const
263</h3>
264Returns the file's extension name.
265<p> If <em>complete</em> is TRUE (the default), <a href="#extension">extension</a>() returns the
266string of all characters in the file name after (but not
267including) the first '.' character.
268<p> If <em>complete</em> is FALSE, extension() returns the string of all
269characters in the file name after (but not including) the last '.'
270character.
271<p> Example:
272<pre>
273 QFileInfo fi( "/tmp/archive.tar.gz" );
274 <a href="qstring.html">QString</a> ext = fi.<a href="#extension">extension</a>(); // ext = "tar.gz"
275 ext = fi.<a href="#extension">extension</a>( FALSE ); // ext = "gz"
276 </pre>
277
278<p> <p>See also <a href="#fileName">fileName</a>() and <a href="#baseName">baseName</a>().
279
280<p>Example: <a href="qdir-example.html#x1823">qdir/qdir.cpp</a>.
281<h3 class=fn><a href="qstring.html">QString</a> <a name="fileName"></a>QFileInfo::fileName () const
282</h3>
283Returns the name of the file, excluding the path.
284<p> Example:
285<pre>
286 QFileInfo fi( "/tmp/archive.tar.gz" );
287 <a href="qstring.html">QString</a> name = fi.<a href="#fileName">fileName</a>(); // name = "archive.tar.gz"
288 </pre>
289
290<p> <p>See also <a href="#isRelative">isRelative</a>(), <a href="#filePath">filePath</a>(), <a href="#baseName">baseName</a>(), and <a href="#extension">extension</a>().
291
292<p>Examples: <a href="dirview-example.html#x1675">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x823">fileiconview/qfileiconview.cpp</a>, and <a href="ftpclient-example.html#x743">network/ftpclient/ftpmainwindow.ui.h</a>.
293<h3 class=fn><a href="qstring.html">QString</a> <a name="filePath"></a>QFileInfo::filePath () const
294</h3>
295Returns the file name, including the path (which may be absolute
296or relative).
297<p> <p>See also <a href="#isRelative">isRelative</a>() and <a href="#absFilePath">absFilePath</a>().
298
299<p>Examples: <a href="dirview-example.html#x1713">dirview/main.cpp</a> and <a href="fileiconview-example.html#x824">fileiconview/qfileiconview.cpp</a>.
300<h3 class=fn><a href="qstring.html">QString</a> <a name="group"></a>QFileInfo::group () const
301</h3>
302Returns the group of the file. On Windows, on systems where files
303do not have groups, or if an error occurs, <a href="qstring.html#QString-null">QString::null</a> is
304returned.
305<p> This function can be time consuming under Unix (in the order of
306milliseconds).
307<p> <p>See also <a href="#groupId">groupId</a>(), <a href="#owner">owner</a>(), and <a href="#ownerId">ownerId</a>().
308
309<h3 class=fn>uint <a name="groupId"></a>QFileInfo::groupId () const
310</h3>
311Returns the id of the group the file belongs to.
312<p> On Windows and on systems where files do not have groups this
313function always returns (uint) -2.
314<p> <p>See also <a href="#group">group</a>(), <a href="#owner">owner</a>(), and <a href="#ownerId">ownerId</a>().
315
316<h3 class=fn>bool <a name="isDir"></a>QFileInfo::isDir () const
317</h3>
318Returns TRUE if this object points to a directory or to a symbolic
319link to a directory; otherwise returns FALSE.
320<p> <p>See also <a href="#isFile">isFile</a>() and <a href="#isSymLink">isSymLink</a>().
321
322<p>Examples: <a href="dirview-example.html#x1676">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x825">fileiconview/qfileiconview.cpp</a>.
323<h3 class=fn>bool <a name="isExecutable"></a>QFileInfo::isExecutable () const
324</h3>
325Returns TRUE if the file is executable; otherwise returns FALSE.
326<p> <p>See also <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>(), and <a href="#permission">permission</a>().
327
328<h3 class=fn>bool <a name="isFile"></a>QFileInfo::isFile () const
329</h3>
330Returns TRUE if this object points to a file. Returns FALSE if the
331object points to something which isn't a file, e.g. a directory or
332a symlink.
333<p> <p>See also <a href="#isDir">isDir</a>() and <a href="#isSymLink">isSymLink</a>().
334
335<p>Examples: <a href="dirview-example.html#x1677">dirview/dirview.cpp</a>, <a href="distributor-example.html#x2662">distributor/distributor.ui.h</a>, <a href="fileiconview-example.html#x826">fileiconview/qfileiconview.cpp</a>, and <a href="qdir-example.html#x1824">qdir/qdir.cpp</a>.
336<h3 class=fn>bool <a name="isHidden"></a>QFileInfo::isHidden () const
337</h3>
338Returns TRUE if the file is hidden; otherwise returns FALSE.
339<p> On Unix-like operating systems, including Mac OS X, a file is
340hidden if its name begins with ".". On Windows a file is hidden if
341its hidden attribute is set.
342
343<h3 class=fn>bool <a name="isReadable"></a>QFileInfo::isReadable () const
344</h3>
345Returns TRUE if the file is readable; otherwise returns FALSE.
346<p> <p>See also <a href="#isWritable">isWritable</a>(), <a href="#isExecutable">isExecutable</a>(), and <a href="#permission">permission</a>().
347
348<p>Example: <a href="distributor-example.html#x2663">distributor/distributor.ui.h</a>.
349<h3 class=fn>bool <a name="isRelative"></a>QFileInfo::isRelative () const
350</h3>
351Returns TRUE if the file path name is relative. Returns FALSE if
352the path is absolute (e.g. under Unix a path is absolute if it
353begins with a "/").
354
355<h3 class=fn>bool <a name="isSymLink"></a>QFileInfo::isSymLink () const
356</h3>
357Returns TRUE if this object points to a symbolic link (or to a
358shortcut on Windows, or an alias on Mac OS X); otherwise returns
359FALSE.
360<p> <p>See also <a href="#isFile">isFile</a>(), <a href="#isDir">isDir</a>(), and <a href="#readLink">readLink</a>().
361
362<p>Examples: <a href="dirview-example.html#x1678">dirview/dirview.cpp</a>, <a href="distributor-example.html#x2664">distributor/distributor.ui.h</a>, and <a href="fileiconview-example.html#x827">fileiconview/qfileiconview.cpp</a>.
363<h3 class=fn>bool <a name="isWritable"></a>QFileInfo::isWritable () const
364</h3>
365Returns TRUE if the file is writable; otherwise returns FALSE.
366<p> <p>See also <a href="#isReadable">isReadable</a>(), <a href="#isExecutable">isExecutable</a>(), and <a href="#permission">permission</a>().
367
368<p>Example: <a href="distributor-example.html#x2665">distributor/distributor.ui.h</a>.
369<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="lastModified"></a>QFileInfo::lastModified () const
370</h3>
371Returns the date and time when the file was last modified.
372<p> <p>See also <a href="#created">created</a>() and <a href="#lastRead">lastRead</a>().
373
374<p>Example: <a href="biff-example.html#x1956">biff/biff.cpp</a>.
375<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="lastRead"></a>QFileInfo::lastRead () const
376</h3>
377Returns the date and time when the file was last read (accessed).
378<p> On platforms where this information is not available, returns the
379same as <a href="#lastModified">lastModified</a>().
380<p> <p>See also <a href="#created">created</a>() and <a href="#lastModified">lastModified</a>().
381
382<p>Example: <a href="biff-example.html#x1957">biff/biff.cpp</a>.
383<h3 class=fn><a href="qfileinfo.html">QFileInfo</a>&nbsp;&amp; <a name="operator-eq"></a>QFileInfo::operator= ( const&nbsp;<a href="qfileinfo.html">QFileInfo</a>&nbsp;&amp;&nbsp;fi )
384</h3>
385Makes a copy of <em>fi</em> and assigns it to this QFileInfo.
386
387<h3 class=fn><a href="qstring.html">QString</a> <a name="owner"></a>QFileInfo::owner () const
388</h3>
389Returns the owner of the file. On systems where files
390do not have owners, or if an error occurs, <a href="qstring.html#QString-null">QString::null</a> is
391returned.
392<p> This function can be time consuming under Unix (in the order of
393milliseconds).
394<p> <p>See also <a href="#ownerId">ownerId</a>(), <a href="#group">group</a>(), and <a href="#groupId">groupId</a>().
395
396<h3 class=fn>uint <a name="ownerId"></a>QFileInfo::ownerId () const
397</h3>
398Returns the id of the owner of the file.
399<p> On Windows and on systems where files do not have owners this
400function returns ((uint) -2).
401<p> <p>See also <a href="#owner">owner</a>(), <a href="#group">group</a>(), and <a href="#groupId">groupId</a>().
402
403<h3 class=fn>bool <a name="permission"></a>QFileInfo::permission ( int&nbsp;permissionSpec ) const
404</h3>
405Tests for file permissions. The <em>permissionSpec</em> argument can be
406several flags of type <a href="#PermissionSpec-enum">PermissionSpec</a> OR-ed together to check
407for permission combinations.
408<p> On systems where files do not have permissions this function
409always returns TRUE.
410<p> Example:
411<pre>
412 QFileInfo fi( "/tmp/archive.tar.gz" );
413 if ( fi.<a href="#permission">permission</a>( QFileInfo::<a href="#PermissionSpec-enum">WriteUser</a> | QFileInfo::<a href="#PermissionSpec-enum">ReadGroup</a> ) )
414 <a href="qapplication.html#qWarning">qWarning</a>( "I can change the file; my group can read the file" );
415 if ( fi.<a href="#permission">permission</a>( QFileInfo::<a href="#PermissionSpec-enum">WriteGroup</a> | QFileInfo::<a href="#PermissionSpec-enum">WriteOther</a> ) )
416 <a href="qapplication.html#qWarning">qWarning</a>( "The group or others can change the file" );
417 </pre>
418
419<p> <p>See also <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>(), and <a href="#isExecutable">isExecutable</a>().
420
421<h3 class=fn><a href="qstring.html">QString</a> <a name="readLink"></a>QFileInfo::readLink () const
422</h3>
423Returns the name a symlink (or shortcut on Windows) points to, or
424a <a href="qstring.html#QString-null">QString::null</a> if the object isn't a symbolic link.
425<p> This name may not represent an existing file; it is only a string.
426<a href="#exists">QFileInfo::exists</a>() returns TRUE if the symlink points to an
427existing file.
428<p> <p>See also <a href="#exists">exists</a>(), <a href="#isSymLink">isSymLink</a>(), <a href="#isDir">isDir</a>(), and <a href="#isFile">isFile</a>().
429
430<h3 class=fn>void <a name="refresh"></a>QFileInfo::refresh () const
431</h3>
432Refreshes the information about the file, i.e. reads in information
433from the file system the next time a cached property is fetched.
434<p> <p>See also <a href="#setCaching">setCaching</a>().
435
436<h3 class=fn>void <a name="setCaching"></a>QFileInfo::setCaching ( bool&nbsp;enable )
437</h3>
438If <em>enable</em> is TRUE, enables caching of file information. If <em>enable</em> is FALSE caching is disabled.
439<p> When caching is enabled, QFileInfo reads the file information from
440the file system the first time it's needed, but generally not
441later.
442<p> Caching is enabled by default.
443<p> <p>See also <a href="#refresh">refresh</a>() and <a href="#caching">caching</a>().
444
445<h3 class=fn>void <a name="setFile"></a>QFileInfo::setFile ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file )
446</h3>
447Sets the file that the QFileInfo provides information about to <em>file</em>.
448<p> The <em>file</em> can also include an absolute or relative file path.
449Absolute paths begin with the directory separator (e.g. "/" under
450Unix) or a drive specification (under Windows). Relative file
451names begin with a directory name or a file name and specify a
452path relative to the current directory.
453<p> Example:
454<pre>
455 <a href="qstring.html">QString</a> absolute = "/local/bin";
456 <a href="qstring.html">QString</a> relative = "local/bin";
457 QFileInfo absFile( absolute );
458 QFileInfo relFile( relative );
459
460 QDir::<a href="qdir.html#setCurrent">setCurrent</a>( QDir::<a href="qdir.html#rootDirPath">rootDirPath</a>() );
461 // absFile and relFile now point to the same file
462
463 QDir::<a href="qdir.html#setCurrent">setCurrent</a>( "/tmp" );
464 // absFile now points to "/local/bin",
465 // while relFile points to "/tmp/local/bin"
466 </pre>
467
468<p> <p>See also <a href="#isRelative">isRelative</a>(), <a href="qdir.html#setCurrent">QDir::setCurrent</a>(), and <a href="qdir.html#isRelativePath">QDir::isRelativePath</a>().
469
470<p>Example: <a href="biff-example.html#x1958">biff/biff.cpp</a>.
471<h3 class=fn>void <a name="setFile-2"></a>QFileInfo::setFile ( const&nbsp;<a href="qfile.html">QFile</a>&nbsp;&amp;&nbsp;file )
472</h3>
473This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
474<p> Sets the file that the QFileInfo provides information about to <em>file</em>.
475<p> If <em>file</em> includes a relative path, the QFileInfo will also have
476a relative path.
477<p> <p>See also <a href="#isRelative">isRelative</a>().
478
479<h3 class=fn>void <a name="setFile-3"></a>QFileInfo::setFile ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;d, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )
480</h3>
481This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
482<p> Sets the file that the QFileInfo provides information about to <em>fileName</em> in directory <em>d</em>.
483<p> If <em>fileName</em> includes a relative path, the QFileInfo will also
484have a relative path.
485<p> <p>See also <a href="#isRelative">isRelative</a>().
486
487<h3 class=fn>uint <a name="size"></a>QFileInfo::size () const
488</h3>
489Returns the file size in bytes, or 0 if the file does not exist or
490if the size is 0 or if the size cannot be fetched.
491
492<p>Example: <a href="qdir-example.html#x1825">qdir/qdir.cpp</a>.
493<!-- eof -->
494<hr><p>
495This file is part of the <a href="index.html">Qt toolkit</a>.
496Copyright &copy; 1995-2007
497<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
498<table width=100% cellspacing=0 border=0><tr>
499<td>Copyright &copy; 2007
500<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
501<td align=right><div align=right>Qt 3.3.8</div>
502</table></div></address></body>
503</html>
Note: See TracBrowser for help on using the repository browser.