summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-11-30 14:28:47 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-11-30 15:04:11 (GMT)
commitb5bf6d68bdde5f5db1d72179f4e20dc1e21d20c4 (patch)
tree04da04f42f5bdb7800e637b5eea717a667420260 /tests
parent132eccca92a90e4d67ba8b5a4052384a2b2cfdf9 (diff)
downloadQt-b5bf6d68bdde5f5db1d72179f4e20dc1e21d20c4.zip
Qt-b5bf6d68bdde5f5db1d72179f4e20dc1e21d20c4.tar.gz
Qt-b5bf6d68bdde5f5db1d72179f4e20dc1e21d20c4.tar.bz2
Unix: Avoid stat() when opening a file
The open() syscall can open directories for reading, which we in QFile and file engines don't support. However, there is no need for stat() to find out if it is a directory if we open() with a write flag because then the syscall will fail anyway. Reviewed-by: joao
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index cf46ce1..7ee5665 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -2783,10 +2783,21 @@ void tst_QFile::mapOpenMode()
void tst_QFile::openDirectory()
{
- QFile f1("resources");
+ QFile f1(SRCDIR "resources");
+ // it's a directory, it must exist
+ QVERIFY(f1.exists());
+
+ // ...but not be openable
QVERIFY(!f1.open(QIODevice::ReadOnly));
f1.close();
QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered));
+ f1.close();
+ QVERIFY(!f1.open(QIODevice::ReadWrite));
+ f1.close();
+ QVERIFY(!f1.open(QIODevice::WriteOnly));
+ f1.close();
+ QVERIFY(!f1.open(QIODevice::WriteOnly|QIODevice::Unbuffered));
+ f1.close();
}
void tst_QFile::openStandardStreams()