From 3ae2387f375798a983b6d052723f10fc88b63da0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 13 Jul 2015 15:58:51 -0700 Subject: QTemporaryDir: fail early if the error isn't EEXIST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, stat -c on Linux (enabling this code path): % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 0.00 0.000000 0 256 256 mkdir After: 0.00 0.000000 0 1 1 mkdir “To err is human, to persist in error is diabolical” - Georges Canguilhem “The definition of insanity is repeating the same mistakes over and over again and expecting different results.” - Albert Einstein, Mark Twain or Benjamin Franklin (all mis-attributed) Change-Id: Ib306f8f647014b399b87ffff13f0a3c155053e6a Reviewed-by: Oswald Buddenhagen Reviewed-by: David Faure --- src/corelib/io/qtemporarydir.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp index 32c3d92dca..c7150d7b33 100644 --- a/src/corelib/io/qtemporarydir.cpp +++ b/src/corelib/io/qtemporarydir.cpp @@ -135,6 +135,15 @@ QPair q_mkdtemp(char *templateName) } return qMakePair(QFile::decodeName(templateName), true); } +# ifdef Q_OS_WIN + const int exists = ERROR_ALREADY_EXISTS; + int code = GetLastError(); +# else + const int exists = EEXIST; + int code = errno; +# endif + if (code != exists) + return qMakePair(qt_error_string(code), false); } return qMakePair(qt_error_string(), false); } -- cgit v1.2.3