Skip to content

Commit

Permalink
Use tmpnam_s for temporary filename on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsheep committed Aug 11, 2020
1 parent 69afa6e commit ea1590d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ bool Helpers::starts_with(const std::string &str, const std::string &starting)
std::string Helpers::temporary_filename()
{
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
return std::tmpnam(nullptr);
char filename[L_tmpnam_s];
tmpnam_s(filename, L_tmpnam_s);

return filename;
#else
auto filename = fs::temp_directory_path().u8string() + "XXXXXXXXXXXXXXXX";
mkstemp(filename.data());
Expand Down

0 comments on commit ea1590d

Please sign in to comment.