Add find_file from libdcp.
[dcpomatic.git] / test / test.cc
index e61387132f12fce7e61e558a445743366ef2ddae..21f27c36c31fbc28596a060d4f661c5aa8eab218 100644 (file)
@@ -937,3 +937,17 @@ ConfigRestorer::~ConfigRestorer()
        setup_test_config();
 }
 
+
+boost::filesystem::path
+find_file (boost::filesystem::path dir, string filename_part)
+{
+       boost::optional<boost::filesystem::path> 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;
+}