X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_kdm_cli.cc;h=7cfcaa1712b50a39f645dc266518cf950e0fdf22;hb=7e4d7d9e4f146576a63c6ab1be9bca5a79b507d9;hp=ad5ee1c7bbcdae99ae298f1cba7359038a92fc3e;hpb=736b3a068ba5a402b541d32f270669e6e1a4e5c4;p=dcpomatic.git diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index ad5ee1c7b..7cfcaa171 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -29,7 +29,6 @@ #include "lib/config.h" #include "lib/exceptions.h" #include "lib/emailer.h" -#include #include #include #include @@ -40,6 +39,8 @@ using std::cerr; using std::list; using std::vector; using boost::shared_ptr; +using boost::optional; +using boost::bind; static void help () @@ -82,10 +83,10 @@ time_from_string (string t) 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"; @@ -106,6 +107,12 @@ duration_from_string (string d) exit (EXIT_FAILURE); } +static bool +always_overwrite () +{ + return true; +} + int main (int argc, char* argv[]) { boost::filesystem::path output; @@ -218,7 +225,7 @@ int main (int argc, char* argv[]) 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 (); @@ -231,7 +238,7 @@ int main (int argc, char* argv[]) 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); } @@ -284,10 +291,10 @@ int main (int argc, char* argv[]) 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 screen_kdms = film->make_kdms ( @@ -306,7 +313,10 @@ int main (int argc, char* argv[]) cout << "Wrote ZIP files to " << output << "\n"; } } else { - ScreenKDM::write_files (screen_kdms, output, Config::instance()->kdm_filename_format(), values); + ScreenKDM::write_files ( + screen_kdms, output, Config::instance()->kdm_filename_format(), values, + bind (&always_overwrite) + ); if (verbose) { cout << "Wrote KDM files to " << output << "\n";