summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)