file_util: Remove tmpnam() usage in MSVC.

Replace with windows/MSVC specific tmpnam_s().

Change-Id: I8c49e37c72630ebb14ea3c7734b96d0f79968772
This commit is contained in:
Tom Finegan
2016-03-08 10:02:25 -08:00
parent b9dc4ac09c
commit e09251510f

View File

@@ -12,6 +12,7 @@
#include <unistd.h> // close()
#endif
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <ios>
@@ -29,9 +30,12 @@ std::string GetTempFileName() {
}
return std::string();
#else
// TODO(tomfinegan): Add the MSVC version of mkstemp() to quiet the MSVC
// version of the security warning.
return std::tmpnam(nullptr);
char tmp_file_name[_MAX_PATH];
errno_t err = tmpnam_s(tmp_file_name);
if (err == 0) {
return std::string(tmp_file_name);
}
return std::string();
#endif
}