diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 18 | ||||
| -rw-r--r-- | src/lib/film.h | 9 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 0079f87c9..3af1a5e18 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -566,7 +566,9 @@ Film::read_metadata(optional<boost::filesystem::path> path) } } - _last_written_by = f.optional_string_child("LastWrittenBy"); + if (auto last = f.optional_node_child("LastWrittenBy")) { + _last_written_by = LastWrittenBy{last->content(), last->string_attribute("git")}; + } _name = f.string_child("Name"); if (_state_version >= 9) { @@ -2470,6 +2472,18 @@ Film::set_dirty(bool dirty) } +bool +Film::last_written_by_git() const +{ + if (_last_written_by) { + auto len = std::min(_last_written_by->version.length(), _last_written_by->git.length()); + return _last_written_by->version.substr(0, len) == _last_written_by->git.substr(0, len); + } + + return false; +} + + /** @return true if the metadata was (probably) last written by a version earlier * than the given one; false if it definitely was not. */ @@ -2481,7 +2495,7 @@ Film::last_written_by_earlier_than(int major, int minor, int micro) const } vector<string> parts; - boost::split(parts, *_last_written_by, boost::is_any_of(".")); + boost::split(parts, _last_written_by->version, boost::is_any_of(".")); if (parts.size() != 3) { /* Not sure what's going on, so let's say it was written by an old version */ diff --git a/src/lib/film.h b/src/lib/film.h index 799333430..3aef1e27e 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -198,6 +198,7 @@ public: bool references_dcp_audio() const; bool contains_atmos_content() const; + bool last_written_by_git() const; bool last_written_by_earlier_than(int major, int minor, int micro) const; /* GET */ @@ -506,7 +507,13 @@ private: */ boost::optional<boost::filesystem::path> _directory; - boost::optional<std::string> _last_written_by; + struct LastWrittenBy + { + std::string version; + std::string git; + }; + + boost::optional<LastWrittenBy> _last_written_by; /** Name for DCP-o-matic */ std::string _name; |
