From 6dc0cdbd5be3f8f60bd50523501a0bd85666ebda Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 28 Oct 2015 10:24:44 +0000 Subject: Don't add external (referenced) assets to the PKL. --- src/asset.cc | 14 +++++++++++++- src/asset.h | 2 +- src/dcp.cc | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/asset.cc b/src/asset.cc index a800e8ee..81321d4d 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -58,10 +58,22 @@ Asset::Asset (string id, boost::filesystem::path file) } void -Asset::write_to_pkl (xmlpp::Node* node, Standard standard) const +Asset::write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const { DCP_ASSERT (!_file.empty ()); + optional path = relative_to_root ( + boost::filesystem::canonical (root), + boost::filesystem::canonical (_file) + ); + + if (!path) { + /* The path of this asset is not within our DCP, so we assume it's an external + (referenced) one. + */ + return; + } + xmlpp::Node* asset = node->add_child ("Asset"); asset->add_child("Id")->add_child_text ("urn:uuid:" + _id); asset->add_child("AnnotationText")->add_child_text (_id); diff --git a/src/asset.h b/src/asset.h index 91661a46..c7911497 100644 --- a/src/asset.h +++ b/src/asset.h @@ -66,7 +66,7 @@ public: * @param node Parent node. * @param standard Standard to use. */ - void write_to_pkl (xmlpp::Node* node, Standard standard) const; + void write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const; /** @return the most recent disk file used to read or write this asset; may be empty */ boost::filesystem::path file () const { diff --git a/src/dcp.cc b/src/dcp.cc index 4f1f07df..53d5dd39 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -274,7 +274,7 @@ DCP::write_pkl (Standard standard, string pkl_uuid, XMLMetadata metadata, shared xmlpp::Element* asset_list = pkl->add_child("AssetList"); BOOST_FOREACH (shared_ptr i, assets ()) { - i->write_to_pkl (asset_list, standard); + i->write_to_pkl (asset_list, _directory, standard); } if (signer) { -- cgit v1.2.3