summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Brachaczek <b.brachaczek@gmail.com>2013-12-29 04:01:27 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-20 12:20:45 +0100
commit7ffce3fb0bb0bd42aa359467d66691ef8a4762df (patch)
tree8313d0e09f0ebd617def0c45b47a2466a9b4b5fc
parent446f9f2812e9f351caca11750792dadbd4e53662 (diff)
Fix cd(), cdUp() QDir member functions docs regarding nonreadable dirs
The documentation implies that cd() and cdUp() functions return false if the new directory is not readable, but that is not the case. It is an obvious mistake in the documentation, because cd'ing into a nonreadable directory is perfectly valid. Provided also with a test to verify that cd() actually returns true with nonreadable directories. Change-Id: I4aa3e859b35c64266df510a203574e3701aea77c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/io/qdir.cpp4
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp19
2 files changed, 21 insertions, 2 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 43db2ec1fe..015f4cfe14 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -855,7 +855,7 @@ QString QDir::fromNativeSeparators(const QString &pathName)
/*!
Changes the QDir's directory to \a dirName.
- Returns \c true if the new directory exists and is readable;
+ Returns \c true if the new directory exists;
otherwise returns \c false. Note that the logical cd() operation is
not performed if the new directory does not exist.
@@ -923,7 +923,7 @@ bool QDir::cd(const QString &dirName)
Changes directory by moving one directory up from the QDir's
current directory.
- Returns \c true if the new directory exists and is readable;
+ Returns \c true if the new directory exists;
otherwise returns \c false. Note that the logical cdUp() operation is
not performed if the new directory does not exist.
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index fbb21e4e9a..96be5065d6 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -193,6 +193,8 @@ private slots:
void isReadable();
+ void cdNonreadable();
+
void cdBelowRoot();
private:
@@ -1990,6 +1992,23 @@ void tst_QDir::isReadable()
#endif
}
+void tst_QDir::cdNonreadable()
+{
+#ifdef Q_OS_UNIX
+ if (::getuid() == 0)
+ QSKIP("Running this test as root doesn't make sense");
+
+ QDir dir;
+ QVERIFY(dir.mkdir("nonreadabledir2"));
+ QVERIFY(0 == ::chmod("nonreadabledir2", S_IWUSR | S_IXUSR));
+ QVERIFY(dir.cd("nonreadabledir2"));
+ QVERIFY(!dir.isReadable());
+ QVERIFY(dir.cd(".."));
+ QVERIFY(0 == ::chmod("nonreadabledir2", S_IRUSR | S_IWUSR | S_IXUSR));
+ QVERIFY(dir.rmdir("nonreadabledir2"));
+#endif
+}
+
void tst_QDir::cdBelowRoot()
{
#if defined (Q_OS_UNIX)