11 namespace fs = std::filesystem;
16 const auto suffix = std::chrono::steady_clock::now()
19 path = fs::temp_directory_path() /
20 (
"acmxvk-output-paths-" + std::to_string(suffix));
21 fs::create_directories(
path);
25 std::error_code error;
26 fs::remove_all(
path, error);
35 void expect(
bool condition,
const std::string &message) {
37 throw std::runtime_error(message);
42 const std::string &message) {
43 expect(path.filename().string().ends_with(suffix), message);
51 fs::path(
".") /
"video_file-movie.mp4-png",
52 "relative output directory is incorrect");
54 (temporary.path /
"movie.mp4").string(),
"generate") ==
55 temporary.path /
"video_file-movie.mp4-generate",
56 "parent output directory was not retained");
58 const fs::path output_directory = temporary.path /
"nested/frames";
60 expect(fs::is_directory(output_directory),
61 "output directory was not created");
63 output_directory /
"frame-00000042.png",
64 "numbered PNG frame path is incorrect");
68 "PNG snapshot extension is incorrect");
71 "WebP snapshot extension is incorrect");
74 "TIFF snapshot extension is incorrect");
77 "raw snapshot extension is incorrect");
79 std::uint64_t counter = 7;
80 const auto timestamp = std::chrono::system_clock::from_time_t(0);
82 temporary.path, 1920, 1080, counter,
85 "snapshot dimensions or counter are incorrect");
86 std::ofstream(first) <<
"collision";
88 temporary.path, 1920, 1080, counter,
90 expect(counter == 8,
"snapshot collision did not advance the counter");
92 "collision-safe snapshot path is incorrect");
94 const fs::path regular_file = temporary.path /
"not-a-directory";
95 std::ofstream(regular_file) <<
"file";
96 bool rejected_file =
false;
99 }
catch (
const std::runtime_error &) {
100 rejected_file =
true;
102 expect(rejected_file,
"regular file was accepted as an output directory");
103 }
catch (
const std::exception &error) {
104 std::cerr <<
"output path test failed: " << error.what() <<
'\n';
int main(int argc, char **argv)
Application entry point.
TemporaryDirectory & operator=(const TemporaryDirectory &)=delete
TemporaryDirectory(const TemporaryDirectory &)=delete
fs::path snapshot_path(const fs::path &directory, std::uint32_t width, std::uint32_t height, std::uint64_t &counter, SnapshotFormat format, std::chrono::system_clock::time_point timestamp)
fs::path output_frame_directory(const std::string &filename, std::string_view suffix)
fs::path frame_path(const fs::path &directory, std::uint64_t index)
void create_output_directory(const fs::path &directory)
std::string_view snapshot_extension(SnapshotFormat format) noexcept
void expect(bool condition, const std::string &message)
void expect_suffix(const fs::path &path, std::string_view suffix, const std::string &message)