From bcbaeff0332e30f020f031b99efcc69d9707f962 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 11 Aug 2009 18:11:20 +0200 Subject: 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 --- src/corelib/io/qfsfileengine_unix.cpp | 10 +++++++--- 1 file 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"; -- cgit v0.12