summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2009-08-11 16:11:20 (GMT)
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-08-11 16:20:22 (GMT)
commitbcbaeff0332e30f020f031b99efcc69d9707f962 (patch)
tree8f8535022d91ff67cf257dee9cf65ff632bca2c7
parentc9fb4ac3483c492f32e4f42987935478d4e89eb8 (diff)
downloadQt-bcbaeff0332e30f020f031b99efcc69d9707f962.zip
Qt-bcbaeff0332e30f020f031b99efcc69d9707f962.tar.gz
Qt-bcbaeff0332e30f020f031b99efcc69d9707f962.tar.bz2
replace QFile::exists() by QT_STAT() respectively
which is a bit faster since it doesn't creates new file engine instance Merge-request: 1176 Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 075aa7c..cde5272 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -76,10 +76,14 @@ static QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QString &
if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) {
mode = "rb";
if (flags & QIODevice::WriteOnly) {
- if (!fileName.isEmpty() &&QFile::exists(fileName))
- mode = "rb+";
- else
+ QT_STATBUF statBuf;
+ if (!fileName.isEmpty()
+ && QT_STAT(QFile::encodeName(fileName), &statBuf) == 0
+ && (statBuf.st_mode & S_IFMT) == S_IFREG) {
+ mode += "+";
+ } else {
mode = "wb+";
+ }
}
} else if (flags & QIODevice::WriteOnly) {
mode = "wb";