| 87 | } |
| 88 | |
| 89 | path CreateTempFileWithData(const span<const byte> data) |
| 90 | { |
| 91 | const auto [fd, filename] = OpenTempFile(); |
| 92 | |
| 93 | const size_t count = write(fd, data.data(), data.size()); |
| 94 | EXPECT_EQ(count, data.size()) << "Couldn't create temporary file '" << string(filename) << "'"; |
| 95 | close(fd); |
| 96 | |
| 97 | return path(filename); |
| 98 | } |
| 99 | |
| 100 | // TODO Replace old-fashinoned C I/O by C++ streams I/O. |
| 101 | // This also avoids potential issues with data type sizes and there is no need for c_str(). |
no test coverage detected