From 0f42e807a707249cd1a60fa6e476cb47a4147c5a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 9 May 2017 13:44:43 +0100 Subject: Basica save-as (duplicate) (#746). --- src/lib/film.cc | 14 +++++++++++--- src/lib/film.h | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/film.cc b/src/lib/film.cc index 04ff00250..36221fb9a 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -98,6 +98,8 @@ using dcp::raw_convert; #define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); #define LOG_GENERAL_NC(...) log()->log (__VA_ARGS__, LogEntry::TYPE_GENERAL); +string const Film::metadata_file = "metadata.xml"; + /* 5 -> 6 * AudioMapping XML changed. * 6 -> 7 @@ -399,7 +401,7 @@ Film::write_metadata () const DCPOMATIC_ASSERT (directory()); boost::filesystem::create_directories (directory().get()); shared_ptr doc = metadata (); - doc->write_to_file_formatted (file("metadata.xml").string ()); + doc->write_to_file_formatted (file(metadata_file).string ()); _dirty = false; } @@ -419,11 +421,11 @@ list Film::read_metadata (optional path) { if (!path) { - if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file ("metadata.xml"))) { + if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file (metadata_file))) { throw runtime_error (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version. You will need to create a new Film, re-add your content and set it up again. Sorry!")); } - path = file ("metadata.xml"); + path = file (metadata_file); } cxml::Document f ("Metadata"); @@ -1575,3 +1577,9 @@ Film::speed_up_range (int dcp_frame_rate) const { return _playlist->speed_up_range (dcp_frame_rate); } + +void +Film::copy_from (shared_ptr film) +{ + read_metadata (film->file (metadata_file)); +} diff --git a/src/lib/film.h b/src/lib/film.h index fdd4674d5..ec64c3913 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -96,6 +96,8 @@ public: void write_template (boost::filesystem::path path) const; boost::shared_ptr metadata (bool with_content_paths = true) const; + void copy_from (boost::shared_ptr film); + std::string isdcf_name (bool if_created_now) const; std::string dcp_name (bool if_created_now = false) const; @@ -337,6 +339,8 @@ private: void maybe_add_content (boost::weak_ptr, boost::weak_ptr); void audio_analysis_finished (); + static std::string const metadata_file; + /** Log to write to */ boost::shared_ptr _log; boost::shared_ptr _playlist; -- cgit v1.2.3