diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-07-13 15:58:51 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-08-01 01:36:58 +0000 |
commit | 3ae2387f375798a983b6d052723f10fc88b63da0 (patch) | |
tree | 09f2e0787b2f44ff7a4dc27fe266a17cbdbde6e9 | |
parent | 1a3f340d0efb3fad3fda8fffed3d268a12d9a60d (diff) | |
download | qtbase-3ae2387f375798a983b6d052723f10fc88b63da0.tar.gz |
QTemporaryDir: fail early if the error isn't EEXIST
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 <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r-- | src/corelib/io/qtemporarydir.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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<QString, bool> 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); } |