#include "lib/config.h"
#include "lib/exceptions.h"
#include "lib/emailer.h"
-#include <locked_sstream.h>
#include <dcp/certificate.h>
#include <getopt.h>
#include <iostream>
using std::list;
using std::vector;
using boost::shared_ptr;
+using boost::optional;
+using boost::bind;
static void
help ()
static boost::posix_time::time_duration
duration_from_string (string d)
{
- locked_stringstream s (d);
int N;
- string unit;
- s >> N >> unit;
+ char unit_buf[64] = "\0";
+ sscanf (d.c_str(), "%d %63s", &N, unit_buf);
+ string const unit (unit_buf);
if (N == 0) {
cerr << "Could not understand duration \"" << d << "\"\n";
exit (EXIT_FAILURE);
}
+static bool
+always_overwrite ()
+{
+ return true;
+}
+
int main (int argc, char* argv[])
{
boost::filesystem::path output;
valid_to = valid_from.get() + duration_from_string (duration_string);
}
- string const film_dir = argv[optind];
+ boost::filesystem::path const film_dir = argv[optind];
dcpomatic_setup_path_encoding ();
dcpomatic_setup ();
cout << "Read film " << film->name () << "\n";
}
} catch (std::exception& e) {
- cerr << program_name << ": error reading film `" << film_dir << "' (" << e.what() << ")\n";
+ cerr << program_name << ": error reading film `" << film_dir.string() << "' (" << e.what() << ")\n";
exit (EXIT_FAILURE);
}
output = ".";
}
- NameFormat::Map values;
- values["film_name"] = film->name();
- values["from"] = dcp::LocalTime(valid_from.get()).date() + " " + dcp::LocalTime(valid_from.get()).time_of_day();
- values["to"] = dcp::LocalTime(valid_to.get()).date() + " " + dcp::LocalTime(valid_to.get()).time_of_day();
+ dcp::NameFormat::Map values;
+ values['f'] = film->name();
+ values['b'] = dcp::LocalTime(valid_from.get()).date() + " " + dcp::LocalTime(valid_from.get()).time_of_day();
+ values['e'] = dcp::LocalTime(valid_to.get()).date() + " " + dcp::LocalTime(valid_to.get()).time_of_day();
try {
list<ScreenKDM> screen_kdms = film->make_kdms (
);
if (zip) {
- CinemaKDMs::write_zip_files (
+ int const N = CinemaKDMs::write_zip_files (
CinemaKDMs::collect (screen_kdms),
output,
+ Config::instance()->kdm_container_name_format(),
Config::instance()->kdm_filename_format(),
- values
+ values,
+ bind (&always_overwrite)
);
if (verbose) {
- cout << "Wrote ZIP files to " << output << "\n";
+ cout << "Wrote " << N << " ZIP files to " << output << "\n";
}
} else {
- ScreenKDM::write_files (screen_kdms, output, Config::instance()->kdm_filename_format(), values);
+ int const N = ScreenKDM::write_files (
+ screen_kdms, output, Config::instance()->kdm_filename_format(), values,
+ bind (&always_overwrite)
+ );
if (verbose) {
- cout << "Wrote KDM files to " << output << "\n";
+ cout << "Wrote " << N << " KDM files to " << output << "\n";
}
}
} catch (FileError& e) {