11 namespace fs = std::filesystem;
16 const auto suffix = std::chrono::steady_clock::now().time_since_epoch().count();
17 path = fs::temp_directory_path() / (
"acmxvk-resource-paths-" + std::to_string(suffix));
18 fs::create_directories(
path);
22 std::error_code error;
23 fs::remove_all(
path, error);
33 fs::create_directories(path.parent_path());
34 std::ofstream output(path);
36 throw std::runtime_error(
"could not create test file: " + path.string());
41 void expect_equal(
const fs::path &actual,
const fs::path &expected,
const std::string &label) {
42 if (actual != expected) {
43 throw std::runtime_error(label +
": expected " + expected.string() +
", received " + actual.string());
51 const fs::path resource_directory = temporary.path /
"share/acmxvk";
52 const fs::path mxvk_shaders = temporary.path /
"share/mxvk/shaders";
53 const fs::path flip = resource_directory /
"shaders/flip.frag.spv";
54 const fs::path crossfade = resource_directory /
"shaders/xfade/xfade_01_linear.frag.spv";
55 const fs::path model = resource_directory /
"models/cube.obj";
56 const fs::path font = resource_directory /
"data/font.ttf";
72 throw std::runtime_error(
"parent traversal was accepted");
75 throw std::runtime_error(
"absolute resource path was accepted");
78 bool rejected_index =
false;
81 }
catch (
const std::out_of_range &) {
82 rejected_index =
true;
84 if (!rejected_index) {
85 throw std::runtime_error(
"invalid crossfade index was accepted");
87 }
catch (
const std::exception &error) {
88 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)
fs::path mxvk_shader_directory(const Options &options)
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