summaryrefslogtreecommitdiff
path: root/src/lib/find_missing.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-05 00:47:24 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-05 23:52:14 +0100
commite61cc4ff73a82ef0a6575ca5a6f960e1577af480 (patch)
tree9f37c9c663f46919d1fd8fdec5ca08cdfd754eda /src/lib/find_missing.cc
parentf3d37cc0ad95cc8e6d71246dd842e6e1d9e7b06c (diff)
Find missing fonts after finding missing content.
Diffstat (limited to 'src/lib/find_missing.cc')
-rw-r--r--src/lib/find_missing.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/find_missing.cc b/src/lib/find_missing.cc
index 14394af04..ce8c65af3 100644
--- a/src/lib/find_missing.cc
+++ b/src/lib/find_missing.cc
@@ -86,6 +86,27 @@ search_by_name(Replacements& replacement_paths, boost::filesystem::path director
static
void
+search_by_name(map<boost::filesystem::path, boost::filesystem::path>& replacements, boost::filesystem::path directory, int depth = 0)
+{
+ boost::system::error_code ec;
+
+ for (auto candidate: dcp::filesystem::directory_iterator(directory, ec)) {
+ if (dcp::filesystem::is_regular_file(candidate.path())) {
+ for (auto& replacement: replacements) {
+ if (should_replace(replacement.first, candidate.path())) {
+ replacement.second = candidate.path();
+ }
+ }
+ } else if (dcp::filesystem::is_directory(candidate.path()) && depth <= 2) {
+ search_by_name(replacements, candidate, depth + 1);
+ }
+ }
+}
+
+
+
+static
+void
search_by_digest(Replacements& replacement_paths, boost::filesystem::path directory, int depth = 0)
{
boost::system::error_code ec;
@@ -148,4 +169,20 @@ dcpomatic::find_missing (vector<shared_ptr<Content>> content_to_fix, boost::file
}
}
}
+
+ /* Check fonts */
+ for (auto content: content_to_fix) {
+ map<boost::filesystem::path, boost::filesystem::path> fonts;
+ for (auto i: content->font_paths()) {
+ fonts[i] = i;
+ }
+
+ search_by_name(fonts, is_directory(clue) ? clue : clue.parent_path());
+
+ for (auto const& font: fonts) {
+ if (font.first != font.second) {
+ content->replace_font_path(font.first, font.second);
+ }
+ }
+ }
}