MCPcopy Create free account
hub / github.com/assimp/assimp / MakeTmpFile

Function MakeTmpFile

test/unit/UnitTestFileGenerator.h:64–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63#include <io.h>
64inline FILE* MakeTmpFile(char* tmplate, size_t len, std::string &tmpName) {
65 size_t tmpLen = len + 1;
66 char *pathtemplate = new char[tmpLen];
67 strcpy_s(pathtemplate, tmpLen, tmplate);
68 int err_code = _mktemp_s(pathtemplate, tmpLen);
69 EXPECT_EQ(err_code, 0);
70 EXPECT_NE(pathtemplate, nullptr);
71 if(pathtemplate == nullptr) {
72 delete[] pathtemplate;
73 return nullptr;
74 }
75 errno_t err;
76 FILE *fs{nullptr};
77 err = fopen_s(&fs, pathtemplate, "w+");
78 EXPECT_EQ(0, err);
79 tmpName = pathtemplate;
80 EXPECT_NE(fs, nullptr);
81 delete[] pathtemplate;
82
83 return fs;
84}
85#elif defined(__GNUC__) || defined(__clang__)
86inline FILE *MakeTmpFile(char *tmplate, size_t len, std::string &tmpName) {
87 auto fd = mkstemp(tmplate);

Callers 2

TEST_FFunction · 0.85
TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected