1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/io/qfileinfo.cpp -->
7
<title>Qt 4.0: QFileInfo Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QFileInfo Class Reference</h1>
21
<p>The QFileInfo class provides system-independent file information. <a href="#details">More...</a></p>
22
<pre>#include <QFileInfo></pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
23
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
25
<li><a href="qfileinfo-members.html">List of all members, including inherited members</a></li>
26
<li><a href="qfileinfo-qt3.html">Qt 3 support members</a></li>
28
<a name="public-types"></a>
31
<li><div class="fn"/>flags <b><a href="qfileinfo.html#Permission-enum">PermissionSpec</a></b></li>
33
<a name="public-functions"></a>
34
<h3>Public Functions</h3>
36
<li><div class="fn"/><b><a href="qfileinfo.html#QFileInfo">QFileInfo</a></b> ()</li>
37
<li><div class="fn"/><b><a href="qfileinfo.html#QFileInfo-2">QFileInfo</a></b> ( const QString & <i>file</i> )</li>
38
<li><div class="fn"/><b><a href="qfileinfo.html#QFileInfo-3">QFileInfo</a></b> ( const QFile & <i>file</i> )</li>
39
<li><div class="fn"/><b><a href="qfileinfo.html#QFileInfo-4">QFileInfo</a></b> ( const QDir & <i>dir</i>, const QString & <i>file</i> )</li>
40
<li><div class="fn"/><b><a href="qfileinfo.html#QFileInfo-5">QFileInfo</a></b> ( const QFileInfo & <i>fileinfo</i> )</li>
41
<li><div class="fn"/><b><a href="qfileinfo.html#dtor.QFileInfo">~QFileInfo</a></b> ()</li>
42
<li><div class="fn"/>QDir <b><a href="qfileinfo.html#absoluteDir">absoluteDir</a></b> () const</li>
43
<li><div class="fn"/>QString <b><a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a></b> () const</li>
44
<li><div class="fn"/>QString <b><a href="qfileinfo.html#absolutePath">absolutePath</a></b> () const</li>
45
<li><div class="fn"/>QString <b><a href="qfileinfo.html#baseName">baseName</a></b> () const</li>
46
<li><div class="fn"/>bool <b><a href="qfileinfo.html#caching">caching</a></b> () const</li>
47
<li><div class="fn"/>QString <b><a href="qfileinfo.html#canonicalFilePath">canonicalFilePath</a></b> () const</li>
48
<li><div class="fn"/>QString <b><a href="qfileinfo.html#canonicalPath">canonicalPath</a></b> () const</li>
49
<li><div class="fn"/>QString <b><a href="qfileinfo.html#completeBaseName">completeBaseName</a></b> () const</li>
50
<li><div class="fn"/>QString <b><a href="qfileinfo.html#completeSuffix">completeSuffix</a></b> () const</li>
51
<li><div class="fn"/>QDateTime <b><a href="qfileinfo.html#created">created</a></b> () const</li>
52
<li><div class="fn"/>QDir <b><a href="qfileinfo.html#dir">dir</a></b> () const</li>
53
<li><div class="fn"/>bool <b><a href="qfileinfo.html#exists">exists</a></b> () const</li>
54
<li><div class="fn"/>QString <b><a href="qfileinfo.html#fileName">fileName</a></b> () const</li>
55
<li><div class="fn"/>QString <b><a href="qfileinfo.html#filePath">filePath</a></b> () const</li>
56
<li><div class="fn"/>QString <b><a href="qfileinfo.html#group">group</a></b> () const</li>
57
<li><div class="fn"/>uint <b><a href="qfileinfo.html#groupId">groupId</a></b> () const</li>
58
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isAbsolute">isAbsolute</a></b> () const</li>
59
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isDir">isDir</a></b> () const</li>
60
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isExecutable">isExecutable</a></b> () const</li>
61
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isFile">isFile</a></b> () const</li>
62
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isHidden">isHidden</a></b> () const</li>
63
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isReadable">isReadable</a></b> () const</li>
64
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isRelative">isRelative</a></b> () const</li>
65
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isRoot">isRoot</a></b> () const</li>
66
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isSymLink">isSymLink</a></b> () const</li>
67
<li><div class="fn"/>bool <b><a href="qfileinfo.html#isWritable">isWritable</a></b> () const</li>
68
<li><div class="fn"/>QDateTime <b><a href="qfileinfo.html#lastModified">lastModified</a></b> () const</li>
69
<li><div class="fn"/>QDateTime <b><a href="qfileinfo.html#lastRead">lastRead</a></b> () const</li>
70
<li><div class="fn"/>bool <b><a href="qfileinfo.html#makeAbsolute">makeAbsolute</a></b> ()</li>
71
<li><div class="fn"/>QString <b><a href="qfileinfo.html#owner">owner</a></b> () const</li>
72
<li><div class="fn"/>uint <b><a href="qfileinfo.html#ownerId">ownerId</a></b> () const</li>
73
<li><div class="fn"/>QString <b><a href="qfileinfo.html#path">path</a></b> () const</li>
74
<li><div class="fn"/>bool <b><a href="qfileinfo.html#permission">permission</a></b> ( QFile::Permissions <i>permissions</i> ) const</li>
75
<li><div class="fn"/>QFile::Permissions <b><a href="qfileinfo.html#permissions">permissions</a></b> () const</li>
76
<li><div class="fn"/>QString <b><a href="qfileinfo.html#readLink">readLink</a></b> () const</li>
77
<li><div class="fn"/>void <b><a href="qfileinfo.html#refresh">refresh</a></b> ()</li>
78
<li><div class="fn"/>void <b><a href="qfileinfo.html#setCaching">setCaching</a></b> ( bool <i>enable</i> )</li>
79
<li><div class="fn"/>void <b><a href="qfileinfo.html#setFile">setFile</a></b> ( const QString & <i>file</i> )</li>
80
<li><div class="fn"/>void <b><a href="qfileinfo.html#setFile-2">setFile</a></b> ( const QFile & <i>file</i> )</li>
81
<li><div class="fn"/>void <b><a href="qfileinfo.html#setFile-3">setFile</a></b> ( const QDir & <i>dir</i>, const QString & <i>file</i> )</li>
82
<li><div class="fn"/>qint64 <b><a href="qfileinfo.html#size">size</a></b> () const</li>
83
<li><div class="fn"/>QString <b><a href="qfileinfo.html#suffix">suffix</a></b> () const</li>
84
<li><div class="fn"/>bool <b><a href="qfileinfo.html#operator-not-eq">operator!=</a></b> ( const QFileInfo & <i>fileinfo</i> )</li>
85
<li><div class="fn"/>QFileInfo & <b><a href="qfileinfo.html#operator-eq">operator=</a></b> ( const QFileInfo & <i>fileinfo</i> )</li>
86
<li><div class="fn"/>bool <b><a href="qfileinfo.html#operator-eq-eq">operator==</a></b> ( const QFileInfo & <i>fileinfo</i> )</li>
88
<a name="details"></a>
90
<h2>Detailed Description</h2>
91
<p>The QFileInfo class provides system-independent file information.</p>
92
<p>QFileInfo provides information about a file's name and position (path) in the file system, its access rights and whether it is a directory or symbolic link, etc. The file's size and last modified/read times are also available. QFileInfo can also be used to optain information about a Qt <a href="resources.html#resource-system">resource</a>.</p>
93
<p>A QFileInfo can point to a file with either a relative or an absolute file path. Absolute file paths begin with the directory separator "/" (or with a drive specification on Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current working directory. An example of an absolute path is the string "/tmp/quartz". A relative path might look like "src/fatlib". You can use the function <a href="qfileinfo.html#isRelative">isRelative</a>() to check whether a QFileInfo is using a relative or an absolute file path. You can call the function <a href="qfileinfo.html#makeAbsolute">makeAbsolute</a>() to convert a relative QFileInfo's path to an absolute path.</p>
94
<p>The file that the QFileInfo works on is set in the constructor or later with <a href="qfileinfo.html#setFile">setFile</a>(). Use <a href="qfileinfo.html#exists">exists</a>() to see if the file exists and <a href="qfileinfo.html#size">size</a>() to get its size.</p>
95
<p>To speed up performance, QFileInfo caches information about the file. Because files can be changed by other users or programs, or even by other parts of the same program, there is a function that refreshes the file information: <a href="qfileinfo.html#refresh">refresh</a>(). If you want to switch off a QFileInfo's caching and force it to access the file system every time you request information from it call setCaching(false).</p>
96
<p>The file's type is obtained with <a href="qfileinfo.html#isFile">isFile</a>(), <a href="qfileinfo.html#isDir">isDir</a>() and <a href="qfileinfo.html#isSymLink">isSymLink</a>(). The <a href="qfileinfo.html#readLink">readLink</a>() function provides the name of the file the symlink points to.</p>
97
<p>Elements of the file's name can be extracted with <a href="qfileinfo-qt3.html#dirPath">dirPath</a>() and <a href="qfileinfo.html#fileName">fileName</a>(). The <a href="qfileinfo.html#fileName">fileName</a>()'s parts can be extracted with <a href="qfileinfo.html#baseName">baseName</a>() and <a href="qfileinfo-qt3.html#extension">extension</a>().</p>
98
<p>The file's dates are returned by <a href="qfileinfo.html#created">created</a>(), <a href="qfileinfo.html#lastModified">lastModified</a>() and <a href="qfileinfo.html#lastRead">lastRead</a>(). Information about the file's access permissions is obtained with <a href="qfileinfo.html#isReadable">isReadable</a>(), <a href="qfileinfo.html#isWritable">isWritable</a>() and <a href="qfileinfo.html#isExecutable">isExecutable</a>(). The file's ownership is available from <a href="qfileinfo.html#owner">owner</a>(), <a href="qfileinfo.html#ownerId">ownerId</a>(), <a href="qfileinfo.html#group">group</a>() and <a href="qfileinfo.html#groupId">groupId</a>(). You can examine a file's permissions and ownership in a single statement using the <a href="qfileinfo.html#permission">permission</a>() function.</p>
99
<p>See also <a href="qdir.html">QDir</a> and <a href="qfile.html">QFile</a>.</p>
101
<h2>Member Function Documentation</h2>
102
<h3 class="fn"><a name="QFileInfo"></a>QFileInfo::QFileInfo ()</h3>
103
<p>Constructs a new empty <a href="qfileinfo.html">QFileInfo</a>.</p>
104
<h3 class="fn"><a name="QFileInfo-2"></a>QFileInfo::QFileInfo ( const <a href="qstring.html">QString</a> & <i>file</i> )</h3>
105
<p>Constructs a new <a href="qfileinfo.html">QFileInfo</a> that gives information about the given file. The <i>file</i> can also include an absolute or relative path.</p>
106
<p>See also <a href="qfileinfo.html#setFile">setFile</a>(), <a href="qfileinfo.html#isRelative">isRelative</a>(), <a href="qdir.html#setCurrent">QDir::setCurrent</a>(), and <a href="qdir.html#isRelativePath">QDir::isRelativePath</a>().</p>
107
<h3 class="fn"><a name="QFileInfo-3"></a>QFileInfo::QFileInfo ( const <a href="qfile.html">QFile</a> & <i>file</i> )</h3>
108
<p>Constructs a new <a href="qfileinfo.html">QFileInfo</a> that gives information about file <i>file</i>.</p>
109
<p>If the <i>file</i> has a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
110
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
111
<h3 class="fn"><a name="QFileInfo-4"></a>QFileInfo::QFileInfo ( const <a href="qdir.html">QDir</a> & <i>dir</i>, const <a href="qstring.html">QString</a> & <i>file</i> )</h3>
112
<p>Constructs a new <a href="qfileinfo.html">QFileInfo</a> that gives information about the given <i>file</i> in the directory <i>dir</i>.</p>
113
<p>If <i>dir</i> has a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
114
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
115
<h3 class="fn"><a name="QFileInfo-5"></a>QFileInfo::QFileInfo ( const QFileInfo & <i>fileinfo</i> )</h3>
116
<p>Constructs a new <a href="qfileinfo.html">QFileInfo</a> that is a copy of the given <i>fileinfo</i>.</p>
117
<h3 class="fn"><a name="dtor.QFileInfo"></a>QFileInfo::~QFileInfo ()</h3>
118
<p>Destroys the <a href="qfileinfo.html">QFileInfo</a> and frees its resources.</p>
119
<h3 class="fn"><a name="absoluteDir"></a><a href="qdir.html">QDir</a> QFileInfo::absoluteDir () const</h3>
120
<p>Returns the file's absolute path as a <a href="qdir.html">QDir</a> object.</p>
121
<p>See also <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#isRelative">isRelative</a>(), and <a href="qfileinfo.html#dir">dir</a>().</p>
122
<h3 class="fn"><a name="absoluteFilePath"></a><a href="qstring.html">QString</a> QFileInfo::absoluteFilePath () const</h3>
123
<p>Returns the absolute path including the file name.</p>
124
<p>The absolute path name consists of the full path and the file name. On Unix this will always begin with the root, '/', directory. On Windows this will always begin 'D:/' where D is a drive letter, except for network shares that are not mapped to a drive letter, in which case the path will begin '//sharename/'.</p>
125
<p>This function returns the same as <a href="qfileinfo.html#filePath">filePath</a>(), unless <a href="qfileinfo.html#isRelative">isRelative</a>() is true.</p>
126
<p>If the <a href="qfileinfo.html">QFileInfo</a> is empty it returns <a href="qdir.html#currentPath">QDir::currentPath</a>().</p>
127
<p>This function can be time consuming under Unix (in the order of milliseconds).</p>
128
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>() and <a href="qfileinfo.html#filePath">filePath</a>().</p>
129
<h3 class="fn"><a name="absolutePath"></a><a href="qstring.html">QString</a> QFileInfo::absolutePath () const</h3>
130
<p>Returns the file's path absolute path.</p>
131
<p>This does not include the file name.</p>
132
<p>See also <a href="qfileinfo.html#dir">dir</a>(), <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#isRelative">isRelative</a>(), and <a href="qfileinfo.html#path">path</a>().</p>
133
<h3 class="fn"><a name="baseName"></a><a href="qstring.html">QString</a> QFileInfo::baseName () const</h3>
134
<p>Returns the base name of the file without the path.</p>
135
<p>The base name consists of all characters in the file up to (but not including) the <i>first</i> '.' character.</p>
137
<pre> QFileInfo fi("/tmp/archive.tar.gz");
138
QString base = fi.baseName(); // base = "archive"</pre>
139
<p>See also <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#suffix">suffix</a>(), <a href="qfileinfo.html#completeSuffix">completeSuffix</a>(), and <a href="qfileinfo.html#completeBaseName">completeBaseName</a>().</p>
140
<h3 class="fn"><a name="caching"></a>bool QFileInfo::caching () const</h3>
141
<p>Returns true if caching is enabled; otherwise returns false.</p>
142
<p>See also <a href="qfileinfo.html#setCaching">setCaching</a>() and <a href="qfileinfo.html#refresh">refresh</a>().</p>
143
<h3 class="fn"><a name="canonicalFilePath"></a><a href="qstring.html">QString</a> QFileInfo::canonicalFilePath () const</h3>
144
<p>Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.</p>
145
<p>On systems that do not have symbolic links this function will always return the same string that <a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a>() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalFilePath() returns an empty string.</p>
146
<p>See also <a href="qfileinfo.html#filePath">filePath</a>() and <a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a>().</p>
147
<h3 class="fn"><a name="canonicalPath"></a><a href="qstring.html">QString</a> QFileInfo::canonicalPath () const</h3>
148
<p>Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.</p>
149
<p>On systems that do not have symbolic links this function will always return the same string that <a href="qfileinfo.html#absolutePath">absolutePath</a>() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns an empty string.</p>
150
<p>See also <a href="qfileinfo.html#absolutePath">absolutePath</a>().</p>
151
<h3 class="fn"><a name="completeBaseName"></a><a href="qstring.html">QString</a> QFileInfo::completeBaseName () const</h3>
152
<p>Returns the complete base name of the file without the path.</p>
153
<p>The complete base name consists of all characters in the file up to (but not including) the <i>last</i> '.' character.</p>
155
<pre> QFileInfo fi("/tmp/archive.tar.gz");
156
QString base = fi.completeBaseName(); // base = "archive.tar"</pre>
157
<p>See also <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#suffix">suffix</a>(), <a href="qfileinfo.html#completeSuffix">completeSuffix</a>(), and <a href="qfileinfo.html#baseName">baseName</a>().</p>
158
<h3 class="fn"><a name="completeSuffix"></a><a href="qstring.html">QString</a> QFileInfo::completeSuffix () const</h3>
159
<p>Returns the complete suffix of the file.</p>
160
<p>The complete suffix consists of all characters in the file after (but not including) the first '.'.</p>
162
<pre> QFileInfo fi("/tmp/archive.tar.gz");
163
QString ext = fi.completeSuffix(); // ext = "tar.gz"</pre>
164
<p>See also <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#suffix">suffix</a>(), <a href="qfileinfo.html#baseName">baseName</a>(), and <a href="qfileinfo.html#completeBaseName">completeBaseName</a>().</p>
165
<h3 class="fn"><a name="created"></a><a href="qdatetime.html">QDateTime</a> QFileInfo::created () const</h3>
166
<p>Returns the date and time when the file was created.</p>
167
<p>On most Unix systems, this function returns the time of the last status change. A status change occurs when the file is created, but it also occurs whenever the user writes or sets inode information (for example, changing the file permissions).</p>
168
<p>If neither creation time nor "last status change" time are not available, returns the same as <a href="qfileinfo.html#lastModified">lastModified</a>().</p>
169
<p>See also <a href="qfileinfo.html#lastModified">lastModified</a>() and <a href="qfileinfo.html#lastRead">lastRead</a>().</p>
170
<h3 class="fn"><a name="dir"></a><a href="qdir.html">QDir</a> QFileInfo::dir () const</h3>
171
<p>Returns the file's path as a <a href="qdir.html">QDir</a> object.</p>
172
<p>See also <a href="qfileinfo-qt3.html#dirPath">dirPath</a>(), <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#isRelative">isRelative</a>(), and <a href="qfileinfo.html#absoluteDir">absoluteDir</a>().</p>
173
<h3 class="fn"><a name="exists"></a>bool QFileInfo::exists () const</h3>
174
<p>Returns true if the file exists; otherwise returns false.</p>
175
<h3 class="fn"><a name="fileName"></a><a href="qstring.html">QString</a> QFileInfo::fileName () const</h3>
176
<p>Returns the name of the file, excluding the path.</p>
178
<pre> QFileInfo fi("/tmp/archive.tar.gz");
179
QString name = fi.fileName(); // name = "archive.tar.gz"</pre>
180
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>(), <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#baseName">baseName</a>(), and <a href="qfileinfo-qt3.html#extension">extension</a>().</p>
181
<h3 class="fn"><a name="filePath"></a><a href="qstring.html">QString</a> QFileInfo::filePath () const</h3>
182
<p>Returns the file name, including the path (which may be absolute or relative).</p>
183
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>() and <a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a>().</p>
184
<h3 class="fn"><a name="group"></a><a href="qstring.html">QString</a> QFileInfo::group () const</h3>
185
<p>Returns the group of the file. On Windows, on systems where files do not have groups, or if an error occurs, an empty string is returned.</p>
186
<p>This function can be time consuming under Unix (in the order of milliseconds).</p>
187
<p>See also <a href="qfileinfo.html#groupId">groupId</a>(), <a href="qfileinfo.html#owner">owner</a>(), and <a href="qfileinfo.html#ownerId">ownerId</a>().</p>
188
<h3 class="fn"><a name="groupId"></a><a href="qtglobal.html#uint-typedef">uint</a> QFileInfo::groupId () const</h3>
189
<p>Returns the id of the group the file belongs to.</p>
190
<p>On Windows and on systems where files do not have groups this function always returns (uint) -2.</p>
191
<p>See also <a href="qfileinfo.html#group">group</a>(), <a href="qfileinfo.html#owner">owner</a>(), and <a href="qfileinfo.html#ownerId">ownerId</a>().</p>
192
<h3 class="fn"><a name="isAbsolute"></a>bool QFileInfo::isAbsolute () const</h3>
193
<p>Returns true if the file path name is absolute, otherwise returns false if the path is relative.</p>
194
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
195
<h3 class="fn"><a name="isDir"></a>bool QFileInfo::isDir () const</h3>
196
<p>Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false.</p>
197
<p>See also <a href="qfileinfo.html#isFile">isFile</a>() and <a href="qfileinfo.html#isSymLink">isSymLink</a>().</p>
198
<h3 class="fn"><a name="isExecutable"></a>bool QFileInfo::isExecutable () const</h3>
199
<p>Returns true if the file is executable; otherwise returns false.</p>
200
<p>See also <a href="qfileinfo.html#isReadable">isReadable</a>(), <a href="qfileinfo.html#isWritable">isWritable</a>(), and <a href="qfileinfo.html#permission">permission</a>().</p>
201
<h3 class="fn"><a name="isFile"></a>bool QFileInfo::isFile () const</h3>
202
<p>Returns true if this object points to a file. Returns false if the object points to something which isn't a file, e.g. a directory or a symlink.</p>
203
<p>See also <a href="qfileinfo.html#isDir">isDir</a>() and <a href="qfileinfo.html#isSymLink">isSymLink</a>().</p>
204
<h3 class="fn"><a name="isHidden"></a>bool QFileInfo::isHidden () const</h3>
205
<p>Returns true if this is a `hidden' file; otherwise returns false.</p>
206
<h3 class="fn"><a name="isReadable"></a>bool QFileInfo::isReadable () const</h3>
207
<p>Returns true if the user can read the file; otherwise returns false.</p>
208
<p>See also <a href="qfileinfo.html#isWritable">isWritable</a>(), <a href="qfileinfo.html#isExecutable">isExecutable</a>(), and <a href="qfileinfo.html#permission">permission</a>().</p>
209
<h3 class="fn"><a name="isRelative"></a>bool QFileInfo::isRelative () const</h3>
210
<p>Returns true if the file path name is relative, otherwise returns false if the path is absolute (e.g. under Unix a path is absolute if it begins with a "/").</p>
211
<p>See also <a href="qfileinfo.html#isAbsolute">isAbsolute</a>().</p>
212
<h3 class="fn"><a name="isRoot"></a>bool QFileInfo::isRoot () const</h3>
213
<p>Returns true if the object points to a directory or to a symbolic link to a directory, and that directory is the root directory; otherwise returns false.</p>
214
<h3 class="fn"><a name="isSymLink"></a>bool QFileInfo::isSymLink () const</h3>
215
<p>Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise returns false.</p>
216
<p>See also <a href="qfileinfo.html#isFile">isFile</a>(), <a href="qfileinfo.html#isDir">isDir</a>(), and <a href="qfileinfo.html#readLink">readLink</a>().</p>
217
<h3 class="fn"><a name="isWritable"></a>bool QFileInfo::isWritable () const</h3>
218
<p>Returns true if the user can write to the file; otherwise returns false.</p>
219
<p>See also <a href="qfileinfo.html#isReadable">isReadable</a>(), <a href="qfileinfo.html#isExecutable">isExecutable</a>(), and <a href="qfileinfo.html#permission">permission</a>().</p>
220
<h3 class="fn"><a name="lastModified"></a><a href="qdatetime.html">QDateTime</a> QFileInfo::lastModified () const</h3>
221
<p>Returns the date and time when the file was last modified.</p>
222
<p>See also <a href="qfileinfo.html#created">created</a>() and <a href="qfileinfo.html#lastRead">lastRead</a>().</p>
223
<h3 class="fn"><a name="lastRead"></a><a href="qdatetime.html">QDateTime</a> QFileInfo::lastRead () const</h3>
224
<p>Returns the date and time when the file was last read (accessed).</p>
225
<p>On platforms where this information is not available, returns the same as <a href="qfileinfo.html#lastModified">lastModified</a>().</p>
226
<p>See also <a href="qfileinfo.html#created">created</a>() and <a href="qfileinfo.html#lastModified">lastModified</a>().</p>
227
<h3 class="fn"><a name="makeAbsolute"></a>bool QFileInfo::makeAbsolute ()</h3>
228
<p>Converts the file's path to an absolute path.</p>
229
<p>If it is already absolute, nothing is done.</p>
230
<p>See also <a href="qfileinfo.html#filePath">filePath</a>() and <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
231
<h3 class="fn"><a name="owner"></a><a href="qstring.html">QString</a> QFileInfo::owner () const</h3>
232
<p>Returns the owner of the file. On systems where files do not have owners, or if an error occurs, an empty string is returned.</p>
233
<p>This function can be time consuming under Unix (in the order of milliseconds).</p>
234
<p>See also <a href="qfileinfo.html#ownerId">ownerId</a>(), <a href="qfileinfo.html#group">group</a>(), and <a href="qfileinfo.html#groupId">groupId</a>().</p>
235
<h3 class="fn"><a name="ownerId"></a><a href="qtglobal.html#uint-typedef">uint</a> QFileInfo::ownerId () const</h3>
236
<p>Returns the id of the owner of the file.</p>
237
<p>On Windows and on systems where files do not have owners this function returns ((uint) -2).</p>
238
<p>See also <a href="qfileinfo.html#owner">owner</a>(), <a href="qfileinfo.html#group">group</a>(), and <a href="qfileinfo.html#groupId">groupId</a>().</p>
239
<h3 class="fn"><a name="path"></a><a href="qstring.html">QString</a> QFileInfo::path () const</h3>
240
<p>Returns the file's path.</p>
241
<p>See also <a href="qfileinfo.html#dir">dir</a>(), <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#isRelative">isRelative</a>(), and <a href="qfileinfo.html#absolutePath">absolutePath</a>().</p>
242
<h3 class="fn"><a name="permission"></a>bool QFileInfo::permission ( <a href="qfile.html#Permission-enum">QFile::Permissions</a> <i>permissions</i> ) const</h3>
243
<p>Tests for file permissions. The <i>permissions</i> argument can be several flags of type <tt>QFile::Permissions</tt> OR-ed together to check for permission combinations.</p>
244
<p>On systems where files do not have permissions this function always returns true.</p>
246
<pre> QFileInfo fi("/tmp/archive.tar.gz");
247
if (fi.permission(QFile::WriteUser | QFile::ReadGroup))
248
qWarning("I can change the file; my group can read the file");
249
if (fi.permission(QFile::WriteGroup | QFile::WriteOther))
250
qWarning("The group or others can change the file");</pre>
251
<p>See also <a href="qfileinfo.html#isReadable">isReadable</a>(), <a href="qfileinfo.html#isWritable">isWritable</a>(), and <a href="qfileinfo.html#isExecutable">isExecutable</a>().</p>
252
<h3 class="fn"><a name="permissions"></a><a href="qfile.html#Permission-enum">QFile::Permissions</a> QFileInfo::permissions () const</h3>
253
<p>Returns the complete OR-ed together combination of <a href="qfile.html#Permission-enum">QFile::Permissions</a> for the file.</p>
254
<h3 class="fn"><a name="readLink"></a><a href="qstring.html">QString</a> QFileInfo::readLink () const</h3>
255
<p>Returns the name a symlink (or shortcut on Windows) points to, or a an empty string if the object isn't a symbolic link.</p>
256
<p>This name may not represent an existing file; it is only a string. <a href="qfileinfo.html#exists">QFileInfo::exists</a>() returns true if the symlink points to an existing file.</p>
257
<p>See also <a href="qfileinfo.html#exists">exists</a>(), <a href="qfileinfo.html#isSymLink">isSymLink</a>(), <a href="qfileinfo.html#isDir">isDir</a>(), and <a href="qfileinfo.html#isFile">isFile</a>().</p>
258
<h3 class="fn"><a name="refresh"></a>void QFileInfo::refresh ()</h3>
259
<p>Refreshes the information about the file, i.e. reads in information from the file system the next time a cached property is fetched.</p>
260
<h3 class="fn"><a name="setCaching"></a>void QFileInfo::setCaching ( bool <i>enable</i> )</h3>
261
<p>If <i>enable</i> is true, enables caching of file information. If <i>enable</i> is false caching is disabled.</p>
262
<p>When caching is enabled, <a href="qfileinfo.html">QFileInfo</a> reads the file information from the file system the first time it's needed, but generally not later.</p>
263
<p>Caching is enabled by default.</p>
264
<p>See also <a href="qfileinfo.html#refresh">refresh</a>() and <a href="qfileinfo.html#caching">caching</a>().</p>
265
<h3 class="fn"><a name="setFile"></a>void QFileInfo::setFile ( const <a href="qstring.html">QString</a> & <i>file</i> )</h3>
266
<p>Sets the file that the <a href="qfileinfo.html">QFileInfo</a> provides information about to <i>file</i>.</p>
267
<p>The <i>file</i> can also include an absolute or relative file path. Absolute paths begin with the directory separator (e.g. "/" under Unix) or 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.</p>
269
<pre> QString absolute = "/local/bin";
270
QString relative = "local/bin";
271
QFileInfo absFile(absolute);
272
QFileInfo relFile(relative);
274
QDir::setCurrent(QDir::rootPath());
275
// absFile and relFile now point to the same file
277
QDir::setCurrent("/tmp");
278
// absFile now points to "/local/bin",
279
// while relFile points to "/tmp/local/bin"</pre>
280
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>(), <a href="qdir.html#setCurrent">QDir::setCurrent</a>(), and <a href="qdir.html#isRelativePath">QDir::isRelativePath</a>().</p>
281
<h3 class="fn"><a name="setFile-2"></a>void QFileInfo::setFile ( const <a href="qfile.html">QFile</a> & <i>file</i> )</h3>
282
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
283
<p>Sets the file that the <a href="qfileinfo.html">QFileInfo</a> provides information about to <i>file</i>.</p>
284
<p>If <i>file</i> includes a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
285
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
286
<h3 class="fn"><a name="setFile-3"></a>void QFileInfo::setFile ( const <a href="qdir.html">QDir</a> & <i>dir</i>, const <a href="qstring.html">QString</a> & <i>file</i> )</h3>
287
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
288
<p>Sets the file that the <a href="qfileinfo.html">QFileInfo</a> provides information about to <i>file</i> in directory <i>dir</i>.</p>
289
<p>If <i>file</i> includes a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
290
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
291
<h3 class="fn"><a name="size"></a><a href="qtglobal.html#qint64-typedef">qint64</a> QFileInfo::size () const</h3>
292
<p>Returns the file size in bytes, or 0 if the file does not exist or if the size is 0 or if the size cannot be fetched.</p>
293
<h3 class="fn"><a name="suffix"></a><a href="qstring.html">QString</a> QFileInfo::suffix () const</h3>
294
<p>Returns the suffix of the file.</p>
295
<p>The suffix consists of all characters in the file after (but not including) the last '.'.</p>
297
<pre> QFileInfo fi("/tmp/archive.tar.gz");
298
QString ext = fi.suffix(); // ext = "gz"</pre>
299
<p>See also <a href="qfileinfo.html#fileName">fileName</a>(), <a href="qfileinfo.html#completeSuffix">completeSuffix</a>(), <a href="qfileinfo.html#baseName">baseName</a>(), and <a href="qfileinfo.html#completeBaseName">completeBaseName</a>().</p>
300
<h3 class="fn"><a name="operator-not-eq"></a>bool QFileInfo::operator!= ( const QFileInfo & <i>fileinfo</i> )</h3>
301
<p>Returns true if the <a href="qfileinfo.html">QFileInfo</a> refers to a different file to the one specified by <i>fileinfo</i>; otherwise returns false.</p>
302
<p>See also <a href="qfileinfo.html#operator-eq-eq">operator==</a>().</p>
303
<h3 class="fn"><a name="operator-eq"></a>QFileInfo & QFileInfo::operator= ( const QFileInfo & <i>fileinfo</i> )</h3>
304
<p>Makes a copy of the given <i>fileinfo</i> and assigns it to this <a href="qfileinfo.html">QFileInfo</a>.</p>
305
<h3 class="fn"><a name="operator-eq-eq"></a>bool QFileInfo::operator== ( const QFileInfo & <i>fileinfo</i> )</h3>
306
<p>Returns true if the <a href="qfileinfo.html">QFileInfo</a> refers to a file in the same location as the other <i>fileinfo</i>; otherwise returns false.</p>
307
<p><b>Warning:</b> This will not compare two different symbolic links pointing to the same file.</p>
308
<p>See also <a href="qfileinfo.html#operator-not-eq">operator!=</a>().</p>
309
<p /><address><hr /><div align="center">
310
<table width="100%" cellspacing="0" border="0"><tr class="address">
311
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
312
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
313
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
314
</tr></table></div></address></body>