From 01cfa8b85b93589476ce3dbff5f9f207ad737abf Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 2 May 2022 09:40:03 +0200 Subject: [PATCH] Add find_file from libdcp. --- test/test.cc | 14 ++++++++++++++ test/test.h | 1 + 2 files changed, 15 insertions(+) diff --git a/test/test.cc b/test/test.cc index e61387132..21f27c36c 100644 --- a/test/test.cc +++ b/test/test.cc @@ -937,3 +937,17 @@ ConfigRestorer::~ConfigRestorer() setup_test_config(); } + +boost::filesystem::path +find_file (boost::filesystem::path dir, string filename_part) +{ + boost::optional found; + for (auto i: boost::filesystem::directory_iterator(dir)) { + if (i.path().filename().string().find(filename_part) != string::npos) { + BOOST_REQUIRE (!found); + found = i; + } + } + BOOST_REQUIRE (found); + return *found; +} diff --git a/test/test.h b/test/test.h index 43bccd52b..10113b662 100644 --- a/test/test.h +++ b/test/test.h @@ -76,6 +76,7 @@ extern void make_random_file (boost::filesystem::path path, size_t size); extern void make_and_verify_dcp (std::shared_ptr film, std::vector ignore = {}); extern void check_int_close (int a, int b, int d); extern void check_int_close (std::pair, std::pair, int d); +extern boost::filesystem::path find_file (boost::filesystem::path dir, std::string filename_part); class LogSwitcher -- 2.30.2