| struct TemporaryFileHandle |
| std::filesystem::path path; |
| // Creates a temporary file with the contents provided, removes it on |
| explicit TemporaryFileHandle(std::string_view sampleData) : |
| path(std::filesystem::temp_directory_path() / |
| "bmcweb_http_response_test_XXXXXXXXXXX") |
| stringPath = path.string(); |
| int fd = mkstemp(stringPath.data()); |
| EXPECT_EQ(write(fd, sampleData.data(), sampleData.size()), |
| TemporaryFileHandle(const TemporaryFileHandle&) = delete; |
| TemporaryFileHandle(TemporaryFileHandle&&) = delete; |
| TemporaryFileHandle& operator=(const TemporaryFileHandle&) = delete; |
| TemporaryFileHandle& operator=(TemporaryFileHandle&&) = delete; |
| std::filesystem::remove(path); |