summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-10-28 10:24:44 +0000
committerCarl Hetherington <cth@carlh.net>2015-10-28 10:24:44 +0000
commit6dc0cdbd5be3f8f60bd50523501a0bd85666ebda (patch)
tree1897931ca1a054d4181818272d723a81513ac39b /src
parent34bacd283bd73cf697079459b0ad9e91bca349de (diff)
Don't add external (referenced) assets to the PKL.
Diffstat (limited to 'src')
-rw-r--r--src/asset.cc14
-rw-r--r--src/asset.h2
-rw-r--r--src/dcp.cc2
3 files changed, 15 insertions, 3 deletions
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<boost::filesystem::path> 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<Asset> i, assets ()) {
- i->write_to_pkl (asset_list, standard);
+ i->write_to_pkl (asset_list, _directory, standard);
}
if (signer) {