7#include <packager/file/file_test_util.h>
19#include <system_error>
23std::string generate_unique_temp_path() {
27 auto temp_path_template =
28 std::filesystem::temp_directory_path() /
"packager-test.XXXXXX";
29 std::string temp_path_template_string = temp_path_template.string();
33 _mktemp(temp_path_template_string.data());
39 int fd = mkstemp(temp_path_template_string.data());
42 return temp_path_template_string;
45void delete_file(
const std::string& path) {
47 std::filesystem::remove(std::filesystem::u8path(path), ec);
51TempFile::TempFile() : path_(generate_unique_temp_path()) {}
53TempFile::~TempFile() {
55 std::filesystem::remove(std::filesystem::u8path(path_), ec);
All the methods that are virtual are virtual for mocking.