1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QFileInfo Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QFileInfo Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QFileInfo class provides system-independent file information. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qfileinfo.html#QFileInfo">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qfileinfo.html#QFileInfo-2">__init__</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qfileinfo.html#QFileInfo-3">__init__</a></b> (<i>self</i>, QFile)</li><li><div class="fn" /><b><a href="qfileinfo.html#QFileInfo-4">__init__</a></b> (<i>self</i>, QDir, QString)</li><li><div class="fn" /><b><a href="qfileinfo.html#QFileInfo-5">__init__</a></b> (<i>self</i>, QFileInfo)</li><li><div class="fn" />QDir <b><a href="qfileinfo.html#absoluteDir">absoluteDir</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#absolutePath">absolutePath</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#baseName">baseName</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#bundleName">bundleName</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#caching">caching</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#canonicalFilePath">canonicalFilePath</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#canonicalPath">canonicalPath</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#completeBaseName">completeBaseName</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#completeSuffix">completeSuffix</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qfileinfo.html#created">created</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qfileinfo.html#detach">detach</a></b> (<i>self</i>)</li><li><div class="fn" />QDir <b><a href="qfileinfo.html#dir">dir</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#exists">exists</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#filePath">filePath</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#group">group</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfileinfo.html#groupId">groupId</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isAbsolute">isAbsolute</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isBundle">isBundle</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isDir">isDir</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isExecutable">isExecutable</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isFile">isFile</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isHidden">isHidden</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isReadable">isReadable</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isRelative">isRelative</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isRoot">isRoot</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isSymLink">isSymLink</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#isWritable">isWritable</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qfileinfo.html#lastModified">lastModified</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qfileinfo.html#lastRead">lastRead</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#makeAbsolute">makeAbsolute</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#owner">owner</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfileinfo.html#ownerId">ownerId</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#path">path</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#permission">permission</a></b> (<i>self</i>, QFile.Permissions)</li><li><div class="fn" />QFile.Permissions <b><a href="qfileinfo.html#permissions">permissions</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#readLink">readLink</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qfileinfo.html#refresh">refresh</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qfileinfo.html#setCaching">setCaching</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qfileinfo.html#setFile">setFile</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qfileinfo.html#setFile-2">setFile</a></b> (<i>self</i>, QFile)</li><li><div class="fn" /><b><a href="qfileinfo.html#setFile-3">setFile</a></b> (<i>self</i>, QDir, QString)</li><li><div class="fn" />int <b><a href="qfileinfo.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#suffix">suffix</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qfileinfo.html#symLinkTarget">symLinkTarget</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qfileinfo.html#__eq__">__eq__</a></b> (<i>self</i>, QFileInfo)</li><li><div class="fn" />bool <b><a href="qfileinfo.html#__ne__">__ne__</a></b> (<i>self</i>, QFileInfo)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QFileInfo class provides system-independent file information.</p>
<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 obtain information about a Qt <a href="resources.html#resource-system">resource</a>.</p>
<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>
<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>
<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#symLinkTarget">symLinkTarget</a>() function provides the name of the file the symlink points to.</p>
<p>On Unix (including Mac OS X), the symlink has the same <a href="qfileinfo.html#size">size</a>() has the file it points to, because Unix handles symlinks transparently; similarly, opening a symlink using <a href="qfile.html">QFile</a> effectively opens the link's target. For example:</p>
<pre> #ifdef Q_OS_UNIX
QFileInfo info1("/home/bob/bin/untabify");
info1.isSymLink(); <span class="comment">// returns true</span>
info1.absoluteFilePath(); <span class="comment">// returns "/home/bob/bin/untabify"</span>
info1.size(); <span class="comment">// returns 56201</span>
info1.symLinkTarget(); <span class="comment">// returns "/opt/pretty++/bin/untabify"</span>
QFileInfo info2(info1.symLinkTarget());
info2.isSymLink(); <span class="comment">// returns false</span>
info2.absoluteFilePath(); <span class="comment">// returns "/opt/pretty++/bin/untabify"</span>
info2.size(); <span class="comment">// returns 56201</span>
#endif</pre>
<p>On Windows, symlinks (shortcuts) are <tt>.lnk</tt> files. The reported <a href="qfileinfo.html#size">size</a>() is that of the symlink (not the link's target), and opening a symlink using <a href="qfile.html">QFile</a> opens the <tt>.lnk</tt> file. For example:</p>
<pre> #ifdef Q_OS_WIN
QFileInfo info1("C:\\Documents and Settings\\Bob\\untabify.lnk");
info1.isSymLink(); <span class="comment">// returns true</span>
info1.absoluteFilePath(); <span class="comment">// returns "C:/Documents and Settings/Bob/untabify.lnk"</span>
info1.size(); <span class="comment">// returns 743</span>
info1.symLinkTarget(); <span class="comment">// returns "C:/Pretty++/untabify"</span>
QFileInfo info2(info1.symLinkTarget());
info2.isSymLink(); <span class="comment">// returns false</span>
info2.absoluteFilePath(); <span class="comment">// returns "C:/Pretty++/untabify"</span>
info2.size(); <span class="comment">// returns 63942</span>
#endif</pre>
<p>Elements of the file's name can be extracted with <a href="qfileinfo.html#pathx">path</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>(), <a href="qfileinfo.html#suffix">suffix</a>() or <a href="qfileinfo.html#completeSuffix">completeSuffix</a>(). QFileInfo objects to directories created by Qt classes will not have a trailing file separator. If you wish to use trailing separators in your own file info objects, just append one to the file name given to the constructors or <a href="qfileinfo.html#setFile">setFile</a>().</p>
<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>
<a name="performance-issues" />
<h3>Performance Issues</h3>
<p>Some of QFileInfo's functions query the file system, but for performance reasons, some functions only operate on the file name itself. For example: To return the absolute path of a relative file name, <a href="qfileinfo.html#absolutePath">absolutePath</a>() has to query the file system. The <a href="qfileinfo.html#pathx">path</a>() function, however, can work on the file name directly, and so it is faster.</p>
<p><b>Note:</b> To speed up performance, QFileInfo caches information about the file.</p>
<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>
<p>See also <a href="qdir.html">QDir</a> and <a href="qfile.html">QFile</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QFileInfo" />QFileInfo.__init__ (<i>self</i>)</h3><p>Constructs an empty <a href="qfileinfo.html">QFileInfo</a> object.</p>
<p>Note that an empty <a href="qfileinfo.html">QFileInfo</a> object contain no file reference.</p>
<p>See also <a href="qfileinfo.html#setFile">setFile</a>().</p>
<h3 class="fn"><a name="QFileInfo-2" />QFileInfo.__init__ (<i>self</i>, QString)</h3><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>
<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>
<h3 class="fn"><a name="QFileInfo-3" />QFileInfo.__init__ (<i>self</i>, <a href="qfile.html">QFile</a>)</h3><p>Constructs a new <a href="qfileinfo.html">QFileInfo</a> that gives information about file <i>file</i>.</p>
<p>If the <i>file</i> has a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<h3 class="fn"><a name="QFileInfo-4" />QFileInfo.__init__ (<i>self</i>, <a href="qdir.html">QDir</a>, QString)</h3><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>
<p>If <i>dir</i> has a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
<p>If <i>file</i> is an absolute path, then the directory specified by <i>dir</i> will be disregarded.</p>
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<h3 class="fn"><a name="QFileInfo-5" />QFileInfo.__init__ (<i>self</i>, <a href="qfileinfo.html">QFileInfo</a>)</h3><p>Constructs a new <a href="qfileinfo.html">QFileInfo</a> that is a copy of the given <i>fileinfo</i>.</p>
<a name="//apple_ref/cpp/instm/QFileInfo/~QFileInfo" />
<h3 class="fn"><a name="absoluteDir" /><a href="qdir.html">QDir</a> QFileInfo.absoluteDir (<i>self</i>)</h3><p>Returns the file's absolute path as a <a href="qdir.html">QDir</a> object.</p>
<p>See also <a href="qfileinfo.html#dir">dir</a>(), <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#fileName">fileName</a>(), and <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/absoluteFilePath" />
<h3 class="fn"><a name="absoluteFilePath" />QString QFileInfo.absoluteFilePath (<i>self</i>)</h3><p>Returns an absolute path including the file name.</p>
<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/'. <a href="qfileinfo.html">QFileInfo</a> will uppercase drive letters. Note that <a href="qdir.html">QDir</a> does not do this. The code snippet below shows this.</p>
<pre> QFileInfo fi("c:/temp/foo"); => fi.absoluteFilePath() => "C:/temp/foo"</pre>
<p>This function returns the same as <a href="qfileinfo.html#filePath">filePath</a>(), unless <a href="qfileinfo.html#isRelative">isRelative</a>() is true. In contrast to <a href="qfileinfo.html#canonicalFilePath">canonicalFilePath</a>(), symbolic links or redundant "." or ".." elements are not necessarily removed.</p>
<p>If the <a href="qfileinfo.html">QFileInfo</a> is empty it returns <a href="qdir.html#currentPath">QDir.currentPath</a>().</p>
<p>See also <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#canonicalFilePath">canonicalFilePath</a>(), and <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/absolutePath" />
<h3 class="fn"><a name="absolutePath" />QString QFileInfo.absolutePath (<i>self</i>)</h3><p>Returns a file's path absolute path. This doesn't include the file name.</p>
<p>On Unix the absolute path 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>
<p>In contrast to <a href="qfileinfo.html#canonicalPath">canonicalPath</a>() symbolic links or redundant "." or ".." elements are not necessarily removed.</p>
<p><b>Warning:</b> If the <a href="qfileinfo.html">QFileInfo</a> object was created with an empty <a href="qstring.html">QString</a>, the behavior of this function is undefined.</p>
<p>See also <a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qfileinfo.html#pathx">path</a>(), <a href="qfileinfo.html#canonicalPath">canonicalPath</a>(), <a href="qfileinfo.html#fileName">fileName</a>(), and <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/baseName" />
<h3 class="fn"><a name="baseName" />QString QFileInfo.baseName (<i>self</i>)</h3><p>Returns the base name of the file without the path.</p>
<p>The base name consists of all characters in the file up to (but not including) the <i>first</i> '.' character.</p>
<p>Example:</p>
<pre> QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.baseName(); <span class="comment">// base = "archive"</span></pre>
<p>The base name of a file is computed equally on all platforms, independent of file naming conventions (e.g., ".bashrc" on Unix has an empty base name, and the suffix is "bashrc").</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/bundleName" />
<h3 class="fn"><a name="bundleName" />QString QFileInfo.bundleName (<i>self</i>)</h3><p>Returns the name of the bundle.</p>
<p>On Mac OS X this returns the proper localized name for a bundle if the path <a href="qfileinfo.html#isBundle">isBundle</a>(). On all other platforms an empty <a href="qstring.html">QString</a> is returned.</p>
<p>Example:</p>
<pre> QFileInfo fi("/Applications/Safari.app");
QString bundle = fi.bundleName(); <span class="comment">// name = "Safari"</span></pre>
<p>This function was introduced in Qt 4.3.</p>
<p>See also <a href="qfileinfo.html#isBundle">isBundle</a>(), <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#baseName">baseName</a>(), and <a class="compat" href="qfileinfo-qt3.html#extension">extension</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/caching" />
<h3 class="fn"><a name="caching" />bool QFileInfo.caching (<i>self</i>)</h3><p>Returns true if caching is enabled; otherwise returns false.</p>
<p>See also <a href="qfileinfo.html#setCaching">setCaching</a>() and <a href="qfileinfo.html#refresh">refresh</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/canonicalFilePath" />
<h3 class="fn"><a name="canonicalFilePath" />QString QFileInfo.canonicalFilePath (<i>self</i>)</h3><p>Returns the canonical path including the file name, i.e. an absolute path without symbolic links or redundant "." or ".." elements.</p>
<p>If the file does not exist, canonicalFilePath() returns an empty string.</p>
<p>See also <a href="qfileinfo.html#filePath">filePath</a>(), <a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a>(), and <a href="qfileinfo.html#dir">dir</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/canonicalPath" />
<h3 class="fn"><a name="canonicalPath" />QString QFileInfo.canonicalPath (<i>self</i>)</h3><p>Returns the file's path canonical path (excluding the file name), i.e. an absolute path without symbolic links or redundant "." or ".." elements.</p>
<p>If the file does not exist, canonicalPath() returns an empty string.</p>
<p>See also <a href="qfileinfo.html#pathx">path</a>() and <a href="qfileinfo.html#absolutePath">absolutePath</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/completeBaseName" />
<h3 class="fn"><a name="completeBaseName" />QString QFileInfo.completeBaseName (<i>self</i>)</h3><p>Returns the complete base name of the file without the path.</p>
<p>The complete base name consists of all characters in the file up to (but not including) the <i>last</i> '.' character.</p>
<p>Example:</p>
<pre> QFileInfo fi("/tmp/archive.tar.gz");
QString base = fi.completeBaseName(); <span class="comment">// base = "archive.tar"</span></pre>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/completeSuffix" />
<h3 class="fn"><a name="completeSuffix" />QString QFileInfo.completeSuffix (<i>self</i>)</h3><p>Returns the complete suffix of the file.</p>
<p>The complete suffix consists of all characters in the file after (but not including) the first '.'.</p>
<p>Example:</p>
<pre> QFileInfo fi("/tmp/archive.tar.gz");
QString ext = fi.completeSuffix(); <span class="comment">// ext = "tar.gz"</span></pre>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/created" />
<h3 class="fn"><a name="created" /><a href="qdatetime.html">QDateTime</a> QFileInfo.created (<i>self</i>)</h3><p>Returns the date and time when the file was created.</p>
<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>
<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>
<p>See also <a href="qfileinfo.html#lastModified">lastModified</a>() and <a href="qfileinfo.html#lastRead">lastRead</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/dir" />
<h3 class="fn"><a name="detach" />QFileInfo.detach (<i>self</i>)</h3><h3 class="fn"><a name="dir" /><a href="qdir.html">QDir</a> QFileInfo.dir (<i>self</i>)</h3><p>Returns the path of the object's parent directory as a <a href="qdir.html">QDir</a> object.</p>
<p><b>Note:</b> The <a href="qdir.html">QDir</a> returned always corresponds to the object's parent directory, even if the <a href="qfileinfo.html">QFileInfo</a> represents a directory.</p>
<p>For each of the follwing, dir() returns a <a href="qdir.html">QDir</a> for <tt>"~/examples/191697"</tt>.</p>
<pre> QFileInfo fileInfo1("~/examples/191697/.");
QFileInfo fileInfo2("~/examples/191697/..");
QFileInfo fileInfo3("~/examples/191697/main.cpp");</pre>
<p>For each of the follwing, dir() returns a <a href="qdir.html">QDir</a> for <tt>"."</tt>.</p>
<pre> QFileInfo fileInfo4(".");
QFileInfo fileInfo5("..");
QFileInfo fileInfo6("main.cpp");</pre>
<p>See also <a href="qfileinfo.html#absolutePath">absolutePath</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>
<a name="//apple_ref/cpp/instm/QFileInfo/exists" />
<h3 class="fn"><a name="exists" />bool QFileInfo.exists (<i>self</i>)</h3><p>Returns true if the file exists; otherwise returns false.</p>
<p><b>Note:</b> If the file is a symlink that points to a non existing file, false is returned.</p>
<a name="//apple_ref/cpp/instm/QFileInfo/fileName" />
<h3 class="fn"><a name="fileName" />QString QFileInfo.fileName (<i>self</i>)</h3><p>Returns the name of the file, excluding the path.</p>
<p>Example:</p>
<pre> QFileInfo fi("/tmp/archive.tar.gz");
QString name = fi.fileName(); <span class="comment">// name = "archive.tar.gz"</span></pre>
<p>Note that, if this <a href="qfileinfo.html">QFileInfo</a> object is given a path ending in a slash, the name of the file is considered empty.</p>
<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 class="compat" href="qfileinfo-qt3.html#extension">extension</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/filePath" />
<h3 class="fn"><a name="filePath" />QString QFileInfo.filePath (<i>self</i>)</h3><p>Returns the file name, including the path (which may be absolute or relative).</p>
<p>See also <a href="qfileinfo.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qfileinfo.html#canonicalFilePath">canonicalFilePath</a>(), and <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/group" />
<h3 class="fn"><a name="group" />QString QFileInfo.group (<i>self</i>)</h3><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>
<p>This function can be time consuming under Unix (in the order of milliseconds).</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/groupId" />
<h3 class="fn"><a name="groupId" />int QFileInfo.groupId (<i>self</i>)</h3><p>Returns the id of the group the file belongs to.</p>
<p>On Windows and on systems where files do not have groups this function always returns (uint) -2.</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/isAbsolute" />
<h3 class="fn"><a name="isAbsolute" />bool QFileInfo.isAbsolute (<i>self</i>)</h3><p>Returns true if the file path name is absolute, otherwise returns false if the path is relative.</p>
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isBundle" />
<h3 class="fn"><a name="isBundle" />bool QFileInfo.isBundle (<i>self</i>)</h3><p>Returns true if this object points to a bundle or to a symbolic link to a bundle on Mac OS X; otherwise returns false.</p>
<p>This function was introduced in Qt 4.3.</p>
<p>See also <a href="qfileinfo.html#isDir">isDir</a>(), <a href="qfileinfo.html#isSymLink">isSymLink</a>(), and <a href="qfileinfo.html#isFile">isFile</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isDir" />
<h3 class="fn"><a name="isDir" />bool QFileInfo.isDir (<i>self</i>)</h3><p>Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false.</p>
<p>See also <a href="qfileinfo.html#isFile">isFile</a>(), <a href="qfileinfo.html#isSymLink">isSymLink</a>(), and <a href="qfileinfo.html#isBundle">isBundle</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isExecutable" />
<h3 class="fn"><a name="isExecutable" />bool QFileInfo.isExecutable (<i>self</i>)</h3><p>Returns true if the file is executable; otherwise returns false.</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/isFile" />
<h3 class="fn"><a name="isFile" />bool QFileInfo.isFile (<i>self</i>)</h3><p>Returns true if this object points to a file or to a symbolic link to a file. Returns false if the object points to something which isn't a file, such as a directory.</p>
<p>See also <a href="qfileinfo.html#isDir">isDir</a>(), <a href="qfileinfo.html#isSymLink">isSymLink</a>(), and <a href="qfileinfo.html#isBundle">isBundle</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isHidden" />
<h3 class="fn"><a name="isHidden" />bool QFileInfo.isHidden (<i>self</i>)</h3><p>Returns true if this is a `hidden' file; otherwise returns false.</p>
<p><b>Note:</b> This function returns true for the special entries "." and ".." on Unix, even though QDir.entryList threats them as shown.</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isReadable" />
<h3 class="fn"><a name="isReadable" />bool QFileInfo.isReadable (<i>self</i>)</h3><p>Returns true if the user can read the file; otherwise returns false.</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/isRelative" />
<h3 class="fn"><a name="isRelative" />bool QFileInfo.isRelative (<i>self</i>)</h3><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>
<p>See also <a href="qfileinfo.html#isAbsolute">isAbsolute</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isRoot" />
<h3 class="fn"><a name="isRoot" />bool QFileInfo.isRoot (<i>self</i>)</h3><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>
<a name="//apple_ref/cpp/instm/QFileInfo/isSymLink" />
<h3 class="fn"><a name="isSymLink" />bool QFileInfo.isSymLink (<i>self</i>)</h3><p>Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise returns false.</p>
<p>On Unix (including Mac OS X), opening a symlink effectively opens the <a href="qfileinfo.html#symLinkTarget">link's target</a>. On Windows, it opens the <tt>.lnk</tt> file itself.</p>
<p>Example:</p>
<pre> QFileInfo info(fileName);
if (info.isSymLink())
fileName = info.symLinkTarget();</pre>
<p><b>Note:</b> If the symlink points to a non existing file, <a href="qfileinfo.html#exists">exists</a>() returns false.</p>
<p>See also <a href="qfileinfo.html#isFile">isFile</a>(), <a href="qfileinfo.html#isDir">isDir</a>(), and <a href="qfileinfo.html#symLinkTarget">symLinkTarget</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/isWritable" />
<h3 class="fn"><a name="isWritable" />bool QFileInfo.isWritable (<i>self</i>)</h3><p>Returns true if the user can write to the file; otherwise returns false.</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/lastModified" />
<h3 class="fn"><a name="lastModified" /><a href="qdatetime.html">QDateTime</a> QFileInfo.lastModified (<i>self</i>)</h3><p>Returns the date and time when the file was last modified.</p>
<p>See also <a href="qfileinfo.html#created">created</a>() and <a href="qfileinfo.html#lastRead">lastRead</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/lastRead" />
<h3 class="fn"><a name="lastRead" /><a href="qdatetime.html">QDateTime</a> QFileInfo.lastRead (<i>self</i>)</h3><p>Returns the date and time when the file was last read (accessed).</p>
<p>On platforms where this information is not available, returns the same as <a href="qfileinfo.html#lastModified">lastModified</a>().</p>
<p>See also <a href="qfileinfo.html#created">created</a>() and <a href="qfileinfo.html#lastModified">lastModified</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/makeAbsolute" />
<h3 class="fn"><a name="makeAbsolute" />bool QFileInfo.makeAbsolute (<i>self</i>)</h3><p>Converts the file's path to an absolute path if it is not already in that form. Returns true to indicate that the path was converted; otherwise returns false to indicate that the path was already absolute.</p>
<p>See also <a href="qfileinfo.html#filePath">filePath</a>() and <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/owner" />
<h3 class="fn"><a name="owner" />QString QFileInfo.owner (<i>self</i>)</h3><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>
<p>This function can be time consuming under Unix (in the order of milliseconds).</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/ownerId" />
<h3 class="fn"><a name="ownerId" />int QFileInfo.ownerId (<i>self</i>)</h3><p>Returns the id of the owner of the file.</p>
<p>On Windows and on systems where files do not have owners this function returns ((uint) -2).</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/path" />
<h3 class="fn"><a name="path" />QString QFileInfo.path (<i>self</i>)</h3><h3 class="fn"><a name="permission" />bool QFileInfo.permission (<i>self</i>, <a href="qfile-permissions.html">QFile.Permissions</a>)</h3><p>Tests for file permissions. The <i>permissions</i> argument can be several flags of type <a href="qfile.html#Permission-enum">QFile.Permissions</a> OR-ed together to check for permission combinations.</p>
<p>On systems where files do not have permissions this function always returns true.</p>
<p>Example:</p>
<pre> QFileInfo fi("/tmp/archive.tar.gz");
if (fi.permission(QFile.WriteUser | QFile.ReadGroup))
qWarning("I can change the file; my group can read the file");
if (fi.permission(QFile.WriteGroup | QFile.WriteOther))
qWarning("The group or others can change the file");</pre>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/permissions" />
<h3 class="fn"><a name="permissions" /><a href="qfile-permissions.html">QFile.Permissions</a> QFileInfo.permissions (<i>self</i>)</h3><p>Returns the complete OR-ed together combination of <a href="qfile.html#Permission-enum">QFile.Permissions</a> for the file.</p>
<a name="//apple_ref/cpp/instm/QFileInfo/refresh" />
<h3 class="fn"><a name="readLink" />QString QFileInfo.readLink (<i>self</i>)</h3><h3 class="fn"><a name="refresh" />QFileInfo.refresh (<i>self</i>)</h3><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>
<p><b>Note:</b> On Windows CE, there might be a delay for the file system driver to detect changes on the file.</p>
<a name="//apple_ref/cpp/instm/QFileInfo/setCaching" />
<h3 class="fn"><a name="setCaching" />QFileInfo.setCaching (<i>self</i>, bool)</h3><p>If <i>enable</i> is true, enables caching of file information. If <i>enable</i> is false caching is disabled.</p>
<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>
<p>Caching is enabled by default.</p>
<p>See also <a href="qfileinfo.html#refresh">refresh</a>() and <a href="qfileinfo.html#caching">caching</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/setFile" />
<h3 class="fn"><a name="setFile" />QFileInfo.setFile (<i>self</i>, QString)</h3><p>Sets the file that the <a href="qfileinfo.html">QFileInfo</a> provides information about to <i>file</i>.</p>
<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>
<p>Example:</p>
<pre> QString absolute = "/local/bin";
QString relative = "local/bin";
QFileInfo absFile(absolute);
QFileInfo relFile(relative);
QDir.setCurrent(QDir.rootPath());
<span class="comment"> // absFile and relFile now point to the same file</span>
QDir.setCurrent("/tmp");
<span class="comment"> // absFile now points to "/local/bin",</span>
<span class="comment"> // while relFile points to "/tmp/local/bin"</span></pre>
<p>See also <a href="qfileinfo.html#isFile">isFile</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>
<h3 class="fn"><a name="setFile-2" />QFileInfo.setFile (<i>self</i>, <a href="qfile.html">QFile</a>)</h3><p>This is an overloaded function.</p>
<p>Sets the file that the <a href="qfileinfo.html">QFileInfo</a> provides information about to <i>file</i>.</p>
<p>If <i>file</i> includes a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<h3 class="fn"><a name="setFile-3" />QFileInfo.setFile (<i>self</i>, <a href="qdir.html">QDir</a>, QString)</h3><p>This is an overloaded function.</p>
<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>
<p>If <i>file</i> includes a relative path, the <a href="qfileinfo.html">QFileInfo</a> will also have a relative path.</p>
<p>See also <a href="qfileinfo.html#isRelative">isRelative</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/size" />
<h3 class="fn"><a name="size" />int QFileInfo.size (<i>self</i>)</h3><p>Returns the file size in bytes. If the file does not exist or cannot be fetched, 0 is returned.</p>
<p>See also <a href="qfileinfo.html#exists">exists</a>().</p>
<a name="//apple_ref/cpp/instm/QFileInfo/suffix" />
<h3 class="fn"><a name="suffix" />QString QFileInfo.suffix (<i>self</i>)</h3><p>Returns the suffix of the file.</p>
<p>The suffix consists of all characters in the file after (but not including) the last '.'.</p>
<p>Example:</p>
<pre> QFileInfo fi("/tmp/archive.tar.gz");
QString ext = fi.suffix(); <span class="comment">// ext = "gz"</span></pre>
<p>The suffix of a file is computed equally on all platforms, independent of file naming conventions (e.g., ".bashrc" on Unix has an empty base name, and the suffix is "bashrc").</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/symLinkTarget" />
<h3 class="fn"><a name="symLinkTarget" />QString QFileInfo.symLinkTarget (<i>self</i>)</h3><p>Returns the absolute path to the file or directory a symlink (or shortcut on Windows) points to, or a an empty string if the object isn't a symbolic link.</p>
<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>
<p>This function was introduced in Qt 4.2.</p>
<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>
<a name="//apple_ref/cpp/instm/QFileInfo/operator!=" />
<h3 class="fn"><a name="__eq__" />bool QFileInfo.__eq__ (<i>self</i>, <a href="qfileinfo.html">QFileInfo</a>)</h3><h3 class="fn"><a name="__ne__" />bool QFileInfo.__ne__ (<i>self</i>, <a href="qfileinfo.html">QFileInfo</a>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.2</td></tr></table></div></address></body></html>
|