Issue #18849: Fixed a Windows-specific tempfile bug where collision with an
existing directory caused mkstemp and related APIs to fail instead of
retrying. Report and fix by Vlad Shcherbina.