MCPcopy Create free account
hub / github.com/USBGuard/usbguard / createFile

Function createFile

src/Tests/Regression/github-PR209-config-parser.cpp:34–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32using namespace usbguard;
33
34static std::string createFile(const std::vector<std::string> lines)
35{
36 std::string filepath("/tmp/usbguard-test.XXXXXX");
37 const int fd = ::mkstemp(&filepath[0]);
38
39 if (fd < 0) {
40 throw std::runtime_error("cannot create temporary file");
41 }
42
43 for (const auto& line : lines) {
44 ::write(fd, line.c_str(), line.size());
45 ::write(fd, "\n", 1);
46 }
47
48 ::close(fd);
49 return filepath;
50}
51
52TEST_CASE("Regression: GitHub PR #209", "[regression]")
53{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected