Confirm overwrite of KDMs (#1008).
[dcpomatic.git] / src / tools / dcpomatic_kdm_cli.cc
index 5126e1954c10405b1929c2acf0a72e1b188afa11..7cfcaa1712b50a39f645dc266518cf950e0fdf22 100644 (file)
@@ -39,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 ()
@@ -83,7 +85,7 @@ duration_from_string (string d)
 {
        int N;
        char unit_buf[64] = "\0";
-       sscanf (d.c_str(), "%d %64s", &N, unit_buf);
+       sscanf (d.c_str(), "%d %63s", &N, unit_buf);
        string const unit (unit_buf);
 
        if (N == 0) {
@@ -105,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;
@@ -217,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 ();
@@ -230,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);
        }
 
@@ -305,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";