Fix PKL path when using customised filenames.
authorCarl Hetherington <cth@carlh.net>
Tue, 16 Aug 2016 14:05:33 +0000 (15:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 Aug 2016 14:05:33 +0000 (15:05 +0100)
src/dcp.cc
src/dcp.h

index 6af144dd08c7d0583a333ff9f25453f8bb62fa9f..8aff6c407f512f94faa56ffaee33a69dfc3bb651 100644 (file)
@@ -302,6 +302,7 @@ DCP::add (DecryptedKDM const & kdm)
        }
 }
 
+/** @return full pathname of PKL file that was written */
 boost::filesystem::path
 DCP::write_pkl (string file, Standard standard, string pkl_uuid, XMLMetadata metadata, shared_ptr<const CertificateChain> signer) const
 {
@@ -380,7 +381,7 @@ DCP::write_volindex (Standard standard) const
 }
 
 void
-DCP::write_assetmap (Standard standard, string pkl_uuid, int pkl_length, XMLMetadata metadata) const
+DCP::write_assetmap (Standard standard, string pkl_uuid, boost::filesystem::path pkl_path, XMLMetadata metadata) const
 {
        boost::filesystem::path p = _directory;
 
@@ -436,10 +437,10 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, int pkl_length, XMLMeta
        asset->add_child("PackingList")->add_child_text ("true");
        xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
        xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
-       chunk->add_child("Path")->add_child_text ("pkl_" + pkl_uuid + ".xml");
+       chunk->add_child("Path")->add_child_text (pkl_path.filename().string());
        chunk->add_child("VolumeIndex")->add_child_text ("1");
        chunk->add_child("Offset")->add_child_text ("0");
-       chunk->add_child("Length")->add_child_text (raw_convert<string> (pkl_length));
+       chunk->add_child("Length")->add_child_text (raw_convert<string> (boost::filesystem::file_size (pkl_path)));
 
        BOOST_FOREACH (shared_ptr<Asset> i, assets ()) {
                i->write_to_assetmap (asset_list, _directory);
@@ -476,7 +477,7 @@ DCP::write_xml (
        boost::filesystem::path const pkl_path = write_pkl (name_format.get(values) + ".xml", standard, pkl_uuid, metadata, signer);
 
        write_volindex (standard);
-       write_assetmap (standard, pkl_uuid, boost::filesystem::file_size (pkl_path), metadata);
+       write_assetmap (standard, pkl_uuid, pkl_path, metadata);
 }
 
 list<shared_ptr<CPL> >
index fecf3cffebe3b1261881bf2b1961792059bec4aa..2f297d822cf098d755dfb6309afab2ef03ec6067 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -140,9 +140,9 @@ private:
 
        /** Write the ASSETMAP file.
         *  @param pkl_uuid UUID of our PKL.
-        *  @param pkl_length Length of our PKL in bytes.
+        *  @param pkl_path Pathname of our PKL file.
         */
-       void write_assetmap (Standard standard, std::string pkl_uuid, int pkl_length, XMLMetadata metadata) const;
+       void write_assetmap (Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path, XMLMetadata metadata) const;
 
        /** the directory that we are writing to */
        boost::filesystem::path _directory;