#include <boost/foreach.hpp>
using std::string;
+using std::cout;
using std::list;
using boost::shared_ptr;
{
int written = 0;
+ if (directory == "-") {
+ /* Write KDMs to the stdout */
+ BOOST_FOREACH (ScreenKDM const & i, screen_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 (ScreenKDM const & i, screen_kdms) {
- name_values['c'] = i.screen->cinema->name;
+ name_values['c'] = i.screen->cinema ? i.screen->cinema->name : "";
name_values['s'] = i.screen->name;
- boost::filesystem::path out = directory / (name_format.get(name_values, ".xml"));
+ name_values['i'] = i.kdm.id ();
+ 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 (out);
++written;