diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-11-04 23:56:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-11-09 00:34:26 +0100 |
| commit | 06a52e28b747983c99211469bf13a7c19e9d1644 (patch) | |
| tree | 8016f2bbfb01452fdb4444d2e49f34892e2e14ba | |
| parent | ca23cd312a0f5f5ee5aa8665b2a2346d6f990b5c (diff) | |
Allow saving of CPL/PKL with original filenames.v1.10.38
| -rw-r--r-- | src/dcp.cc | 10 | ||||
| -rw-r--r-- | src/dcp.h | 4 | ||||
| -rw-r--r-- | src/types.h | 9 |
3 files changed, 19 insertions, 4 deletions
@@ -451,6 +451,7 @@ DCP::write_volindex (Standard standard) const void DCP::write_xml( shared_ptr<const CertificateChain> signer, + Filenames filenames, NameFormat name_format, optional<string> group_id ) @@ -472,7 +473,8 @@ DCP::write_xml( for (auto i: cpls()) { NameFormat::Map values; values['t'] = "cpl"; - i->write_xml(_directory / (name_format.get(values, "_" + i->id() + ".xml")), signer); + boost::filesystem::path filename = (filenames == Filenames::ORIGINAL && i->file()) ? i->file()->filename() : name_format.get(values, "_" + i->id() + ".xml"); + i->write_xml(_directory / filename, signer); } if (_pkls.empty()) { @@ -498,8 +500,8 @@ DCP::write_xml( NameFormat::Map values; values['t'] = "pkl"; - auto pkl_path = _directory / name_format.get(values, "_" + pkl->id() + ".xml"); - pkl->write_xml (pkl_path, signer); + boost::filesystem::path const pkl_filename = (filenames == Filenames::ORIGINAL && pkl->file()) ? pkl->file()->filename() : name_format.get(values, "_" + pkl->id() + ".xml"); + pkl->write_xml(_directory / pkl_filename, signer); if (!_asset_map) { _asset_map = AssetMap( @@ -513,7 +515,7 @@ DCP::write_xml( /* The assets may have changed since we read the asset map, so re-add them */ _asset_map->clear_assets(); - _asset_map->add_asset(pkl->id(), pkl_path, true); + _asset_map->add_asset(pkl->id(), _directory / pkl_filename, true); for (auto asset: assets()) { asset->add_to_assetmap(*_asset_map, _directory); } @@ -152,9 +152,13 @@ public: /** Write all the XML files for this DCP. * @param signer Signer to use * @param name_format Name format to use for the CPL and PKL filenames + * @param filenames ORIGINAL to use original CPL and PKL filenames where available, NEW to + * always use name_format + * @param group_id Group UUID to write to PKL (or none to not write a GroupID tag) */ void write_xml( std::shared_ptr<const CertificateChain> signer = std::shared_ptr<const CertificateChain>(), + Filenames filenames = Filenames::NEW, NameFormat name_format = NameFormat("%t"), boost::optional<std::string> group_id = boost::none ); diff --git a/src/types.h b/src/types.h index 675c0a85..e0b1f064 100644 --- a/src/types.h +++ b/src/types.h @@ -363,6 +363,15 @@ private: bool operator== (Luminance const& a, Luminance const& b); +enum class Filenames +{ + /* Use the original filenames for PKL and CPL, where available */ + ORIGINAL, + /* Use new filenames for CPL and PKL, made using the given NameFormat */ + NEW +}; + + } |
