34 #include <glog/logging.h>
51 char temp_dir_path[MAX_PATH + 1] = {
'\0'};
52 char temp_file_path[MAX_PATH + 1] = {
'\0'};
53 ::GetTempPathA(
sizeof(temp_dir_path), temp_dir_path);
54 const UINT success = ::GetTempFileNameA(temp_dir_path,
prefix.c_str(),
58 LOG(
ERROR) <<
"Unable to create a temporary file in " << temp_dir_path;
60 errno_t
err = _sopen_s(&fhandle, temp_file_path, _O_BINARY, _SH_DENYNO,
61 _S_IREAD | _S_IWRITE);
66 const int max_path = 4096;
67 char temp_file_path[max_path] = {0};
68 if (
prefix.length() >= 512) {
69 LOG(
ERROR) <<
"Unable to create a temporary file with prefix "
93 strcat(temp_file_path,
"/sdcard/");
95 strcat(temp_file_path,
"/tmp/");
97 #endif // OS_LINUX_ANDROID
98 strcat(temp_file_path,
prefix.c_str());
99 strcat(temp_file_path,
".XXXXXX");
100 fhandle = mkstemp(temp_file_path);
108 LOG(
ERROR) <<
"Unable to open temporary file " << temp_file_path;
110 filename = temp_file_path;