diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-19 22:23:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-19 22:23:05 +0100 |
| commit | 0b66748421b751b1863ce86f98ab449c8e8e87fc (patch) | |
| tree | 9bafd444c8254d5bd307b8bb2b8c07f37011c947 | |
| parent | 9f2595c22d10a64f561379847192ad64001ac9f1 (diff) | |
Find missing files better in projects coming from other platforms (#2935).
| -rw-r--r-- | src/lib/find_missing.cc | 15 | ||||
| m--------- | test/data | 0 | ||||
| -rw-r--r-- | test/find_missing_test.cc | 23 |
3 files changed, 37 insertions, 1 deletions
diff --git a/src/lib/find_missing.cc b/src/lib/find_missing.cc index 65776d02e..af91b3682 100644 --- a/src/lib/find_missing.cc +++ b/src/lib/find_missing.cc @@ -27,6 +27,7 @@ using std::map; using std::shared_ptr; +using std::string; using std::vector; @@ -42,7 +43,19 @@ search_by_name(Replacements& replacement_paths, boost::filesystem::path director if (dcp::filesystem::is_regular_file(candidate.path())) { for (auto& replacement: replacement_paths) { for (auto& path: replacement.second) { - if (!dcp::filesystem::exists(path) && path.filename() == candidate.path().filename()) { + /* Extract a filename as if this path were from a platform with a different + * separator. + */ + string other = path.string(); +#ifdef DCPOMATIC_POSIX + std::replace(other.begin(), other.end(), '\\', '/'); +#else + std::replace(other.begin(), other.end(), '/', '\\'); +#endif + boost::filesystem::path other_path(other); + if ( + !dcp::filesystem::exists(path) && + (path.filename() == candidate.path().filename() || other_path.filename() == candidate.path().filename())) { path = candidate.path(); } } diff --git a/test/data b/test/data -Subproject 8cf2d01f470c8e5be3ab4a241dd88236c041a5c +Subproject 6a0da3e92abf6f6fd2f7b5dfd5f03eee44c585e diff --git a/test/find_missing_test.cc b/test/find_missing_test.cc index 809a8f864..94c2fc53b 100644 --- a/test/find_missing_test.cc +++ b/test/find_missing_test.cc @@ -197,3 +197,26 @@ BOOST_AUTO_TEST_CASE(find_missing_test_with_rename) } + +BOOST_AUTO_TEST_CASE(test_film_saved_on_windows) +{ + auto film = make_shared<Film>(boost::filesystem::path("test/data/windows_film")); + film->read_metadata(); + dcpomatic::find_missing(film->content(), TestPaths::private_data()); + + for (auto content: film->content()) { + BOOST_CHECK(content->paths_valid()); + } +} + + +BOOST_AUTO_TEST_CASE(test_film_saved_on_posix) +{ + auto film = make_shared<Film>(boost::filesystem::path("test/data/posix_film")); + film->read_metadata(); + dcpomatic::find_missing(film->content(), TestPaths::private_data()); + + for (auto content: film->content()) { + BOOST_CHECK(content->paths_valid()); + } +} |
