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.
819 lines
51 KiB
819 lines
51 KiB
<!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/qdir.cpp:56 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>QDir 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>QDir Class Reference</h1>
|
|
|
|
<p>The QDir class provides access to directory structures and their contents in a platform-independent way.
|
|
<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="qdir-h.html">qdir.h</a>></tt>
|
|
<p><a href="qdir-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn>enum <a href="#FilterSpec-enum"><b>FilterSpec</b></a> { Dirs = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008, All = 0x007, TypeMask = 0x00F, Readable = 0x010, Writable = 0x020, Executable = 0x040, RWEMask = 0x070, Modified = 0x080, Hidden = 0x100, System = 0x200, AccessMask = 0x3F0, DefaultFilter = -1 }</li>
|
|
<li class=fn>enum <a href="#SortSpec-enum"><b>SortSpec</b></a> { Name = 0x00, Time = 0x01, Size = 0x02, Unsorted = 0x03, SortByMask = 0x03, DirsFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10, LocaleAware = 0x20, DefaultSort = -1 }</li>
|
|
<li class=fn><a href="#QDir"><b>QDir</b></a> ()</li>
|
|
<li class=fn><a href="#QDir-2"><b>QDir</b></a> ( const QString & path, const QString & nameFilter = QString::null, int sortSpec = Name | IgnoreCase, int filterSpec = All )</li>
|
|
<li class=fn><a href="#QDir-3"><b>QDir</b></a> ( const QDir & d )</li>
|
|
<li class=fn>virtual <a href="#~QDir"><b>~QDir</b></a> ()</li>
|
|
<li class=fn>QDir & <a href="#operator-eq"><b>operator=</b></a> ( const QDir & d )</li>
|
|
<li class=fn>QDir & <a href="#operator-eq-2"><b>operator=</b></a> ( const QString & path )</li>
|
|
<li class=fn>virtual void <a href="#setPath"><b>setPath</b></a> ( const QString & path )</li>
|
|
<li class=fn>virtual QString <a href="#path"><b>path</b></a> () const</li>
|
|
<li class=fn>virtual QString <a href="#absPath"><b>absPath</b></a> () const</li>
|
|
<li class=fn>virtual QString <a href="#canonicalPath"><b>canonicalPath</b></a> () const</li>
|
|
<li class=fn>virtual QString <a href="#dirName"><b>dirName</b></a> () const</li>
|
|
<li class=fn>virtual QString <a href="#filePath"><b>filePath</b></a> ( const QString & fileName, bool acceptAbsPath = TRUE ) const</li>
|
|
<li class=fn>virtual QString <a href="#absFilePath"><b>absFilePath</b></a> ( const QString & fileName, bool acceptAbsPath = TRUE ) const</li>
|
|
<li class=fn>virtual bool <a href="#cd"><b>cd</b></a> ( const QString & dirName, bool acceptAbsPath = TRUE )</li>
|
|
<li class=fn>virtual bool <a href="#cdUp"><b>cdUp</b></a> ()</li>
|
|
<li class=fn>QString <a href="#nameFilter"><b>nameFilter</b></a> () const</li>
|
|
<li class=fn>virtual void <a href="#setNameFilter"><b>setNameFilter</b></a> ( const QString & nameFilter )</li>
|
|
<li class=fn>FilterSpec <a href="#filter"><b>filter</b></a> () const</li>
|
|
<li class=fn>virtual void <a href="#setFilter"><b>setFilter</b></a> ( int filterSpec )</li>
|
|
<li class=fn>SortSpec <a href="#sorting"><b>sorting</b></a> () const</li>
|
|
<li class=fn>virtual void <a href="#setSorting"><b>setSorting</b></a> ( int sortSpec )</li>
|
|
<li class=fn>bool <a href="#matchAllDirs"><b>matchAllDirs</b></a> () const</li>
|
|
<li class=fn>virtual void <a href="#setMatchAllDirs"><b>setMatchAllDirs</b></a> ( bool enable )</li>
|
|
<li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
|
|
<li class=fn>QString <a href="#operator[]"><b>operator[]</b></a> ( int index ) const</li>
|
|
<li class=fn>virtual QStrList encodedEntryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const <em>(obsolete)</em></li>
|
|
<li class=fn>virtual QStrList encodedEntryList ( const QString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const <em>(obsolete)</em></li>
|
|
<li class=fn>virtual QStringList <a href="#entryList-2"><b>entryList</b></a> ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const</li>
|
|
<li class=fn>virtual QStringList <a href="#entryList"><b>entryList</b></a> ( const QString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const</li>
|
|
<li class=fn>virtual const QFileInfoList * <a href="#entryInfoList-2"><b>entryInfoList</b></a> ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const</li>
|
|
<li class=fn>virtual const QFileInfoList * <a href="#entryInfoList"><b>entryInfoList</b></a> ( const QString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const</li>
|
|
<li class=fn>virtual bool <a href="#mkdir"><b>mkdir</b></a> ( const QString & dirName, bool acceptAbsPath = TRUE ) const</li>
|
|
<li class=fn>virtual bool <a href="#rmdir"><b>rmdir</b></a> ( const QString & dirName, bool acceptAbsPath = TRUE ) const</li>
|
|
<li class=fn>virtual bool <a href="#isReadable"><b>isReadable</b></a> () const</li>
|
|
<li class=fn>virtual bool <a href="#exists-2"><b>exists</b></a> () const</li>
|
|
<li class=fn>virtual bool <a href="#isRoot"><b>isRoot</b></a> () const</li>
|
|
<li class=fn>virtual bool <a href="#isRelative"><b>isRelative</b></a> () const</li>
|
|
<li class=fn>virtual void <a href="#convertToAbs"><b>convertToAbs</b></a> ()</li>
|
|
<li class=fn>virtual bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QDir & d ) const</li>
|
|
<li class=fn>virtual bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QDir & d ) const</li>
|
|
<li class=fn>virtual bool <a href="#remove"><b>remove</b></a> ( const QString & fileName, bool acceptAbsPath = TRUE )</li>
|
|
<li class=fn>virtual bool <a href="#rename"><b>rename</b></a> ( const QString & oldName, const QString & newName, bool acceptAbsPaths = TRUE )</li>
|
|
<li class=fn>virtual bool <a href="#exists"><b>exists</b></a> ( const QString & name, bool acceptAbsPath = TRUE )</li>
|
|
<li class=fn>void <a href="#refresh"><b>refresh</b></a> () const</li>
|
|
</ul>
|
|
<h2>Static Public Members</h2>
|
|
<ul>
|
|
<li class=fn>QString <a href="#convertSeparators"><b>convertSeparators</b></a> ( const QString & pathName )</li>
|
|
<li class=fn>const QFileInfoList * <a href="#drives"><b>drives</b></a> ()</li>
|
|
<li class=fn>char <a href="#separator"><b>separator</b></a> ()</li>
|
|
<li class=fn>bool <a href="#setCurrent"><b>setCurrent</b></a> ( const QString & path )</li>
|
|
<li class=fn>QDir <a href="#current"><b>current</b></a> ()</li>
|
|
<li class=fn>QDir <a href="#home"><b>home</b></a> ()</li>
|
|
<li class=fn>QDir <a href="#root"><b>root</b></a> ()</li>
|
|
<li class=fn>QString <a href="#currentDirPath"><b>currentDirPath</b></a> ()</li>
|
|
<li class=fn>QString <a href="#homeDirPath"><b>homeDirPath</b></a> ()</li>
|
|
<li class=fn>QString <a href="#rootDirPath"><b>rootDirPath</b></a> ()</li>
|
|
<li class=fn>bool <a href="#match-2"><b>match</b></a> ( const QStringList & filters, const QString & fileName )</li>
|
|
<li class=fn>bool <a href="#match"><b>match</b></a> ( const QString & filter, const QString & fileName )</li>
|
|
<li class=fn>QString <a href="#cleanDirPath"><b>cleanDirPath</b></a> ( const QString & filePath )</li>
|
|
<li class=fn>bool <a href="#isRelativePath"><b>isRelativePath</b></a> ( const QString & path )</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
|
|
|
|
The QDir class provides access to directory structures and their contents in a platform-independent way.
|
|
<p>
|
|
|
|
<p> A QDir is used to manipulate path names, access information
|
|
regarding paths and files, and manipulate the underlying file
|
|
system.
|
|
<p> A QDir can point to a file using either a relative or an absolute
|
|
path. Absolute paths begin with the directory separator "/"
|
|
(optionally preceded by a drive specification under Windows). If
|
|
you always use "/" as a directory separator, Qt will translate
|
|
your paths to conform to the underlying operating system. Relative
|
|
file names begin with a directory name or a file name and specify
|
|
a path relative to the current directory.
|
|
<p> The "current" path refers to the application's working directory.
|
|
A QDir's own path is set and retrieved with <a href="#setPath">setPath</a>() and <a href="#path">path</a>().
|
|
<p> 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 if a QDir is using a relative or an
|
|
absolute file path. Call <a href="#convertToAbs">convertToAbs</a>() to convert a relative QDir
|
|
to an absolute one. For a simplified path use <a href="#cleanDirPath">cleanDirPath</a>(). To
|
|
obtain a path which has no symbolic links or redundant ".."
|
|
elements use <a href="#canonicalPath">canonicalPath</a>(). The path can be set with setPath(),
|
|
and changed with <a href="#cd">cd</a>() and <a href="#cdUp">cdUp</a>().
|
|
<p> QDir provides several static functions, for example, <a href="#setCurrent">setCurrent</a>()
|
|
to set the application's working directory and <a href="#currentDirPath">currentDirPath</a>() to
|
|
retrieve the application's working directory. Access to some
|
|
common paths is provided with the static functions, <a href="#current">current</a>(),
|
|
<a href="#home">home</a>() and <a href="#root">root</a>() which return QDir objects or currentDirPath(),
|
|
<a href="#homeDirPath">homeDirPath</a>() and <a href="#rootDirPath">rootDirPath</a>() which return the path as a string.
|
|
If you want to know about your application's path use
|
|
<a href="qapplication.html#applicationDirPath">QApplication::applicationDirPath</a>().
|
|
<p> The number of entries in a directory is returned by <a href="#count">count</a>().
|
|
Obtain a string list of the names of all the files and directories
|
|
in a directory with <a href="#entryList">entryList</a>(). If you prefer a list of <a href="qfileinfo.html">QFileInfo</a>
|
|
pointers use <a href="#entryInfoList">entryInfoList</a>(). Both these functions can apply a
|
|
name filter, an attributes filter (e.g. read-only, files not
|
|
directories, etc.), and a sort order. The filters and sort may be
|
|
set with calls to <a href="#setNameFilter">setNameFilter</a>(), <a href="#setFilter">setFilter</a>() and <a href="#setSorting">setSorting</a>().
|
|
They may also be specified in the entryList() and
|
|
entryInfoList()'s arguments.
|
|
<p> Create a new directory with <a href="#mkdir">mkdir</a>(), rename a directory with
|
|
<a href="#rename">rename</a>() and remove an existing directory with <a href="#rmdir">rmdir</a>(). Remove a
|
|
file with <a href="#remove">remove</a>(). You can interrogate a directory with <a href="#exists">exists</a>(),
|
|
<a href="#isReadable">isReadable</a>() and <a href="#isRoot">isRoot</a>().
|
|
<p> To get a path with a filename use <a href="#filePath">filePath</a>(), and to get a
|
|
directory name use <a href="#dirName">dirName</a>(); neither of these functions checks
|
|
for the existence of the file or directory.
|
|
<p> The list of root directories is provided by <a href="#drives">drives</a>(); on Unix
|
|
systems this returns a list containing one root directory, "/"; on
|
|
Windows the list will usually contain "C:/", and possibly "D:/",
|
|
etc.
|
|
<p> It is easiest to work with "/" separators in Qt code. If you need
|
|
to present a path to the user or need a path in a form suitable
|
|
for a function in the underlying operating system use
|
|
<a href="#convertSeparators">convertSeparators</a>().
|
|
<p> Examples:
|
|
<p> See if a directory exists.
|
|
<pre>
|
|
QDir d( "example" ); // "./example"
|
|
if ( !d.<a href="#exists">exists</a>() )
|
|
<a href="qapplication.html#qWarning">qWarning</a>( "Cannot find the example directory" );
|
|
</pre>
|
|
|
|
<p> Traversing directories and reading a file.
|
|
<pre>
|
|
QDir d = QDir::<a href="#root">root</a>(); // "/"
|
|
if ( !d.<a href="#cd">cd</a>("tmp") ) { // "/tmp"
|
|
<a href="qapplication.html#qWarning">qWarning</a>( "Cannot find the \"/tmp\" directory" );
|
|
} else {
|
|
<a href="qfile.html">QFile</a> f( d.<a href="#filePath">filePath</a>("ex1.txt") ); // "/tmp/ex1.txt"
|
|
if ( !f.<a href="qfile.html#open">open</a>(IO_ReadWrite) )
|
|
<a href="qapplication.html#qWarning">qWarning</a>( "Cannot create the file %s", f.<a href="qfile.html#name">name</a>() );
|
|
}
|
|
</pre>
|
|
|
|
<p> A program that lists all the files in the current directory
|
|
(excluding symbolic links), sorted by size, smallest first:
|
|
<pre>
|
|
#include <stdio.h>
|
|
#include <<a href="qdir-h.html">qdir.h</a>>
|
|
|
|
int main( int argc, char **argv )
|
|
{
|
|
QDir d;
|
|
d.<a href="#setFilter">setFilter</a>( QDir::<a href="#FilterSpec-enum">Files</a> | QDir::<a href="#FilterSpec-enum">Hidden</a> | QDir::<a href="#FilterSpec-enum">NoSymLinks</a> );
|
|
d.<a href="#setSorting">setSorting</a>( QDir::<a href="#SortSpec-enum">Size</a> | QDir::<a href="#SortSpec-enum">Reversed</a> );
|
|
|
|
const QFileInfoList *list = d.<a href="#entryInfoList">entryInfoList</a>();
|
|
QFileInfoListIterator it( *list );
|
|
<a href="qfileinfo.html">QFileInfo</a> *fi;
|
|
|
|
printf( " Bytes Filename\n" );
|
|
while ( (fi = it.current()) != 0 ) {
|
|
printf( "%10li %s\n", fi-><a href="qfileinfo.html#size">size</a>(), fi-><a href="qfileinfo.html#fileName">fileName</a>().latin1() );
|
|
++it;
|
|
}
|
|
return 0;
|
|
}
|
|
</pre>
|
|
|
|
<p> <p>See also <a href="qapplication.html#applicationDirPath">QApplication::applicationDirPath</a>() and <a href="io.html">Input/Output and Networking</a>.
|
|
|
|
<hr><h2>Member Type Documentation</h2>
|
|
<h3 class=fn><a name="FilterSpec-enum"></a>QDir::FilterSpec</h3>
|
|
|
|
<p> This enum describes the filtering options available to QDir, e.g.
|
|
for <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>(). The filter value is specified
|
|
by OR-ing together values from the following list:
|
|
<ul>
|
|
<li><tt>QDir::Dirs</tt> - List directories only.
|
|
<li><tt>QDir::Files</tt> - List files only.
|
|
<li><tt>QDir::Drives</tt> - List disk drives (ignored under Unix).
|
|
<li><tt>QDir::NoSymLinks</tt> - Do not list symbolic links (ignored by operating
|
|
systems that don't support symbolic links).
|
|
<li><tt>QDir::All</tt> - List directories, files, drives and symlinks (this does not list
|
|
broken symlinks unless you specify System).
|
|
<li><tt>QDir::TypeMask</tt> - A mask for the the Dirs, Files, Drives and
|
|
NoSymLinks flags.
|
|
<li><tt>QDir::Readable</tt> - List files for which the application has read access.
|
|
<li><tt>QDir::Writable</tt> - List files for which the application has write access.
|
|
<li><tt>QDir::Executable</tt> - List files for which the application has execute
|
|
access. Executables needs to be combined with Dirs or Files.
|
|
<li><tt>QDir::RWEMask</tt> - A mask for the Readable, Writable and Executable flags.
|
|
<li><tt>QDir::Modified</tt> - Only list files that have been modified (ignored
|
|
under Unix).
|
|
<li><tt>QDir::Hidden</tt> - List hidden files (on Unix, files starting with a .).
|
|
<li><tt>QDir::System</tt> - List system files (on Unix, FIFOs, sockets and
|
|
device files)
|
|
<li><tt>QDir::AccessMask</tt> - A mask for the Readable, Writable, Executable
|
|
Modified, Hidden and System flags
|
|
<li><tt>QDir::DefaultFilter</tt> - Internal flag.
|
|
</ul><p> If you do not set any of <a href="#FilterSpec-enum">Readable</a>, <a href="#FilterSpec-enum">Writable</a> or <a href="#FilterSpec-enum">Executable</a>, QDir will set all three of them. This makes the
|
|
default easy to write and at the same time useful.
|
|
<p> Examples: <tt>Readable|Writable</tt> means list all files for which the
|
|
application has read access, write access or both. <tt>Dirs|Drives</tt>
|
|
means list drives, directories, all files that the application can
|
|
read, write or execute, and also symlinks to such
|
|
files/directories.
|
|
|
|
<h3 class=fn><a name="SortSpec-enum"></a>QDir::SortSpec</h3>
|
|
|
|
<p> This enum describes the sort options available to QDir, e.g. for
|
|
<a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>(). The sort value is specified by
|
|
OR-ing together values from the following list:
|
|
<ul>
|
|
<li><tt>QDir::Name</tt> - Sort by name.
|
|
<li><tt>QDir::Time</tt> - Sort by time (modification time).
|
|
<li><tt>QDir::Size</tt> - Sort by file size.
|
|
<li><tt>QDir::Unsorted</tt> - Do not sort.
|
|
<li><tt>QDir::SortByMask</tt> - A mask for Name, Time and Size.
|
|
<li><tt>QDir::DirsFirst</tt> - Put the directories first, then the files.
|
|
<li><tt>QDir::Reversed</tt> - Reverse the sort order.
|
|
<li><tt>QDir::IgnoreCase</tt> - Sort case-insensitively.
|
|
<li><tt>QDir::LocaleAware</tt> - Sort names using locale aware compares
|
|
<li><tt>QDir::DefaultSort</tt> - Internal flag.
|
|
</ul><p> You can only specify one of the first four.
|
|
<p> If you specify both <a href="#SortSpec-enum">DirsFirst</a> and <a href="#SortSpec-enum">Reversed</a>, directories are
|
|
still put first, but in reverse order; the files will be listed
|
|
after the directories, again in reverse order.
|
|
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<h3 class=fn><a name="QDir"></a>QDir::QDir ()
|
|
</h3>
|
|
Constructs a QDir pointing to the current directory (".").
|
|
<p> <p>See also <a href="#currentDirPath">currentDirPath</a>().
|
|
|
|
<h3 class=fn><a name="QDir-2"></a>QDir::QDir ( const <a href="qstring.html">QString</a> & path, const <a href="qstring.html">QString</a> & nameFilter = QString::null, int sortSpec = Name | IgnoreCase, int filterSpec = All )
|
|
</h3>
|
|
Constructs a QDir with path <em>path</em>, that filters its entries by
|
|
name using <em>nameFilter</em> and by attributes using <em>filterSpec</em>. It
|
|
also sorts the names using <em>sortSpec</em>.
|
|
<p> The default <em>nameFilter</em> is an empty string, which excludes
|
|
nothing; the default <em>filterSpec</em> is <a href="#FilterSpec-enum">All</a>, which also means
|
|
exclude nothing. The default <em>sortSpec</em> is <tt>Name|IgnoreCase</tt>,
|
|
i.e. sort by name case-insensitively.
|
|
<p> Example that lists all the files in "/tmp":
|
|
<pre>
|
|
QDir d( "/tmp" );
|
|
for ( int i = 0; i < d.<a href="#count">count</a>(); i++ )
|
|
printf( "%s\n", d[i] );
|
|
</pre>
|
|
|
|
<p> If <em>path</em> is "" or <a href="qstring.html#QString-null">QString::null</a>, QDir uses "." (the current
|
|
directory). If <em>nameFilter</em> is "" or QString::null, QDir uses the
|
|
name filter "*" (all files).
|
|
<p> Note that <em>path</em> need not exist.
|
|
<p> <p>See also <a href="#exists">exists</a>(), <a href="#setPath">setPath</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setFilter">setFilter</a>(), and <a href="#setSorting">setSorting</a>().
|
|
|
|
<h3 class=fn><a name="QDir-3"></a>QDir::QDir ( const <a href="qdir.html">QDir</a> & d )
|
|
</h3>
|
|
Constructs a QDir that is a copy of the directory <em>d</em>.
|
|
<p> <p>See also <a href="#operator-eq">operator=</a>().
|
|
|
|
<h3 class=fn><a name="~QDir"></a>QDir::~QDir ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Destroys the QDir frees up its resources.
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="absFilePath"></a>QDir::absFilePath ( const <a href="qstring.html">QString</a> & fileName, bool acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns the absolute path name of a file in the directory. Does <em>not</em> check if the file actually exists in the directory. Redundant
|
|
multiple separators or "." and ".." directories in <em>fileName</em>
|
|
will not be removed (see <a href="#cleanDirPath">cleanDirPath</a>()).
|
|
<p> If <em>acceptAbsPath</em> is TRUE a <em>fileName</em> starting with a
|
|
separator "/" will be returned without change. If <em>acceptAbsPath</em>
|
|
is FALSE an absolute path will be prepended to the fileName and
|
|
the resultant string returned.
|
|
<p> <p>See also <a href="#filePath">filePath</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="absPath"></a>QDir::absPath () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns the absolute path (a path that starts with "/" or with a
|
|
drive specification), which may contain symbolic links, but never
|
|
contains redundant ".", ".." or multiple separators.
|
|
<p> <p>See also <a href="#setPath">setPath</a>(), <a href="#canonicalPath">canonicalPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), and <a href="#absFilePath">absFilePath</a>().
|
|
|
|
<p>Example: <a href="fileiconview-example.html#x810">fileiconview/qfileiconview.cpp</a>.
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="canonicalPath"></a>QDir::canonicalPath () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns the canonical path, i.e. a path without symbolic links or
|
|
redundant "." or ".." elements.
|
|
<p> On systems that do not have symbolic links this function will
|
|
always return the same string that <a href="#absPath">absPath</a>() returns. If the
|
|
canonical path does not exist (normally due to dangling symbolic
|
|
links) <a href="#canonicalPath">canonicalPath</a>() returns <a href="qstring.html#QString-null">QString::null</a>.
|
|
<p> <p>See also <a href="#path">path</a>(), <a href="#absPath">absPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), <a href="#absFilePath">absFilePath</a>(), and <a href="qstring.html#isNull">QString::isNull</a>().
|
|
|
|
<h3 class=fn>bool <a name="cd"></a>QDir::cd ( const <a href="qstring.html">QString</a> & dirName, bool acceptAbsPath = TRUE )<tt> [virtual]</tt>
|
|
</h3>
|
|
Changes the QDir's directory to <em>dirName</em>.
|
|
<p> If <em>acceptAbsPath</em> is TRUE a path starting with separator "/"
|
|
will cause the function to change to the absolute directory. If <em>acceptAbsPath</em> is FALSE any number of separators at the beginning
|
|
of <em>dirName</em> will be removed and the function will descend into
|
|
<em>dirName</em>.
|
|
<p> Returns TRUE if the new directory exists and is readable;
|
|
otherwise returns FALSE. Note that the logical <a href="#cd">cd</a>() operation is
|
|
not performed if the new directory does not exist.
|
|
<p> Calling cd( ".." ) is equivalent to calling <a href="#cdUp">cdUp</a>().
|
|
<p> <p>See also <a href="#cdUp">cdUp</a>(), <a href="#isReadable">isReadable</a>(), <a href="#exists">exists</a>(), and <a href="#path">path</a>().
|
|
|
|
<p>Example: <a href="fileiconview-example.html#x883">fileiconview/mainwindow.cpp</a>.
|
|
<h3 class=fn>bool <a name="cdUp"></a>QDir::cdUp ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Changes directory by moving one directory up from the QDir's
|
|
current directory.
|
|
<p> Returns TRUE if the new directory exists and is readable;
|
|
otherwise returns FALSE. Note that the logical <a href="#cdUp">cdUp</a>() operation is
|
|
not performed if the new directory does not exist.
|
|
<p> <p>See also <a href="#cd">cd</a>(), <a href="#isReadable">isReadable</a>(), <a href="#exists">exists</a>(), and <a href="#path">path</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="cleanDirPath"></a>QDir::cleanDirPath ( const <a href="qstring.html">QString</a> & filePath )<tt> [static]</tt>
|
|
</h3>
|
|
Removes all multiple directory separators "/" and resolves any
|
|
"."s or ".."s found in the path, <em>filePath</em>.
|
|
<p> Symbolic links are kept. This function does not return the
|
|
canonical path, but rather the simplest version of the input.
|
|
For example, "./local" becomes "local", "local/../bin" becomes
|
|
"bin" and "/local/usr/../bin" becomes "/local/bin".
|
|
<p> <p>See also <a href="#absPath">absPath</a>() and <a href="#canonicalPath">canonicalPath</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="convertSeparators"></a>QDir::convertSeparators ( const <a href="qstring.html">QString</a> & pathName )<tt> [static]</tt>
|
|
</h3>
|
|
Returns <em>pathName</em> with the '/' separators converted to
|
|
separators that are appropriate for the underlying operating
|
|
system.
|
|
<p> On Windows, <a href="#convertSeparators">convertSeparators</a>("c:/winnt/system32") returns
|
|
"c:\winnt\system32".
|
|
<p> The returned string may be the same as the argument on some
|
|
operating systems, for example on Unix.
|
|
|
|
<p>Examples: <a href="dirview-example.html#x1664">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x811">fileiconview/qfileiconview.cpp</a>.
|
|
<h3 class=fn>void <a name="convertToAbs"></a>QDir::convertToAbs ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Converts the directory path to an absolute path. If it is already
|
|
absolute nothing is done.
|
|
<p> <p>See also <a href="#isRelative">isRelative</a>().
|
|
|
|
<h3 class=fn>uint <a name="count"></a>QDir::count () const
|
|
</h3>
|
|
Returns the total number of directories and files that were found.
|
|
<p> Equivalent to <a href="#entryList">entryList</a>().<a href="#count">count</a>().
|
|
<p> <p>See also <a href="#operator[]">operator[]</a>() and <a href="#entryList">entryList</a>().
|
|
|
|
<h3 class=fn><a href="qdir.html">QDir</a> <a name="current"></a>QDir::current ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns the application's current directory.
|
|
<p> Use <a href="#path">path</a>() to access a QDir object's path.
|
|
<p> <p>See also <a href="#currentDirPath">currentDirPath</a>() and <a href="#QDir">QDir::QDir</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="currentDirPath"></a>QDir::currentDirPath ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns the absolute path of the application's current directory.
|
|
<p> <p>See also <a href="#current">current</a>().
|
|
|
|
<p>Examples: <a href="dirview-example.html#x1665">dirview/dirview.cpp</a>, <a href="helpviewer-example.html#x986">helpviewer/helpwindow.cpp</a>, and <a href="qdir-example.html#x1813">qdir/qdir.cpp</a>.
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="dirName"></a>QDir::dirName () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns the name of the directory; this is <em>not</em> the same as the
|
|
path, e.g. a directory with the name "mail", might have the path
|
|
"/var/spool/mail". If the directory has no name (e.g. it is the
|
|
root directory) <a href="qstring.html#QString-null">QString::null</a> is returned.
|
|
<p> No check is made to ensure that a directory with this name
|
|
actually exists.
|
|
<p> <p>See also <a href="#path">path</a>(), <a href="#absPath">absPath</a>(), <a href="#absFilePath">absFilePath</a>(), <a href="#exists">exists</a>(), and <a href="qstring.html#isNull">QString::isNull</a>().
|
|
|
|
<h3 class=fn>const QFileInfoList * <a name="drives"></a>QDir::drives ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns a list of the root directories on this system. On Windows
|
|
this returns a number of <a href="qfileinfo.html">QFileInfo</a> objects containing "C:/", "D:/"
|
|
etc. On other operating systems, it returns a list containing just
|
|
one root directory (e.g. "/").
|
|
<p> The returned pointer is owned by Qt. Callers should <em>not</em> delete
|
|
or modify it.
|
|
|
|
<p>Example: <a href="dirview-example.html#x1712">dirview/main.cpp</a>.
|
|
<h3 class=fn><a href="qstrlist.html">QStrList</a> <a name="encodedEntryList"></a>QDir::encodedEntryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
|
<p> This function is included to easy porting from Qt 1.x to Qt 2.0,
|
|
it is the same as <a href="#entryList">entryList</a>(), but encodes the filenames as 8-bit
|
|
strings using QFile::encodedName().
|
|
<p> It is more efficient to use entryList().
|
|
|
|
<h3 class=fn><a href="qstrlist.html">QStrList</a> <a name="encodedEntryList-2"></a>QDir::encodedEntryList ( const <a href="qstring.html">QString</a> & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> This function is included to easy porting from Qt 1.x to Qt 2.0,
|
|
it is the same as <a href="#entryList">entryList</a>(), but encodes the filenames as 8-bit
|
|
strings using QFile::encodedName().
|
|
<p> It is more efficient to use entryList().
|
|
|
|
<h3 class=fn>const QFileInfoList * <a name="entryInfoList"></a>QDir::entryInfoList ( const <a href="qstring.html">QString</a> & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and
|
|
directories in the directory, ordered in accordance with
|
|
<a href="#setSorting">setSorting</a>() and filtered in accordance with <a href="#setFilter">setFilter</a>() and
|
|
<a href="#setNameFilter">setNameFilter</a>().
|
|
<p> The filter and sorting specifications can be overridden using the
|
|
<em>nameFilter</em>, <em>filterSpec</em> and <em>sortSpec</em> arguments.
|
|
<p> Returns 0 if the directory is unreadable or does not exist.
|
|
<p> The returned pointer is a const pointer to a QFileInfoList. The
|
|
list is owned by the QDir object and will be reused on the next
|
|
call to <a href="#entryInfoList">entryInfoList</a>() for the same QDir instance. If you want to
|
|
keep the entries of the list after a subsequent call to this
|
|
function you must copy them.
|
|
<p> Note: QFileInfoList is really a <a href="qptrlist.html">QPtrList</a><QFileInfo>.
|
|
<p> <p>See also <a href="#entryList">entryList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
|
|
|
|
<p>Examples: <a href="dirview-example.html#x1666">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x812">fileiconview/qfileiconview.cpp</a>.
|
|
<h3 class=fn>const QFileInfoList * <a name="entryInfoList-2"></a>QDir::entryInfoList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and
|
|
directories in the directory, ordered in accordance with
|
|
<a href="#setSorting">setSorting</a>() and filtered in accordance with <a href="#setFilter">setFilter</a>() and
|
|
<a href="#setNameFilter">setNameFilter</a>().
|
|
<p> The filter and sorting specifications can be overridden using the
|
|
<em>filterSpec</em> and <em>sortSpec</em> arguments.
|
|
<p> Returns 0 if the directory is unreadable or does not exist.
|
|
<p> The returned pointer is a const pointer to a QFileInfoList. The
|
|
list is owned by the QDir object and will be reused on the next
|
|
call to <a href="#entryInfoList">entryInfoList</a>() for the same QDir instance. If you want to
|
|
keep the entries of the list after a subsequent call to this
|
|
function you must copy them.
|
|
<p> Note: QFileInfoList is really a <a href="qptrlist.html">QPtrList</a><QFileInfo>.
|
|
<p> <p>See also <a href="#entryList">entryList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
|
|
|
|
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="entryList"></a>QDir::entryList ( const <a href="qstring.html">QString</a> & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns a list of the names of all the files and directories in
|
|
the directory, ordered in accordance with <a href="#setSorting">setSorting</a>() and
|
|
filtered in accordance with <a href="#setFilter">setFilter</a>() and <a href="#setNameFilter">setNameFilter</a>().
|
|
<p> The filter and sorting specifications can be overridden using the
|
|
<em>nameFilter</em>, <em>filterSpec</em> and <em>sortSpec</em> arguments.
|
|
<p> Returns an empty list if the directory is unreadable or does not
|
|
exist.
|
|
<p> <p>See also <a href="#entryInfoList">entryInfoList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
|
|
|
|
<p>Example: <a href="statistics-example.html#x2780">table/statistics/statistics.cpp</a>.
|
|
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="entryList-2"></a>QDir::entryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns a list of the names of all the files and directories in
|
|
the directory, ordered in accordance with <a href="#setSorting">setSorting</a>() and
|
|
filtered in accordance with <a href="#setFilter">setFilter</a>() and <a href="#setNameFilter">setNameFilter</a>().
|
|
<p> The filter and sorting specifications can be overridden using the
|
|
<em>filterSpec</em> and <em>sortSpec</em> arguments.
|
|
<p> Returns an empty list if the directory is unreadable or does not
|
|
exist.
|
|
<p> <p>See also <a href="#entryInfoList">entryInfoList</a>(), <a href="#setNameFilter">setNameFilter</a>(), <a href="#setSorting">setSorting</a>(), and <a href="#setFilter">setFilter</a>().
|
|
|
|
<h3 class=fn>bool <a name="exists"></a>QDir::exists ( const <a href="qstring.html">QString</a> & name, bool acceptAbsPath = TRUE )<tt> [virtual]</tt>
|
|
</h3>
|
|
Checks for the existence of the file <em>name</em>.
|
|
<p> If <em>acceptAbsPath</em> is TRUE a path starting with separator "/"
|
|
will check the file with the absolute path. If <em>acceptAbsPath</em> is
|
|
FALSE any number of separators at the beginning of <em>name</em> will be
|
|
removed and the resultant file name will be checked.
|
|
<p> Returns TRUE if the file exists; otherwise returns FALSE.
|
|
<p> <p>See also <a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists">QFile::exists</a>().
|
|
|
|
<h3 class=fn>bool <a name="exists-2"></a>QDir::exists () const<tt> [virtual]</tt>
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns TRUE if the <em>directory</em> exists; otherwise returns FALSE.
|
|
(If a file with the same name is found this function will return
|
|
FALSE).
|
|
<p> <p>See also <a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists">QFile::exists</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="filePath"></a>QDir::filePath ( const <a href="qstring.html">QString</a> & fileName, bool acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns the path name of a file in the directory. Does <em>not</em>
|
|
check if the file actually exists in the directory. If the QDir is
|
|
relative the returned path name will also be relative. Redundant
|
|
multiple separators or "." and ".." directories in <em>fileName</em>
|
|
will not be removed (see <a href="#cleanDirPath">cleanDirPath</a>()).
|
|
<p> If <em>acceptAbsPath</em> is TRUE a <em>fileName</em> starting with a
|
|
separator "/" will be returned without change. If <em>acceptAbsPath</em>
|
|
is FALSE an absolute path will be prepended to the fileName and
|
|
the resultant string returned.
|
|
<p> <p>See also <a href="#absFilePath">absFilePath</a>(), <a href="#isRelative">isRelative</a>(), and <a href="#canonicalPath">canonicalPath</a>().
|
|
|
|
<h3 class=fn><a href="qdir.html#FilterSpec-enum">FilterSpec</a> <a name="filter"></a>QDir::filter () const
|
|
</h3>
|
|
|
|
<p> Returns the value set by <a href="#setFilter">setFilter</a>()
|
|
|
|
<h3 class=fn><a href="qdir.html">QDir</a> <a name="home"></a>QDir::home ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns the home directory.
|
|
<p> Under Windows the <tt>HOME</tt> environment variable is used. If this
|
|
does not exist the <tt>USERPROFILE</tt> environment variable is used. If
|
|
that does not exist the path is formed by concatenating the <tt>HOMEDRIVE</tt> and <tt>HOMEPATH</tt> environment variables. If they don't
|
|
exist the <a href="#rootDirPath">rootDirPath</a>() is used (this uses the <tt>SystemDrive</tt>
|
|
environment variable). If none of these exist "C:\" is used.
|
|
<p> Under non-Windows operating systems the <tt>HOME</tt> environment
|
|
variable is used if it exists, otherwise rootDirPath() is used.
|
|
<p> <p>See also <a href="#homeDirPath">homeDirPath</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="homeDirPath"></a>QDir::homeDirPath ()<tt> [static]</tt>
|
|
</h3>
|
|
|
|
<p> Returns the absolute path of the user's home directory.
|
|
<p> <p>See also <a href="#home">home</a>().
|
|
|
|
<h3 class=fn>bool <a name="isReadable"></a>QDir::isReadable () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns TRUE if the directory is readable <em>and</em> we can open files
|
|
by name; otherwise returns FALSE.
|
|
<p> <b>Warning:</b> A FALSE value from this function is not a guarantee that
|
|
files in the directory are not accessible.
|
|
<p> <p>See also <a href="qfileinfo.html#isReadable">QFileInfo::isReadable</a>().
|
|
|
|
<p>Examples: <a href="dirview-example.html#x1667">dirview/dirview.cpp</a> and <a href="fileiconview-example.html#x813">fileiconview/qfileiconview.cpp</a>.
|
|
<h3 class=fn>bool <a name="isRelative"></a>QDir::isRelative () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns TRUE if the directory path is relative to the current
|
|
directory and returns FALSE if the path is absolute (e.g. under
|
|
UNIX a path is relative if it does not start with a "/").
|
|
<p> <p>See also <a href="#convertToAbs">convertToAbs</a>().
|
|
|
|
<h3 class=fn>bool <a name="isRelativePath"></a>QDir::isRelativePath ( const <a href="qstring.html">QString</a> & path )<tt> [static]</tt>
|
|
</h3>
|
|
Returns TRUE if <em>path</em> is relative; returns FALSE if it is
|
|
absolute.
|
|
<p> <p>See also <a href="#isRelative">isRelative</a>().
|
|
|
|
<h3 class=fn>bool <a name="isRoot"></a>QDir::isRoot () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns TRUE if the directory is the root directory; otherwise
|
|
returns FALSE.
|
|
<p> Note: If the directory is a symbolic link to the root directory
|
|
this function returns FALSE. If you want to test for this use
|
|
<a href="#canonicalPath">canonicalPath</a>(), e.g.
|
|
<pre>
|
|
QDir d( "/tmp/root_link" );
|
|
d = d.<a href="#canonicalPath">canonicalPath</a>();
|
|
if ( d.<a href="#isRoot">isRoot</a>() )
|
|
<a href="qapplication.html#qWarning">qWarning</a>( "It is a root link" );
|
|
</pre>
|
|
|
|
<p> <p>See also <a href="#root">root</a>() and <a href="#rootDirPath">rootDirPath</a>().
|
|
|
|
<h3 class=fn>bool <a name="match"></a>QDir::match ( const <a href="qstring.html">QString</a> & filter, const <a href="qstring.html">QString</a> & fileName )<tt> [static]</tt>
|
|
</h3>
|
|
Returns TRUE if the <em>fileName</em> matches the wildcard (glob)
|
|
pattern <em>filter</em>; otherwise returns FALSE. The <em>filter</em> may
|
|
contain multiple patterns separated by spaces or semicolons.
|
|
<p> (See <a href="qregexp.html#wildcard-matching">QRegExp wildcard
|
|
matching.</a>)
|
|
<p>See also <a href="qregexp.html#match">QRegExp::match</a>().
|
|
|
|
<h3 class=fn>bool <a name="match-2"></a>QDir::match ( const <a href="qstringlist.html">QStringList</a> & filters, const <a href="qstring.html">QString</a> & fileName )<tt> [static]</tt>
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns TRUE if the <em>fileName</em> matches any of the wildcard (glob)
|
|
patterns in the list of <em>filters</em>; otherwise returns FALSE.
|
|
<p> (See <a href="qregexp.html#wildcard-matching">QRegExp wildcard
|
|
matching.</a>)
|
|
<p>See also <a href="qregexp.html#match">QRegExp::match</a>().
|
|
|
|
<h3 class=fn>bool <a name="matchAllDirs"></a>QDir::matchAllDirs () const
|
|
</h3>
|
|
|
|
<p> Returns the value set by <a href="#setMatchAllDirs">setMatchAllDirs</a>()
|
|
<p> <p>See also <a href="#setMatchAllDirs">setMatchAllDirs</a>().
|
|
|
|
<h3 class=fn>bool <a name="mkdir"></a>QDir::mkdir ( const <a href="qstring.html">QString</a> & dirName, bool acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Creates a directory.
|
|
<p> If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
|
|
will create the absolute directory; if <em>acceptAbsPath</em> is FALSE
|
|
any number of separators at the beginning of <em>dirName</em> will be
|
|
removed.
|
|
<p> Returns TRUE if successful; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#rmdir">rmdir</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="nameFilter"></a>QDir::nameFilter () const
|
|
</h3>
|
|
|
|
<p> Returns the string set by <a href="#setNameFilter">setNameFilter</a>()
|
|
|
|
<h3 class=fn>bool <a name="operator!-eq"></a>QDir::operator!= ( const <a href="qdir.html">QDir</a> & d ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Returns TRUE if directory <em>d</em> and this directory have different
|
|
paths or different sort or filter settings; otherwise returns
|
|
FALSE.
|
|
<p> Example:
|
|
<pre>
|
|
// The current directory is "/usr/local"
|
|
QDir d1( "/usr/local/bin" );
|
|
QDir d2( "bin" );
|
|
if ( d1 != d2 )
|
|
<a href="qapplication.html#qDebug">qDebug</a>( "They differ" );
|
|
</pre>
|
|
|
|
|
|
<h3 class=fn><a href="qdir.html">QDir</a> & <a name="operator-eq"></a>QDir::operator= ( const <a href="qdir.html">QDir</a> & d )
|
|
</h3>
|
|
Makes a copy of QDir <em>d</em> and assigns it to this QDir.
|
|
|
|
<h3 class=fn><a href="qdir.html">QDir</a> & <a name="operator-eq-2"></a>QDir::operator= ( const <a href="qstring.html">QString</a> & path )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Sets the directory path to be the given <em>path</em>.
|
|
|
|
<h3 class=fn>bool <a name="operator-eq-eq"></a>QDir::operator== ( const <a href="qdir.html">QDir</a> & d ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Returns TRUE if directory <em>d</em> and this directory have the same
|
|
path and their sort and filter settings are the same; otherwise
|
|
returns FALSE.
|
|
<p> Example:
|
|
<pre>
|
|
// The current directory is "/usr/local"
|
|
QDir d1( "/usr/local/bin" );
|
|
QDir d2( "bin" );
|
|
d2.<a href="#convertToAbs">convertToAbs</a>();
|
|
if ( d1 == d2 )
|
|
<a href="qapplication.html#qDebug">qDebug</a>( "They're the same" );
|
|
</pre>
|
|
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="operator[]"></a>QDir::operator[] ( int index ) const
|
|
</h3>
|
|
Returns the file name at position <em>index</em> in the list of file
|
|
names. Equivalent to <a href="#entryList">entryList</a>().at(index).
|
|
<p> Returns a <a href="qstring.html#QString-null">QString::null</a> if the <em>index</em> is out of range or if the
|
|
entryList() function failed.
|
|
<p> <p>See also <a href="#count">count</a>() and <a href="#entryList">entryList</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="path"></a>QDir::path () const<tt> [virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Returns the path, this may contain symbolic links, but never
|
|
contains redundant ".", ".." or multiple separators.
|
|
<p> The returned path can be either absolute or relative (see
|
|
<a href="#setPath">setPath</a>()).
|
|
<p> <p>See also <a href="#setPath">setPath</a>(), <a href="#absPath">absPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), <a href="#absFilePath">absFilePath</a>(), and <a href="#convertSeparators">convertSeparators</a>().
|
|
|
|
<h3 class=fn>void <a name="refresh"></a>QDir::refresh () const
|
|
</h3>
|
|
Refreshes the directory information.
|
|
|
|
<h3 class=fn>bool <a name="remove"></a>QDir::remove ( const <a href="qstring.html">QString</a> & fileName, bool acceptAbsPath = TRUE )<tt> [virtual]</tt>
|
|
</h3>
|
|
Removes the file, <em>fileName</em>.
|
|
<p> If <em>acceptAbsPath</em> is TRUE a path starting with separator "/"
|
|
will remove the file with the absolute path. If <em>acceptAbsPath</em>
|
|
is FALSE any number of separators at the beginning of <em>fileName</em>
|
|
will be removed and the resultant file name will be removed.
|
|
<p> Returns TRUE if the file is removed successfully; otherwise
|
|
returns FALSE.
|
|
|
|
<h3 class=fn>bool <a name="rename"></a>QDir::rename ( const <a href="qstring.html">QString</a> & oldName, const <a href="qstring.html">QString</a> & newName, bool acceptAbsPaths = TRUE )<tt> [virtual]</tt>
|
|
</h3>
|
|
Renames a file or directory.
|
|
<p> If <em>acceptAbsPaths</em> is TRUE a path starting with a separator
|
|
('/') will rename the file with the absolute path; if <em>acceptAbsPaths</em> is FALSE any number of separators at the beginning
|
|
of the names will be removed.
|
|
<p> Returns TRUE if successful; otherwise returns FALSE.
|
|
<p> On most file systems, <a href="#rename">rename</a>() fails only if <em>oldName</em> does not
|
|
exist or if <em>newName</em> and <em>oldName</em> are not on the same
|
|
partition. On Windows, rename() will fail if <em>newName</em> already
|
|
exists. However, there are also other reasons why rename() can
|
|
fail. For example, on at least one file system rename() fails if
|
|
<em>newName</em> points to an open file.
|
|
|
|
<p>Example: <a href="fileiconview-example.html#x814">fileiconview/qfileiconview.cpp</a>.
|
|
<h3 class=fn>bool <a name="rmdir"></a>QDir::rmdir ( const <a href="qstring.html">QString</a> & dirName, bool acceptAbsPath = TRUE ) const<tt> [virtual]</tt>
|
|
</h3>
|
|
Removes a directory.
|
|
<p> If <em>acceptAbsPath</em> is TRUE a path starting with a separator ('/')
|
|
will remove the absolute directory; if <em>acceptAbsPath</em> is FALSE
|
|
any number of separators at the beginning of <em>dirName</em> will be
|
|
removed.
|
|
<p> The directory must be empty for <a href="#rmdir">rmdir</a>() to succeed.
|
|
<p> Returns TRUE if successful; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#mkdir">mkdir</a>().
|
|
|
|
<h3 class=fn><a href="qdir.html">QDir</a> <a name="root"></a>QDir::root ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns the root directory.
|
|
<p> <p>See also <a href="#rootDirPath">rootDirPath</a>() and <a href="#drives">drives</a>().
|
|
|
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="rootDirPath"></a>QDir::rootDirPath ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns the absolute path for the root directory.
|
|
<p> For UNIX operating systems this returns "/". For Windows file
|
|
systems this normally returns "c:/".
|
|
<p> <p>See also <a href="#root">root</a>() and <a href="#drives">drives</a>().
|
|
|
|
<h3 class=fn>char <a name="separator"></a>QDir::separator ()<tt> [static]</tt>
|
|
</h3>
|
|
Returns the native directory separator; "/" under UNIX (including
|
|
Mac OS X) and "\" under Windows.
|
|
<p> You do not need to use this function to build file paths. If you
|
|
always use "/", Qt will translate your paths to conform to the
|
|
underlying operating system.
|
|
|
|
<h3 class=fn>bool <a name="setCurrent"></a>QDir::setCurrent ( const <a href="qstring.html">QString</a> & path )<tt> [static]</tt>
|
|
</h3>
|
|
Sets the application's current working directory to <em>path</em>.
|
|
Returns TRUE if the directory was successfully changed; otherwise
|
|
returns FALSE.
|
|
|
|
<h3 class=fn>void <a name="setFilter"></a>QDir::setFilter ( int filterSpec )<tt> [virtual]</tt>
|
|
</h3>
|
|
Sets the filter used by <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>() to <em>filterSpec</em>. The filter is used to specify the kind of files that
|
|
should be returned by entryList() and entryInfoList(). See
|
|
<a href="#FilterSpec-enum">QDir::FilterSpec</a>.
|
|
<p> <p>See also <a href="#filter">filter</a>() and <a href="#setNameFilter">setNameFilter</a>().
|
|
|
|
<h3 class=fn>void <a name="setMatchAllDirs"></a>QDir::setMatchAllDirs ( bool enable )<tt> [virtual]</tt>
|
|
</h3>
|
|
If <em>enable</em> is TRUE then all directories are included (e.g. in
|
|
<a href="#entryList">entryList</a>()), and the <a href="#nameFilter">nameFilter</a>() is only applied to the files.
|
|
If <em>enable</em> is FALSE then the nameFilter() is applied to both
|
|
directories and files.
|
|
<p> <p>See also <a href="#matchAllDirs">matchAllDirs</a>().
|
|
|
|
<h3 class=fn>void <a name="setNameFilter"></a>QDir::setNameFilter ( const <a href="qstring.html">QString</a> & nameFilter )<tt> [virtual]</tt>
|
|
</h3>
|
|
Sets the name filter used by <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>() to <em>nameFilter</em>.
|
|
<p> The <em>nameFilter</em> is a wildcard (globbing) filter that understands
|
|
"*" and "?" wildcards. (See <a href="qregexp.html#wildcard-matching">QRegExp wildcard matching</a>.) You may specify several filter
|
|
entries all separated by a single space " " or by a semi-colon
|
|
";".
|
|
<p> For example, if you want entryList() and entryInfoList() to list
|
|
all files ending with either ".cpp" or ".h", you would use either
|
|
dir.<a href="#setNameFilter">setNameFilter</a>("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h").
|
|
<p> <p>See also <a href="#nameFilter">nameFilter</a>() and <a href="#setFilter">setFilter</a>().
|
|
|
|
<h3 class=fn>void <a name="setPath"></a>QDir::setPath ( const <a href="qstring.html">QString</a> & path )<tt> [virtual]</tt>
|
|
</h3>
|
|
Sets the path of the directory to <em>path</em>. The path is cleaned of
|
|
redundant ".", ".." and of multiple separators. No check is made
|
|
to ensure that a directory with this path exists.
|
|
<p> The path can be either absolute or relative. Absolute paths begin
|
|
with the directory separator "/" (optionally preceded by 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. An example of an absolute path is the string
|
|
"/tmp/quartz", a relative path might look like "src/fatlib".
|
|
<p> <p>See also <a href="#path">path</a>(), <a href="#absPath">absPath</a>(), <a href="#exists">exists</a>(), <a href="#cleanDirPath">cleanDirPath</a>(), <a href="#dirName">dirName</a>(), <a href="#absFilePath">absFilePath</a>(), <a href="#isRelative">isRelative</a>(), and <a href="#convertToAbs">convertToAbs</a>().
|
|
|
|
<h3 class=fn>void <a name="setSorting"></a>QDir::setSorting ( int sortSpec )<tt> [virtual]</tt>
|
|
</h3>
|
|
Sets the sort order used by <a href="#entryList">entryList</a>() and <a href="#entryInfoList">entryInfoList</a>().
|
|
<p> The <em>sortSpec</em> is specified by OR-ing values from the enum
|
|
<a href="#SortSpec-enum">QDir::SortSpec</a>.
|
|
<p> <p>See also <a href="#sorting">sorting</a>() and <a href="#SortSpec-enum">SortSpec</a>.
|
|
|
|
<h3 class=fn><a href="qdir.html#SortSpec-enum">SortSpec</a> <a name="sorting"></a>QDir::sorting () const
|
|
</h3>
|
|
|
|
<p> Returns the value set by <a href="#setSorting">setSorting</a>()
|
|
<p> <p>See also <a href="#setSorting">setSorting</a>() and <a href="#SortSpec-enum">SortSpec</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>
|