11 namespace fs = std::filesystem;
16 const auto suffix = std::chrono::steady_clock::now()
19 path = fs::temp_directory_path() /
20 (
"acmxvk-resource-paths-" + std::to_string(suffix));
21 fs::create_directories(
path);
25 std::error_code error;
26 fs::remove_all(
path, error);
36 fs::create_directories(path.parent_path());
37 std::ofstream output(path);
39 throw std::runtime_error(
"could not create test file: " +
45 void expect_equal(
const fs::path &actual,
const fs::path &expected,
46 const std::string &label) {
47 if (actual != expected) {
48 throw std::runtime_error(label +
": expected " +
49 expected.string() +
", received " +
58 const fs::path flip = temporary.path /
"shaders/flip.frag.spv";
59 const fs::path crossfade =
60 temporary.path /
"shaders/xfade/xfade_01_linear.frag.spv";
61 const fs::path model = temporary.path /
"models/cube.obj";
62 const fs::path font = temporary.path /
"data/font.ttf";
71 "user resource shader");
73 "user resource crossfade");
75 "user resource model");
77 "user resource font");
80 throw std::runtime_error(
"parent traversal was accepted");
83 throw std::runtime_error(
"absolute resource path was accepted");
86 bool rejected_index =
false;
90 }
catch (
const std::out_of_range &) {
91 rejected_index =
true;
93 if (!rejected_index) {
94 throw std::runtime_error(
"invalid crossfade index was accepted");
96 }
catch (
const std::exception &error) {
97 std::cerr <<
"resource 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 default_model_path(const Options &options)
fs::path crossfade_shader_path(const Options &options, std::size_t shader_index)
constexpr std::array< std::string_view, 35 > CROSSFADE_NAMES
fs::path overlay_font_path(const Options &options)
fs::path flip_shader_path(const Options &options)
fs::path find_resource(const Options &options, const fs::path &relative_path)
void expect_equal(const fs::path &actual, const fs::path &expected, const std::string &label)
void create_file(const fs::path &path)
std::string resource_directory