blob: b89fb18612a8b5d601bdee29869b5080d6fb641a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "util.h"
#include "recipient_with_kdm.h"
#include <dcp/name_format.h>
#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <boost/filesystem.hpp>
#include <iostream>
using std::list;
using std::cout;
using boost::shared_ptr;
int
write_kdm_files (
list<shared_ptr<RecipientWithKDM> > kdms,
boost::filesystem::path directory,
dcp::NameFormat name_format,
dcp::NameFormat::Map name_values,
boost::function<bool (boost::filesystem::path)> confirm_overwrite
)
{
int written = 0;
if (directory == "-") {
/* Write KDMs to the stdout */
BOOST_FOREACH (shared_ptr<RecipientWithKDM> i, kdms) {
cout << i->kdm_as_xml ();
++written;
}
return written;
}
if (!boost::filesystem::exists (directory)) {
boost::filesystem::create_directories (directory);
}
/* Write KDMs to the specified directory */
BOOST_FOREACH (shared_ptr<RecipientWithKDM> i, kdms) {
i->add_name_values (name_values);
boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml"));
if (!boost::filesystem::exists(out) || confirm_overwrite(out)) {
i->kdm_as_xml_to_file (out);
++written;
}
}
return written;
}
|