X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffilm.cc;fp=src%2Flib%2Ffilm.cc;h=4084ca59c1700ec2d5ecae874b8eb5b0732b62b5;hb=e68386830c8812f80cb4b3af9871170226b916b4;hp=1aba68eeb653f8342e158bcc598f74ec751d2d52;hpb=3d9c0674236a425f0be5e9caff5e23f59e7c037a;p=dcpomatic.git diff --git a/src/lib/film.cc b/src/lib/film.cc index 1aba68eeb..4084ca59c 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -534,6 +534,8 @@ Film::read_metadata (optional path) } } + _last_written_by = f.optional_string_child("LastWrittenBy"); + _name = f.string_child ("Name"); if (_state_version >= 9) { _use_isdcf_name = f.bool_child ("UseISDCFName"); @@ -2167,3 +2169,41 @@ Film::set_dirty (bool dirty) } } + +/** @return true if the metadata was (probably) last written by a version earlier + * than the given one; false if it definitely was not. + */ +bool +Film::last_written_by_earlier_than(int major, int minor, int micro) const +{ + if (!_last_written_by) { + return true; + } + + vector parts; + boost::split(parts, *_last_written_by, 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 */ + return true; + } + + if (boost::ends_with(parts[2], "pre")) { + parts[2] = parts[2].substr(0, parts[2].length() - 3); + } + + int our_major = dcp::raw_convert(parts[0]); + int our_minor = dcp::raw_convert(parts[1]); + int our_micro = dcp::raw_convert(parts[2]); + + if (our_major != major) { + return our_major < major; + } + + if (our_minor != minor) { + return our_minor < minor; + } + + return our_micro < micro; +} +