From ddc12bfa6d287a7b434f012333e2ea0d4bacb92c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 30 Dec 2017 22:06:08 +0000 Subject: Refactor slightly. --- src/tools/dcpomatic_kdm_cli.cc | 52 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 01a86cd7f..df2e1a8e2 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -113,6 +113,34 @@ always_overwrite () return true; } +void +write_files (list screen_kdms, bool zip, boost::filesystem::path output, dcp::NameFormat::Map values, bool verbose) +{ + if (zip) { + int const N = CinemaKDMs::write_zip_files ( + CinemaKDMs::collect (screen_kdms), + output, + Config::instance()->kdm_container_name_format(), + Config::instance()->kdm_filename_format(), + values, + bind (&always_overwrite) + ); + + if (verbose) { + cout << "Wrote " << N << " ZIP files to " << output << "\n"; + } + } else { + int const N = ScreenKDM::write_files ( + screen_kdms, output, Config::instance()->kdm_filename_format(), values, + bind (&always_overwrite) + ); + + if (verbose) { + cout << "Wrote " << N << " KDM files to " << output << "\n"; + } + } +} + int main (int argc, char* argv[]) { boost::filesystem::path output; @@ -301,29 +329,7 @@ int main (int argc, char* argv[]) (*i)->screens(), cpl, valid_from.get(), valid_to.get(), formulation ); - if (zip) { - int const N = CinemaKDMs::write_zip_files ( - CinemaKDMs::collect (screen_kdms), - output, - Config::instance()->kdm_container_name_format(), - Config::instance()->kdm_filename_format(), - values, - bind (&always_overwrite) - ); - - if (verbose) { - cout << "Wrote " << N << " ZIP files to " << output << "\n"; - } - } else { - int const N = ScreenKDM::write_files ( - screen_kdms, output, Config::instance()->kdm_filename_format(), values, - bind (&always_overwrite) - ); - - if (verbose) { - cout << "Wrote " << N << " KDM files to " << output << "\n"; - } - } + write_files (screen_kdms, zip, output, values, verbose); } catch (FileError& e) { cerr << argv[0] << ": " << e.what() << " (" << e.file().string() << ")\n"; exit (EXIT_FAILURE); -- cgit v1.2.3