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