You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
504 lines
29 KiB
504 lines
29 KiB
14 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qfileinfo.cpp:52 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>QFileInfo Class</title>
|
||
|
<style type="text/css"><!--
|
||
|
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 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>
|
||
|
<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>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
||
|
<p><tt>#include <<a href="qfileinfo-h.html">qfileinfo.h</a>></tt>
|
||
|
<p><a href="qfileinfo-members.html">List of all member functions.</a>
|
||
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>enum <a href="#PermissionSpec-enum"><b>PermissionSpec</b></a> { ReadOwner = 04000, WriteOwner = 02000, ExeOwner = 01000, ReadUser = 00400, WriteUser = 00200, ExeUser = 00100, ReadGroup = 00040, WriteGroup = 00020, ExeGroup = 00010, ReadOther = 00004, WriteOther = 00002, ExeOther = 00001 }</li>
|
||
|
<li class=fn><a href="#QFileInfo"><b>QFileInfo</b></a> ()</li>
|
||
|
<li class=fn><a href="#QFileInfo-2"><b>QFileInfo</b></a> ( const QString & file )</li>
|
||
|
<li class=fn><a href="#QFileInfo-3"><b>QFileInfo</b></a> ( const QFile & file )</li>
|
||
|
<li class=fn><a href="#QFileInfo-4"><b>QFileInfo</b></a> ( const QDir & d, const QString & fileName )</li>
|
||
|
<li class=fn><a href="#QFileInfo-5"><b>QFileInfo</b></a> ( const QFileInfo & fi )</li>
|
||
|
<li class=fn><a href="#~QFileInfo"><b>~QFileInfo</b></a> ()</li>
|
||
|
<li class=fn>QFileInfo & <a href="#operator-eq"><b>operator=</b></a> ( const QFileInfo & fi )</li>
|
||
|
<li class=fn>void <a href="#setFile"><b>setFile</b></a> ( const QString & file )</li>
|
||
|
<li class=fn>void <a href="#setFile-2"><b>setFile</b></a> ( const QFile & file )</li>
|
||
|
<li class=fn>void <a href="#setFile-3"><b>setFile</b></a> ( const QDir & d, const QString & fileName )</li>
|
||
|
<li class=fn>bool <a href="#exists"><b>exists</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#refresh"><b>refresh</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#caching"><b>caching</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#setCaching"><b>setCaching</b></a> ( bool enable )</li>
|
||
|
<li class=fn>QString <a href="#filePath"><b>filePath</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#fileName"><b>fileName</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#absFilePath"><b>absFilePath</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#baseName"><b>baseName</b></a> ( bool complete = FALSE ) const</li>
|
||
|
<li class=fn>QString <a href="#extension"><b>extension</b></a> ( bool complete = TRUE ) const</li>
|
||
|
<li class=fn>QString <a href="#dirPath"><b>dirPath</b></a> ( bool absPath = FALSE ) const</li>
|
||
|
<li class=fn>QDir <a href="#dir"><b>dir</b></a> ( bool absPath = FALSE ) const</li>
|
||
|
<li class=fn>bool <a href="#isReadable"><b>isReadable</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isWritable"><b>isWritable</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isExecutable"><b>isExecutable</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isHidden"><b>isHidden</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isRelative"><b>isRelative</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#convertToAbs"><b>convertToAbs</b></a> ()</li>
|
||
|
<li class=fn>bool <a href="#isFile"><b>isFile</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isDir"><b>isDir</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isSymLink"><b>isSymLink</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#readLink"><b>readLink</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#owner"><b>owner</b></a> () const</li>
|
||
|
<li class=fn>uint <a href="#ownerId"><b>ownerId</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#group"><b>group</b></a> () const</li>
|
||
|
<li class=fn>uint <a href="#groupId"><b>groupId</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#permission"><b>permission</b></a> ( int permissionSpec ) const</li>
|
||
|
<li class=fn>uint <a href="#size"><b>size</b></a> () const</li>
|
||
|
<li class=fn>QDateTime <a href="#created"><b>created</b></a> () const</li>
|
||
|
<li class=fn>QDateTime <a href="#lastModified"><b>lastModified</b></a> () const</li>
|
||
|
<li class=fn>QDateTime <a href="#lastRead"><b>lastRead</b></a> () const</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 or symbolic link, etc. The file's size and last
|
||
|
modified/read times are also available.
|
||
|
<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="#isRelative">isRelative</a>() to
|
||
|
check whether a QFileInfo is using a relative or an absolute file
|
||
|
path. You can call the function <a href="#convertToAbs">convertToAbs</a>() to convert a
|
||
|
relative QFileInfo's path to an absolute path.
|
||
|
<p> The file that the QFileInfo works on is set in the constructor or
|
||
|
later 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 by other parts of the same program, there is a function that
|
||
|
refreshes the file information: <a href="#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 <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 symlink points 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 is
|
||
|
obtained with <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and <a href="#isExecutable">isExecutable</a>(). The
|
||
|
file'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 a
|
||
|
single 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 the
|
||
|
permissions and ownership of a file. The values may be OR-ed
|
||
|
together to test multiple permissions and ownership values.
|
||
|
<ul>
|
||
|
<li><tt>QFileInfo::ReadOwner</tt> - The file is readable by the owner of the file.
|
||
|
<li><tt>QFileInfo::WriteOwner</tt> - The file is writable by the owner of the file.
|
||
|
<li><tt>QFileInfo::ExeOwner</tt> - The file is executable by the owner of the file.
|
||
|
<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><p> <b>Warning:</b> The semantics of <a href="#PermissionSpec-enum">ReadUser</a>, <a href="#PermissionSpec-enum">WriteUser</a> and <a href="#PermissionSpec-enum">ExeUser</a> are
|
||
|
unfortunately not platform independent: on Unix, the rights of the owner of
|
||
|
the file are returned and on Windows the rights of the current user are
|
||
|
returned. This behavior might change in a future Qt version. If you want to
|
||
|
find the rights of the owner of the file, you should use the flags <a href="#PermissionSpec-enum">ReadOwner</a>, <a href="#PermissionSpec-enum">WriteOwner</a> and <a href="#PermissionSpec-enum">ExeOwner</a>. If you want to find out the
|
||
|
rights of the current user, you should use <a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and
|
||
|
<a href="#isExecutable">isExecutable</a>().
|
||
|
|
||
|
<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 <a href="qstring.html">QString</a> & file )
|
||
|
</h3>
|
||
|
Constructs a new QFileInfo that gives information about the given
|
||
|
file. The <em>file</em> can also include an absolute or relative path.
|
||
|
<p> <b>Warning:</b> Some functions might behave in a counter-intuitive way
|
||
|
if <em>file</em> has a trailing directory separator.
|
||
|
<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 <a href="qfile.html">QFile</a> & 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 a
|
||
|
relative path.
|
||
|
<p> <p>See also <a href="#isRelative">isRelative</a>().
|
||
|
|
||
|
<h3 class=fn><a name="QFileInfo-4"></a>QFileInfo::QFileInfo ( const <a href="qdir.html">QDir</a> & d, const <a href="qstring.html">QString</a> & fileName )
|
||
|
</h3>
|
||
|
Constructs a new QFileInfo that gives information about the file
|
||
|
called <em>fileName</em> in the directory <em>d</em>.
|
||
|
<p> If <em>d</em> has a relative path, the QFileInfo will also have a
|
||
|
relative path.
|
||
|
<p> <p>See also <a href="#isRelative">isRelative</a>().
|
||
|
|
||
|
<h3 class=fn><a name="QFileInfo-5"></a>QFileInfo::QFileInfo ( const <a href="qfileinfo.html">QFileInfo</a> & 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 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> This function returns the same as <a href="#filePath">filePath</a>(), unless <a href="#isRelative">isRelative</a>()
|
||
|
is TRUE.
|
||
|
<p> If the QFileInfo is empty it returns <a href="qdir.html#currentDirPath">QDir::currentDirPath</a>().
|
||
|
<p> This function can be time consuming under Unix (in the order of
|
||
|
milliseconds).
|
||
|
<p> <p>See also <a href="#isRelative">isRelative</a>() and <a href="#filePath">filePath</a>().
|
||
|
|
||
|
<p>Examples: <a href="biff-example.html#x1954">biff/biff.cpp</a> and <a href="fileiconview-example.html#x820">fileiconview/qfileiconview.cpp</a>.
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="baseName"></a>QFileInfo::baseName ( bool 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
|
||
|
all characters 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
|
||
|
the file 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>
|
||
|
|
||
|
<p> Returns TRUE if caching is enabled; otherwise returns FALSE.
|
||
|
<p> <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's path 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 the
|
||
|
same 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 absPath = FALSE ) const
|
||
|
</h3>
|
||
|
Returns the file's path as a <a href="qdir.html">QDir</a> object.
|
||
|
<p> If the QFileInfo is relative and <em>absPath</em> is FALSE, the QDir
|
||
|
will be relative; 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#x821">fileiconview/qfileiconview.cpp</a>.
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="dirPath"></a>QFileInfo::dirPath ( bool absPath = FALSE ) const
|
||
|
</h3>
|
||
|
Returns the file's path.
|
||
|
<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>().
|
||
|
|
||
|
<p>Example: <a href="fileiconview-example.html#x822">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#x1955">biff/biff.cpp</a>, <a href="distributor-example.html#x2661">distributor/distributor.ui.h</a>, and <a href="i18n-example.html#x1937">i18n/main.cpp</a>.
|
||
|
<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
|
||
|
string of all characters in the file name after (but not
|
||
|
including) the first '.' character.
|
||
|
<p> If <em>complete</em> is FALSE, extension() returns the string of all
|
||
|
characters 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>Example: <a href="qdir-example.html#x1823">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, excluding the path.
|
||
|
<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#x1675">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x823">fileiconview/qfileiconview.cpp</a>, and <a href="ftpclient-example.html#x743">network/ftpclient/ftpmainwindow.ui.h</a>.
|
||
|
<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
|
||
|
or relative).
|
||
|
<p> <p>See also <a href="#isRelative">isRelative</a>() and <a href="#absFilePath">absFilePath</a>().
|
||
|
|
||
|
<p>Examples: <a href="dirview-example.html#x1713">dirview/main.cpp</a> and <a href="fileiconview-example.html#x824">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
|
||
|
do not have groups, or if an error occurs, <a href="qstring.html#QString-null">QString::null</a> is
|
||
|
returned.
|
||
|
<p> This function can be time consuming under Unix (in the order of
|
||
|
milliseconds).
|
||
|
<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
|
||
|
function always 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 symbolic
|
||
|
link to a directory; otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#isFile">isFile</a>() and <a href="#isSymLink">isSymLink</a>().
|
||
|
|
||
|
<p>Examples: <a href="dirview-example.html#x1676">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x825">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> <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 the
|
||
|
object points to something which isn't a file, e.g. a directory or
|
||
|
a symlink.
|
||
|
<p> <p>See also <a href="#isDir">isDir</a>() and <a href="#isSymLink">isSymLink</a>().
|
||
|
|
||
|
<p>Examples: <a href="dirview-example.html#x1677">dirview/dirview.cpp</a>, <a href="distributor-example.html#x2662">distributor/distributor.ui.h</a>, <a href="fileiconview-example.html#x826">fileiconview/qfileiconview.cpp</a>, and <a href="qdir-example.html#x1824">qdir/qdir.cpp</a>.
|
||
|
<h3 class=fn>bool <a name="isHidden"></a>QFileInfo::isHidden () const
|
||
|
</h3>
|
||
|
Returns TRUE if the file is hidden; otherwise returns FALSE.
|
||
|
<p> On Unix-like operating systems, including Mac OS X, a file is
|
||
|
hidden if its name begins with ".". On Windows a file is hidden if
|
||
|
its hidden attribute is set.
|
||
|
|
||
|
<h3 class=fn>bool <a name="isReadable"></a>QFileInfo::isReadable () const
|
||
|
</h3>
|
||
|
Returns TRUE if the file is readable; otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#isWritable">isWritable</a>(), <a href="#isExecutable">isExecutable</a>(), and <a href="#permission">permission</a>().
|
||
|
|
||
|
<p>Example: <a href="distributor-example.html#x2663">distributor/distributor.ui.h</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
|
||
|
the path is absolute (e.g. under Unix a path is absolute if it
|
||
|
begins 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 a
|
||
|
shortcut on Windows, or an alias on Mac OS X); 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#x1678">dirview/dirview.cpp</a>, <a href="distributor-example.html#x2664">distributor/distributor.ui.h</a>, and <a href="fileiconview-example.html#x827">fileiconview/qfileiconview.cpp</a>.
|
||
|
<h3 class=fn>bool <a name="isWritable"></a>QFileInfo::isWritable () const
|
||
|
</h3>
|
||
|
Returns TRUE if the file is writable; otherwise returns FALSE.
|
||
|
<p> <p>See also <a href="#isReadable">isReadable</a>(), <a href="#isExecutable">isExecutable</a>(), and <a href="#permission">permission</a>().
|
||
|
|
||
|
<p>Example: <a href="distributor-example.html#x2665">distributor/distributor.ui.h</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#x1956">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 the
|
||
|
same 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#x1957">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 systems where files
|
||
|
do not have owners, or if an error occurs, <a href="qstring.html#QString-null">QString::null</a> is
|
||
|
returned.
|
||
|
<p> This function can be time consuming under Unix (in the order of
|
||
|
milliseconds).
|
||
|
<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
|
||
|
function returns ((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>
|
||
|
Tests for file permissions. The <em>permissionSpec</em> argument can be
|
||
|
several flags of type <a href="#PermissionSpec-enum">PermissionSpec</a> OR-ed together to check
|
||
|
for permission combinations.
|
||
|
<p> On systems where files do not have permissions this function
|
||
|
always returns 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
|
||
|
a <a href="qstring.html#QString-null">QString::null</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 an
|
||
|
existing 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 information
|
||
|
from 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
|
||
|
the file 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 <em>file</em> 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> 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#x1958">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 <em>file</em> includes a relative path, the QFileInfo will also have
|
||
|
a relative 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 <em>fileName</em> includes a relative path, the QFileInfo will also
|
||
|
have a relative 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
|
||
|
if the size is 0 or if the size cannot be fetched.
|
||
|
|
||
|
<p>Example: <a href="qdir-example.html#x1825">qdir/qdir.cpp</a>.
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">Qt toolkit</a>.
|
||
|
Copyright © 1995-2007
|
||
|
<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 © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>Qt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|