⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qfileinfo.html

📁 QT 下载资料仅供参考
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/tools/qfileinfo.cpp:48 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QFileInfo Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><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><p>The QFileInfo class provides system-independent file information.<a href="#details">More...</a><p><tt>#include &lt;<a href="qfileinfo-h.html">qfileinfo.h</a>&gt;</tt><p><a href="qfileinfo-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn>enum <a href="#PermissionSpec-enum"><b>PermissionSpec</b></a> { ReadUser = 0400, WriteUser = 0200, ExeUser = 0100, ReadGroup = 0040, WriteGroup = 0020, ExeGroup = 0010, ReadOther = 0004, WriteOther = 0002, ExeOther = 0001 }</div></li><li><div class=fn><a href="#QFileInfo"><b>QFileInfo</b></a> ()</div></li><li><div class=fn><a href="#QFileInfo-2"><b>QFileInfo</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file )</div></li><li><div class=fn><a href="#QFileInfo-3"><b>QFileInfo</b></a> ( const&nbsp;QFile&nbsp;&amp;&nbsp;file )</div></li><li><div class=fn><a href="#QFileInfo-4"><b>QFileInfo</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;d, const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</div></li><li><div class=fn><a href="#QFileInfo-5"><b>QFileInfo</b></a> ( const&nbsp;QFileInfo&nbsp;&amp;&nbsp;fi )</div></li><li><div class=fn><a href="#~QFileInfo"><b>~QFileInfo</b></a> ()</div></li><li><div class=fn>QFileInfo &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QFileInfo&nbsp;&amp;&nbsp;fi )</div></li><li><div class=fn>void <a href="#setFile"><b>setFile</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file )</div></li><li><div class=fn>void <a href="#setFile-2"><b>setFile</b></a> ( const&nbsp;QFile&nbsp;&amp;&nbsp;file )</div></li><li><div 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 )</div></li><li><div class=fn>bool <a href="#exists"><b>exists</b></a> () const</div></li><li><div class=fn>void <a href="#refresh"><b>refresh</b></a> () const</div></li><li><div class=fn>bool <a href="#caching"><b>caching</b></a> () const</div></li><li><div class=fn>void <a href="#setCaching"><b>setCaching</b></a> ( bool&nbsp;enable )</div></li><li><div class=fn>QString <a href="#filePath"><b>filePath</b></a> () const</div></li><li><div class=fn>QString <a href="#fileName"><b>fileName</b></a> () const</div></li><li><div class=fn>QString <a href="#absFilePath"><b>absFilePath</b></a> () const</div></li><li><div class=fn>QString <a href="#baseName"><b>baseName</b></a> ( bool&nbsp;complete = FALSE ) const</div></li><li><div class=fn>QString <a href="#extension"><b>extension</b></a> ( bool&nbsp;complete = TRUE ) const</div></li><li><div class=fn>QString <a href="#dirPath"><b>dirPath</b></a> ( bool&nbsp;absPath = FALSE ) const</div></li><li><div class=fn>QDir <a href="#dir"><b>dir</b></a> ( bool&nbsp;absPath = FALSE ) const</div></li><li><div class=fn>bool <a href="#isReadable"><b>isReadable</b></a> () const</div></li><li><div class=fn>bool <a href="#isWritable"><b>isWritable</b></a> () const</div></li><li><div class=fn>bool <a href="#isExecutable"><b>isExecutable</b></a> () const</div></li><li><div class=fn>bool <a href="#isRelative"><b>isRelative</b></a> () const</div></li><li><div class=fn>bool <a href="#convertToAbs"><b>convertToAbs</b></a> ()</div></li><li><div class=fn>bool <a href="#isFile"><b>isFile</b></a> () const</div></li><li><div class=fn>bool <a href="#isDir"><b>isDir</b></a> () const</div></li><li><div class=fn>bool <a href="#isSymLink"><b>isSymLink</b></a> () const</div></li><li><div class=fn>QString <a href="#readLink"><b>readLink</b></a> () const</div></li><li><div class=fn>QString <a href="#owner"><b>owner</b></a> () const</div></li><li><div class=fn>uint <a href="#ownerId"><b>ownerId</b></a> () const</div></li><li><div class=fn>QString <a href="#group"><b>group</b></a> () const</div></li><li><div class=fn>uint <a href="#groupId"><b>groupId</b></a> () const</div></li><li><div class=fn>bool <a href="#permission"><b>permission</b></a> ( int&nbsp;permissionSpec ) const</div></li><li><div class=fn>uint <a href="#size"><b>size</b></a> () const</div></li><li><div class=fn>QDateTime <a href="#created"><b>created</b></a> () const</div></li><li><div class=fn>QDateTime <a href="#lastModified"><b>lastModified</b></a> () const</div></li><li><div class=fn>QDateTime <a href="#lastRead"><b>lastRead</b></a> () const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>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 orsymbolic link, etc. The file's size and last modified/read times arealso available.<p> A QFileInfo can point to a file with either a relative or anabsolute file path. Absolute file paths begin with the directoryseparator "/" or a drive specification (except on Unix).Relative file names begin with a directory name or a file name andspecify a path relative to the current working directory. An example of anabsolute path is the string "/tmp/quartz". A relative path might looklike "src/fatlib". You can use the function <a href="#isRelative">isRelative</a>() to checkwhether a QFileInfo is using a relative or an absolute file path. Youcan call the function <a href="#convertToAbs">convertToAbs</a>() to convert a relative QFileInfo'spath to an absolute path.<p> The file that the QFileInfo works on is set in the constructor orlater with <a href="#setFile">setFile</a>(). Use <a href="#exists">exists</a>() to see if the file exists and<a href="#size">size</a>() to get its size.<p> To speed up performance, QFileInfo caches information about the file.Because files can be changed by other users or programs, or even byother parts of the same program, there is a function that refreshesthe file information: <a href="#refresh">refresh</a>(). If you want to switch off aQFileInfo's caching and force it to access the file system every timeyou request information from it call <a href="#setCaching">setCaching</a>(FALSE).<p> The file's type is obtained with <a href="#isFile">isFile</a>(), <a href="#isDir">isDir</a>() and <a href="#isSymLink">isSymLink</a>().The <a href="#readLink">readLink</a>() function provides the name of the file the symlinkpoints to.<p> Elements of the file's name can be extracted with <a href="#dirPath">dirPath</a>() and<a href="#fileName">fileName</a>(). The fileName()'s parts can be extracted with <a href="#baseName">baseName</a>()and <a href="#extension">extension</a>().<p> The file's dates are returned by <a href="#created">created</a>(), <a href="#lastModified">lastModified</a>() and<a href="#lastRead">lastRead</a>(). Information about the file's access permissions isobtained with <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and <a href="#isExecutable">isExecutable</a>(). Thefile's ownership is available from <a href="#owner">owner</a>(), <a href="#ownerId">ownerId</a>(), <a href="#group">group</a>() and<a href="#groupId">groupId</a>(). You can examine a file's permissions and ownership in asingle statement using the <a href="#permission">permission</a>() function.<p> If you need to read and traverse directories, see the <a href="qdir.html">QDir</a> class.<p>See also <a href="io.html">Input/Output and Networking</a>.<hr><h2>Member Type Documentation</h2><h3 class=fn><a name="PermissionSpec-enum"></a>QFileInfo::PermissionSpec</h3><p> This enum is used by the <a href="#permission">permission</a>() function to report thepermissions and ownership of a file. The values may be OR-edtogether to test multiple permissions and ownership values.<ul><li><tt>QFileInfo::ReadUser</tt> - The file is readable by the user.<li><tt>QFileInfo::WriteUser</tt> - The file is writable by the user.<li><tt>QFileInfo::ExeUser</tt> - The file is executable by the user.<li><tt>QFileInfo::ReadGroup</tt> - The file is readable by the group.<li><tt>QFileInfo::WriteGroup</tt> - The file is writable by the group.<li><tt>QFileInfo::ExeGroup</tt> - The file is executable by the group.<li><tt>QFileInfo::ReadOther</tt> - The file is readable by anyone.<li><tt>QFileInfo::WriteOther</tt> - The file is writable by anyone.<li><tt>QFileInfo::ExeOther</tt> - The file is executable by anyone.</ul><hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QFileInfo"></a>QFileInfo::QFileInfo ()</h3>Constructs a new empty QFileInfo.<h3 class=fn><a name="QFileInfo-2"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file )</h3>Constructs a new QFileInfo that gives information about the given file.The <em>file</em> can be an absolute or a relative file path.<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>().<h3 class=fn><a name="QFileInfo-3"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qfile.html">QFile</a>&nbsp;&amp;&nbsp;file )</h3>Constructs a new QFileInfo that gives information about file <em>file</em>.<p> If the <em>file</em> has a relative path, the QFileInfo will also have arelative path.<p> <p>See also <a href="#isRelative">isRelative</a>().<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 )</h3>Constructs a new QFileInfo that gives information about the filenamed <em>fileName</em> in the directory <em>d</em>.<p> If the directory has a relative path, the QFileInfo will also have arelative path.<p> <p>See also <a href="#isRelative">isRelative</a>().<h3 class=fn><a name="QFileInfo-5"></a>QFileInfo::QFileInfo ( const&nbsp;<a href="qfileinfo.html">QFileInfo</a>&nbsp;&amp;&nbsp;fi )</h3>Constructs a new QFileInfo that is a copy of <em>fi</em>.<h3 class=fn><a name="~QFileInfo"></a>QFileInfo::~QFileInfo ()</h3>Destroys the QFileInfo and frees its resources.<h3 class=fn><a href="qstring.html">QString</a> <a name="absFilePath"></a>QFileInfo::absFilePath () const</h3>Returns the absolute path including the file name.<p> The absolute path name consists of the full path and the filename. On Unix this will always begin with the root, '/', directory.On Windows this will always begin 'D:/' where D is a driveletter, except for network shares that are not mapped to a driveletter, in which case the path will begin '//sharename/'.<p> This function returns the same as <a href="#filePath">filePath</a>(), unless <a href="#isRelative">isRelative</a>() isTRUE.<p> This function can be time consuming under Unix (in the order ofmilliseconds).<p> <p>See also <a href="#isRelative">isRelative</a>() and <a href="#filePath">filePath</a>().<p>Examples: <a href="biff-example.html#x1940">biff/biff.cpp</a> and <a href="fileiconview-example.html#x816">fileiconview/qfileiconview.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="baseName"></a>QFileInfo::baseName ( bool&nbsp;complete = FALSE ) const</h3>Returns the base name of the file.<p> If <em>complete</em> is FALSE (the default) the base name consists of allcharacters in the file name up to (but not including) the <em>first</em> '.'character.<p> If <em>complete</em> is TRUE the base name consists of all characters in thefile up to (but not including) the <em>last</em> '.' character.<p> The path is not included in either case.<p> Example:<pre>     QFileInfo fi( "/tmp/archive.tar.gz" );     <a href="qstring.html">QString</a> base = fi.<a href="#baseName">baseName</a>();  // base = "archive"     base = fi.<a href="#baseName">baseName</a>( TRUE );    // base = "archive.tar"  </pre> <p> <p>See also <a href="#fileName">fileName</a>() and <a href="#extension">extension</a>().<h3 class=fn>bool <a name="caching"></a>QFileInfo::caching () const</h3>Returns TRUE if caching is enabled; otherwise returns FALSE.<p>See also <a href="#setCaching">setCaching</a>() and <a href="#refresh">refresh</a>().<h3 class=fn>bool <a name="convertToAbs"></a>QFileInfo::convertToAbs ()</h3>Converts the file path name to an absolute path.<p> If it is already absolute, nothing is done.<p> <p>See also <a href="#filePath">filePath</a>() and <a href="#isRelative">isRelative</a>().<h3 class=fn><a href="qdatetime.html">QDateTime</a> <a name="created"></a>QFileInfo::created () const</h3>Returns the date and time when the file was created.<p> On platforms where this information is not available, returns thesame as <a href="#lastModified">lastModified</a>().<p> <p>See also <a href="#lastModified">lastModified</a>() and <a href="#lastRead">lastRead</a>().<h3 class=fn><a href="qdir.html">QDir</a> <a name="dir"></a>QFileInfo::dir ( bool&nbsp;absPath = FALSE ) const</h3>Returns the directory path of the file.<p> If the QFileInfo is relative and <em>absPath</em> is FALSE, the <a href="qdir.html">QDir</a> will berelative; otherwise it will be absolute.<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>().<p>Example: <a href="fileiconview-example.html#x817">fileiconview/qfileiconview.cpp</a>.<h3 class=fn><a href="qstring.html">QString</a> <a name="dirPath"></a>QFileInfo::dirPath ( bool&nbsp;absPath = FALSE ) const</h3>Returns the directory path of the file.<p> If <em>absPath</em> is TRUE an absolute path is returned.<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>().

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -