49 #include <boost/filesystem.hpp>
59 using std::dynamic_pointer_cast;
60 using boost::optional;
61 using std::shared_ptr;
64 boost::filesystem::path
65 make_unique (boost::filesystem::path path)
67 if (!boost::filesystem::exists(path)) {
71 for (
int i = 0; i < 10000; ++i) {
72 boost::filesystem::path p = path.parent_path() / (path.stem().string() + dcp::raw_convert<string>(i) + path.extension().string());
73 if (!boost::filesystem::exists(p)) {
85 create_hard_link_or_copy (boost::filesystem::path from, boost::filesystem::path to)
88 create_hard_link (from, to);
89 }
catch (boost::filesystem::filesystem_error& e) {
90 if (e.code() == boost::system::errc::cross_device_link) {
101 vector<boost::filesystem::path> inputs,
102 boost::filesystem::path output,
106 string annotation_text,
107 shared_ptr<const CertificateChain> signer
110 using namespace boost::filesystem;
112 DCP_ASSERT (!inputs.empty());
114 DCP output_dcp (output);
115 optional<dcp::Standard> standard;
117 for (
auto i: inputs) {
121 standard = *
dcp.standard();
122 }
else if (standard !=
dcp.standard()) {
123 throw CombineError (
"Cannot combine Interop and SMPTE DCPs.");
128 vector<shared_ptr<dcp::Asset>> assets;
130 for (
auto i: inputs) {
134 for (
auto j:
dcp.cpls()) {
138 for (
auto j:
dcp.assets(
true)) {
139 if (dynamic_pointer_cast<dcp::CPL>(j)) {
143 auto sub = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(j);
150 auto fonts = sub->font_filenames ();
151 for (
auto const& k: fonts) {
152 sub->set_font_file (k.first, make_unique(output / k.second.filename()));
154 auto file = sub->file();
156 path new_path = make_unique(output / file->filename());
157 sub->write (new_path);
160 assets.push_back (j);
164 output_dcp.resolve_refs (assets);
166 for (
auto i: output_dcp.assets()) {
167 if (!dynamic_pointer_cast<dcp::FontAsset>(i) && !dynamic_pointer_cast<dcp::CPL>(i)) {
168 auto file = i->file();
170 path new_path = make_unique(output / file->filename());
171 create_hard_link_or_copy (*file, new_path);
172 i->set_file (new_path);
176 output_dcp.write_xml (issuer, creator, issue_date, annotation_text, signer);
Exceptions thrown by libdcp.
InteropSubtitleAsset class.
Namespace for everything in libdcp.
Methods for conversion to/from string.