summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/test/support/platform_support.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h
index 9ae2ae7cb2e..7b1ee8a8db4 100644
--- a/libcxx/test/support/platform_support.h
+++ b/libcxx/test/support/platform_support.h
@@ -50,13 +50,23 @@ inline
std::string
get_temp_file_name()
{
- std::string s("temp.XXXXXX");
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- _mktemp(&s[0]);
+ char Path[MAX_PATH+1];
+ char FN[MAX_PATH+1];
+ do { } while (0 == GetTempPath(MAX_PATH+1, Path));
+ do { } while (0 == GetTempFileName(Path, "libcxx", 0, FN));
+ return FN;
#else
- mktemp(&s[0]);
+ std::string Name;
+ int FD = -1;
+ do {
+ Name = "libcxx.XXXXXX";
+ FD = mkstemp(&Name[0]);
+ assert(errno != EINVAL && "Something is wrong with the mkstemp's argument");
+ } while (FD == -1 || errno == EEXIST);
+ close(FD);
+ return Name;
#endif
- return s;
}
#endif // PLATFORM_SUPPORT_H
OpenPOWER on IntegriCloud