📄 qfileinfo.html
字号:
<p>Example: <a href="fileiconview-example.html#x818">fileiconview/qfileiconview.cpp</a>.<h3 class=fn>bool <a name="exists"></a>QFileInfo::exists () const</h3>Returns TRUE if the file exists; otherwise returns FALSE.<p>Examples: <a href="biff-example.html#x1941">biff/biff.cpp</a> and <a href="i18n-example.html#x1926">i18n/main.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="extension"></a>QFileInfo::extension ( bool complete = TRUE ) const</h3>Returns the file's extension name.<p> If <em>complete</em> is TRUE (the default), <a href="#extension">extension</a>() returns the stringof all characters in the file name after (but not including) thefirst '.' character.<p> If <em>complete</em> is FALSE, extension() returns the string of allcharacters in the file name after (but not including) the last '.'character.<p> Example:<pre> QFileInfo fi( "/tmp/archive.tar.gz" ); <a href="qstring.html">QString</a> ext = fi.<a href="#extension">extension</a>(); // ext = "tar.gz" ext = fi.<a href="#extension">extension</a>( FALSE ); // ext = "gz" </pre> <p> <p>See also <a href="#fileName">fileName</a>() and <a href="#baseName">baseName</a>().<p> <p>Example: <a href="qdir-example.html#x1816">qdir/qdir.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="fileName"></a>QFileInfo::fileName () const</h3>Returns the name of the file, the file path is not included.<p> Example:<pre> QFileInfo fi( "/tmp/archive.tar.gz" ); <a href="qstring.html">QString</a> name = fi.<a href="#fileName">fileName</a>(); // name = "archive.tar.gz" </pre> <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>().<p>Examples: <a href="dirview-example.html#x1715">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x819">fileiconview/qfileiconview.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="filePath"></a>QFileInfo::filePath () const</h3>Returns the file name, including the path (which may be absolute orrelative).<p> <p>See also <a href="#isRelative">isRelative</a>() and <a href="#absFilePath">absFilePath</a>().<p>Examples: <a href="dirview-example.html#x1751">dirview/main.cpp</a> and <a href="fileiconview-example.html#x820">fileiconview/qfileiconview.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="group"></a>QFileInfo::group () const</h3>Returns the group of the file. On Windows, on systems where files donot have groups, or if an error occurs, a null string is returned. <p> This function can be time consuming under Unix (in the order ofmilliseconds).<p> <p>See also <a href="#groupId">groupId</a>(), <a href="#owner">owner</a>() and <a href="#ownerId">ownerId</a>().<h3 class=fn>uint <a name="groupId"></a>QFileInfo::groupId () const</h3>Returns the id of the group the file belongs to.<p> On Windows and on systems where files do not have groups this functionalways returns (uint) -2.<p> <p>See also <a href="#group">group</a>(), <a href="#owner">owner</a>() and <a href="#ownerId">ownerId</a>().<h3 class=fn>bool <a name="isDir"></a>QFileInfo::isDir () const</h3>Returns TRUE if this object points to a directory or to a symboliclink to a directory; otherwise returns FALSE.<p>See also <a href="#isFile">isFile</a>() and <a href="#isSymLink">isSymLink</a>().<p>Examples: <a href="dirview-example.html#x1716">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x821">fileiconview/qfileiconview.cpp</a>.<h3 class=fn>bool <a name="isExecutable"></a>QFileInfo::isExecutable () const</h3>Returns TRUE if the file is executable; otherwise returns FALSE.<p>See also <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and <a href="#permission">permission</a>().<h3 class=fn>bool <a name="isFile"></a>QFileInfo::isFile () const</h3>Returns TRUE if this object points to a file. Returns FALSE if theobject points to something which isn't a file, e.g. a directory or asymlink.<p> <p>See also <a href="#isDir">isDir</a>() and <a href="#isSymLink">isSymLink</a>().<p>Examples: <a href="dirview-example.html#x1717">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x822">fileiconview/qfileiconview.cpp</a> and <a href="qdir-example.html#x1817">qdir/qdir.cpp</a>.<h3 class=fn>bool <a name="isReadable"></a>QFileInfo::isReadable () const</h3>Returns TRUE if the file is readable; otherwise returns FALSE.<p>See also <a href="#isWritable">isWritable</a>(), <a href="#isExecutable">isExecutable</a>() and <a href="#permission">permission</a>().<h3 class=fn>bool <a name="isRelative"></a>QFileInfo::isRelative () const</h3>Returns TRUE if the file path name is relative. Returns FALSE if thepath is absolute (e.g. under Unix a path is absolute if itbegins with a "/").<h3 class=fn>bool <a name="isSymLink"></a>QFileInfo::isSymLink () const</h3>Returns TRUE if this object points to a symbolic link (or to ashortcut on Windows); otherwise returns FALSE. <p> <p>See also <a href="#isFile">isFile</a>(), <a href="#isDir">isDir</a>() and <a href="#readLink">readLink</a>().<p>Examples: <a href="dirview-example.html#x1718">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x823">fileiconview/qfileiconview.cpp</a>.<h3 class=fn>bool <a name="isWritable"></a>QFileInfo::isWritable () const</h3>Returns TRUE if the file is writable; otherwise returns FALSE.<p>See also <a href="#isReadable">isReadable</a>(), <a href="#isExecutable">isExecutable</a>() and <a href="#permission">permission</a>().<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="lastModified"></a>QFileInfo::lastModified () const</h3>Returns the date and time when the file was last modified.<p> <p>See also <a href="#created">created</a>() and <a href="#lastRead">lastRead</a>().<p>Example: <a href="biff-example.html#x1942">biff/biff.cpp</a>.<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="lastRead"></a>QFileInfo::lastRead () const</h3>Returns the date and time when the file was last read (accessed).<p> On platforms where this information is not available, returns thesame as <a href="#lastModified">lastModified</a>().<p> <p>See also <a href="#created">created</a>() and <a href="#lastModified">lastModified</a>().<p>Example: <a href="biff-example.html#x1943">biff/biff.cpp</a>.<h3 class=fn><a href="qfileinfo.html">QFileInfo</a> & <a name="operator-eq"></a>QFileInfo::operator= ( const <a href="qfileinfo.html">QFileInfo</a> & fi )</h3>Makes a copy of <em>fi</em> and assigns it to this QFileInfo.<h3 class=fn><a href="qstring.html">QString</a> <a name="owner"></a>QFileInfo::owner () const</h3>Returns the owner of the file. On Windows, on systems where files donot have owners, or if an error occurs, a null string is returned. <p> This function can be time consuming under Unix (in the order ofmilliseconds).<p> <p>See also <a href="#ownerId">ownerId</a>(), <a href="#group">group</a>() and <a href="#groupId">groupId</a>().<h3 class=fn>uint <a name="ownerId"></a>QFileInfo::ownerId () const</h3>Returns the id of the owner of the file.<p> On Windows and on systems where files do not have owners this functionreturns ((uint) -2).<p> <p>See also <a href="#owner">owner</a>(), <a href="#group">group</a>() and <a href="#groupId">groupId</a>().<h3 class=fn>bool <a name="permission"></a>QFileInfo::permission ( int permissionSpec ) const</h3><p> Tests for file permissions. The <em>permissionSpec</em> argument can be severalflags of type PermissionSpec OR-ed together to check for permissioncombinations.<p> On systems where files do not have permissions this function alwaysreturns TRUE.<p> Example:<pre> QFileInfo fi( "/tmp/archive.tar.gz" ); if ( fi.<a href="#permission">permission</a>( QFileInfo::<a href="#PermissionSpec-enum">WriteUser</a> | QFileInfo::<a href="#PermissionSpec-enum">ReadGroup</a> ) ) <a href="qapplication.html#qWarning">qWarning</a>( "I can change the file; my group can read the file."); if ( fi.<a href="#permission">permission</a>( QFileInfo::<a href="#PermissionSpec-enum">WriteGroup</a> | QFileInfo::<a href="#PermissionSpec-enum">WriteOther</a> ) ) <a href="qapplication.html#qWarning">qWarning</a>( "The group or others can change the file!" ); </pre> <p> <p>See also <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and <a href="#isExecutable">isExecutable</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="readLink"></a>QFileInfo::readLink () const</h3>Returns the name a symlink (or shortcut on Windows) points to, or anull <a href="qstring.html">QString</a> if the object isn't a symbolic link.<p> This name may not represent an existing file; it is only a string.<a href="#exists">QFileInfo::exists</a>() returns TRUE if the symlink points to anexisting file.<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>().<h3 class=fn>void <a name="refresh"></a>QFileInfo::refresh () const</h3>Refreshes the information about the file, i.e. reads in informationfrom the file system the next time a cached property is fetched.<p> <p>See also <a href="#setCaching">setCaching</a>().<h3 class=fn>void <a name="setCaching"></a>QFileInfo::setCaching ( bool enable )</h3>If <em>enable</em> is TRUE, enables caching of file information. If <em>enable</em> is FALSE caching is disabled.<p> When caching is enabled, QFileInfo reads the file information from thefile system the first time it's needed, but generally not later.<p> Caching is enabled by default.<p> <p>See also <a href="#refresh">refresh</a>() and <a href="#caching">caching</a>().<h3 class=fn>void <a name="setFile"></a>QFileInfo::setFile ( const <a href="qstring.html">QString</a> & file )</h3>Sets the file that the QFileInfo provides information about to <em>file</em>.<p> The string given can be an absolute or a relative file path. Absolutepaths begin with the directory separator (e.g. "/" under Unix) or a drivespecification (not applicable to Unix). Relative file names begin with adirectory name or a file name and specify a path relative to the currentdirectory.<p> Example:<pre> <a href="qstring.html">QString</a> absolute = "/local/bin"; <a href="qstring.html">QString</a> relative = "local/bin"; QFileInfo absFile( absolute ); QFileInfo relFile( relative ); QDir::<a href="qdir.html#setCurrent">setCurrent</a>( QDir::<a href="qdir.html#rootDirPath">rootDirPath</a>() ); // absFile and relFile now point to the same file QDir::<a href="qdir.html#setCurrent">setCurrent</a>( "/tmp" ); // absFile now points to "/local/bin", // while relFile points to "/tmp/local/bin" </pre> <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>().<p>Example: <a href="biff-example.html#x1944">biff/biff.cpp</a>.<h3 class=fn>void <a name="setFile-2"></a>QFileInfo::setFile ( const <a href="qfile.html">QFile</a> & file )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Sets the file that the QFileInfo provides information about to <em>file</em>.<p> If the file has a relative path, the QFileInfo will also have arelative path.<p> <p>See also <a href="#isRelative">isRelative</a>().<h3 class=fn>void <a name="setFile-3"></a>QFileInfo::setFile ( const <a href="qdir.html">QDir</a> & d, const <a href="qstring.html">QString</a> & fileName )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Sets the file that the QFileInfo provides information about to <em>fileName</em> in directory <em>d</em>.<p> If the file has a relative path, the QFileInfo will also have arelative path.<p> <p>See also <a href="#isRelative">isRelative</a>().<h3 class=fn>uint <a name="size"></a>QFileInfo::size () const</h3>Returns the file size in bytes, or 0 if the file does not exist or ifthe size is 0 or if the size cannot be fetched.<p>Example: <a href="qdir-example.html#x1818">qdir/qdir.cpp</a>.<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright © 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright © 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -