Add new write() method.
[libdcp.git] / tools / dcprecover.cc
index eb3b0d827c8e44a7abb0d06b28e904da84aeeb01..f9e08087ad6873844d4d3c1fd307ab0c9d4d7d6e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
 #include <getopt.h>
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <iostream>
 
 using std::cerr;
 using std::cout;
 using std::string;
-using std::list;
-using boost::shared_ptr;
+using std::shared_ptr;
+using std::vector;
 using boost::optional;
 
 static void
@@ -65,6 +64,8 @@ void progress (float f)
 int
 main (int argc, char* argv[])
 {
+       dcp::init ();
+
        int option_index = 0;
        optional<boost::filesystem::path> output;
        while (true) {
@@ -100,14 +101,14 @@ main (int argc, char* argv[])
        /* Try to read it and report errors */
 
        dcp::DCP dcp (dcp_dir);
-       list<dcp::VerificationNote> notes;
+       vector<dcp::VerificationNote> notes;
        try {
                dcp.read (&notes, true);
-       } catch (dcp::DCPReadError& e) {
+       } catch (dcp::ReadError& e) {
                cout << "Error:" <<  e.what() << "\n";
        }
 
-       BOOST_FOREACH (dcp::VerificationNote i, notes) {
+       for (auto i: notes) {
                cout << "Error: " << dcp::note_to_string(i) << "\n";
        }
 
@@ -118,7 +119,7 @@ main (int argc, char* argv[])
                if (i->path().extension() == ".xml") {
                        try {
                                cpl.reset(new dcp::CPL(i->path()));
-                       } catch (dcp::DCPReadError& e) {
+                       } catch (dcp::ReadError& e) {
                                cout << "Error: " << e.what() << "\n";
                        } catch (xmlpp::parse_error& e) {
                                cout << "Error: " << e.what() << "\n";
@@ -135,7 +136,7 @@ main (int argc, char* argv[])
                }
 
                /* Read all MXF assets */
-               list<shared_ptr<dcp::Asset> > assets;
+               vector<shared_ptr<dcp::Asset>> assets;
                for (boost::filesystem::directory_iterator i(dcp_dir); i != boost::filesystem::directory_iterator(); ++i) {
                        if (i->path().extension() == ".mxf") {
                                try {
@@ -145,7 +146,7 @@ main (int argc, char* argv[])
                                        asset->hash (&progress);
                                        cout << "100%                     \n";
                                        assets.push_back (asset);
-                               } catch (dcp::DCPReadError& e) {
+                               } catch (dcp::ReadError& e) {
                                        cout << "Error: " << e.what() << "\n";
                                }
                        }
@@ -154,7 +155,7 @@ main (int argc, char* argv[])
                dcp::DCP fixed (*output);
                fixed.add (cpl);
                fixed.resolve_refs (assets);
-               fixed.write_xml (dcp::INTEROP);
+               fixed.write_xml (dcp::Standard::INTEROP);
                cout << "Fixed XML files written to " << output->string() << "\n";
        }