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>
This commit is contained in:
parent
1a3f340d0e
commit
3ae2387f37
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user