summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r--src/corelib/io/qdir.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index a8826b331a..b89e665d20 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -329,7 +329,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt
return r < 0;
}
-inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l,
+inline void QDirPrivate::sortFileList(QDir::SortFlags sort, const QFileInfoList &l,
QStringList *names, QFileInfoList *infos)
{
// names and infos are always empty lists or 0 here
@@ -408,7 +408,7 @@ inline void QDirPrivate::initFileEngine()
\snippet code/src_corelib_io_qdir.cpp 0
On Windows, the second example above will be translated to
- \c{C:\Documents and Settings} when used to access files.
+ \c{C:\Users} when used to access files.
Examples of relative paths:
@@ -418,6 +418,9 @@ inline void QDirPrivate::initFileEngine()
a QDir is using a relative or an absolute file path. Call
makeAbsolute() to convert a relative QDir to an absolute one.
+ \note Paths starting with a colon (\e{:}) are always considered
+ absolute, as they denote a QResource.
+
\section1 Navigation and Directory Operations
A directory's path can be obtained with the path() function, and
@@ -551,6 +554,10 @@ inline void QDirPrivate::initFileEngine()
\snippet qdir-listfiles/main.cpp 0
+ \section1 Platform Specific Issues
+
+ \include android-content-uri-limitations.qdocinc
+
\sa QFileInfo, QFile, QFileDialog, QCoreApplication::applicationDirPath(), {Find Files Example}
*/
@@ -670,8 +677,12 @@ QString QDir::path() const
QString QDir::absolutePath() const
{
const QDirPrivate* d = d_ptr.constData();
- d->resolveAbsoluteEntry();
- return d->absoluteDirEntry.filePath();
+ if (!d->fileEngine) {
+ d->resolveAbsoluteEntry();
+ return d->absoluteDirEntry.filePath();
+ }
+
+ return d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
}
/*!
@@ -714,7 +725,9 @@ QString QDir::canonicalPath() const
QString QDir::dirName() const
{
const QDirPrivate* d = d_ptr.constData();
- return d->dirEntry.fileName();
+ if (!d_ptr->fileEngine)
+ return d->dirEntry.fileName();
+ return d->fileEngine->fileName(QAbstractFileEngine::BaseName);
}
@@ -1034,6 +1047,9 @@ bool QDir::cd(const QString &dirName)
otherwise returns \c false. Note that the logical cdUp() operation is
not performed if the new directory does not exist.
+ \note On Android, this is not supported for content URIs. For more information,
+ see \l {Android: DocumentFile.getParentFile()}{DocumentFile.getParentFile()}.
+
\sa cd(), isReadable(), exists(), path()
*/
bool QDir::cdUp()
@@ -1243,9 +1259,9 @@ QDir::Filters QDir::filter() const
files that the application can read, write, or execute, and symlinks
to such files/directories can be listed.
- To retrieve the permissons for a directory, use the
+ To retrieve the permissions for a directory, use the
entryInfoList() function to get the associated QFileInfo objects
- and then use the QFileInfo::permissons() to obtain the permissions
+ and then use the QFileInfo::permissions() to obtain the permissions
and ownership for each file.
*/
@@ -1709,6 +1725,9 @@ bool QDir::isRoot() const
Returns \c true if the directory's path is absolute; otherwise
returns \c false. See isAbsolutePath().
+ \note Paths starting with a colon (\e{:}) are always considered
+ absolute, as they denote a QResource.
+
\sa isRelative(), makeAbsolute(), cleanPath()
*/
@@ -1718,9 +1737,8 @@ bool QDir::isRoot() const
Returns \c true if \a path is absolute; returns \c false if it is
relative.
- \note If \a path starts with ':', this function will return \c true
- because paths starting with ':' are treated specially as they denote
- a QResource.
+ \note Paths starting with a colon (\e{:}) are always considered
+ absolute, as they denote a QResource.
\sa isAbsolute(), isRelativePath(), makeAbsolute(), cleanPath(), QResource
*/
@@ -1730,6 +1748,9 @@ bool QDir::isRoot() const
false. (Under Unix a path is relative if it does not start with a
"/").
+ \note Paths starting with a colon (\e{:}) are always considered
+ absolute, as they denote a QResource.
+
\sa makeAbsolute(), isAbsolute(), isAbsolutePath(), cleanPath()
*/
bool QDir::isRelative() const
@@ -1953,7 +1974,8 @@ bool QDir::isEmpty(Filters filters) const
Returns a list of the root directories on this system.
On Windows this returns a list of QFileInfo objects containing "C:/",
- "D:/", etc. On other operating systems, it returns a list containing
+ "D:/", etc. This does not return drives with ejectable media that are empty.
+ On other operating systems, it returns a list containing
just one root directory (i.e. "/").
\sa root(), rootPath()
@@ -2003,6 +2025,8 @@ QChar QDir::separator()
Returns \c true if the directory was successfully changed; otherwise
returns \c false.
+ \snippet code/src_corelib_io_qdir.cpp 16
+
\sa current(), currentPath(), home(), root(), temp()
*/
bool QDir::setCurrent(const QString &path)
@@ -2396,6 +2420,9 @@ QString QDir::cleanPath(const QString &path)
Returns \c true if \a path is relative; returns \c false if it is
absolute.
+ \note Paths starting with a colon (\e{:}) are always considered
+ absolute, as they denote a QResource.
+
\sa isRelative(), isAbsolutePath(), makeAbsolute()
*/
bool QDir::isRelativePath(const QString &path)