diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-04 23:24:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-05 23:52:14 +0100 |
| commit | ab766096598188759d29829043bf28e63379b730 (patch) | |
| tree | 1fb8fb9eb22c275834db2671395e7b3558e7aac4 /src | |
| parent | 2719964f89431a0598ef617326158309afe5ba43 (diff) | |
Replace Content::paths_valid() with a free utility function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/content.cc | 13 | ||||
| -rw-r--r-- | src/lib/content.h | 2 | ||||
| -rw-r--r-- | src/lib/empty.cc | 2 | ||||
| -rw-r--r-- | src/lib/make_dcp.cc | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 2 | ||||
| -rw-r--r-- | src/lib/util.cc | 6 | ||||
| -rw-r--r-- | src/lib/util.h | 1 | ||||
| -rw-r--r-- | src/wx/content_menu.cc | 2 | ||||
| -rw-r--r-- | src/wx/content_panel.cc | 4 |
9 files changed, 13 insertions, 21 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc index c5f82a375..60073f860 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -337,19 +337,6 @@ Content::identifier() const } -bool -Content::paths_valid() const -{ - for (auto i: _paths) { - if (!dcp::filesystem::exists(i)) { - return false; - } - } - - return true; -} - - void Content::set_paths(vector<boost::filesystem::path> paths) { diff --git a/src/lib/content.h b/src/lib/content.h index cf24bde00..aca5abea5 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -144,8 +144,6 @@ public: return _last_write_times[i]; } - bool paths_valid() const; - /** @return Digest of the content's file(s). Note: this is * not a complete MD5-or-whatever hash, but a sort of poor * man's version (see comments in examine()). diff --git a/src/lib/empty.cc b/src/lib/empty.cc index a75066395..7a7833941 100644 --- a/src/lib/empty.cc +++ b/src/lib/empty.cc @@ -42,7 +42,7 @@ Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, { list<DCPTimePeriod> full; for (auto i: playlist->content()) { - if (part(i) && i->paths_valid()) { + if (part(i) && paths_exist(i->paths())) { full.push_back(i->period(film)); } } diff --git a/src/lib/make_dcp.cc b/src/lib/make_dcp.cc index b72756194..5fb93a618 100644 --- a/src/lib/make_dcp.cc +++ b/src/lib/make_dcp.cc @@ -69,7 +69,7 @@ make_dcp (shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour) } for (auto i: film->content()) { - if (!i->paths_valid()) { + if (!paths_exist(i->paths())) { throw runtime_error (_("Some of your content is missing")); } auto dcp = dynamic_pointer_cast<const DCPContent>(i); diff --git a/src/lib/player.cc b/src/lib/player.cc index b5ee280ae..fd99e7732 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -283,7 +283,7 @@ Player::setup_pieces() for (auto content: playlist()->content()) { - if (!content->paths_valid()) { + if (!paths_exist(content->paths())) { continue; } diff --git a/src/lib/util.cc b/src/lib/util.cc index bcb39c482..df15e1abb 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1226,3 +1226,9 @@ rfc_2822_date(time_t time) } +bool +paths_exist(vector<boost::filesystem::path> const& paths) +{ + return std::all_of(paths.begin(), paths.end(), [](boost::filesystem::path const& path) { return dcp::filesystem::exists(path); }); +} + diff --git a/src/lib/util.h b/src/lib/util.h index 67c759b57..525deeb75 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -103,6 +103,7 @@ extern void setup_grok_library_path(); #endif extern std::string join_strings(std::vector<std::string> const& in, std::string const& separator = " "); extern std::string rfc_2822_date(time_t time); +bool paths_exist(std::vector<boost::filesystem::path> const& paths); template <class T> diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index e2dfdaf97..dadd1877f 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -155,7 +155,7 @@ ContentMenu::popup (weak_ptr<Film> film, ContentList c, TimelineContentViewList _join->Enable (n > 1); - _find_missing->Enable (_content.size() == 1 && !_content.front()->paths_valid ()); + _find_missing->Enable(_content.size() == 1 && !paths_exist(_content.front()->paths())); _properties->Enable (_content.size() == 1); _advanced->Enable (_content.size() == 1); _re_examine->Enable (!_content.empty ()); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 8938ef0fd..826481216 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -482,7 +482,7 @@ ContentPanel::check_selection () optional<DCPTime> go_to; for (auto content: selected()) { - if (content->paths_valid()) { + if (paths_exist(content->paths())) { auto position = content->position(); if (auto text_content = dynamic_pointer_cast<StringTextFileContent>(content)) { /* Rather special case; if we select a text subtitle file jump to its @@ -896,7 +896,7 @@ ContentPanel::setup () vector<ContentListCtrl::Item> items; for (auto i: content) { - bool const valid = i->paths_valid (); + bool const valid = paths_exist(i->paths()); auto dcp = dynamic_pointer_cast<DCPContent> (i); bool const needs_kdm = dcp && dcp->needs_kdm (); |
