Add dcp::LocalTime::millisecond().
[libdcp.git] / tools / dcpverify.cc
index eaecb0f17bf7fbde5bc6c671cbd4c30a50a7962c..b9b3c9974c78168905afe54520d73c14c46fc259 100644 (file)
@@ -37,7 +37,6 @@
 #include <boost/bind.hpp>
 #include <boost/optional.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <getopt.h>
 #include <iostream>
 #include <cstdlib>
@@ -61,25 +60,6 @@ help (string n)
             << "  -q, --quiet             don't report progress\n";
 }
 
-void
-stage (bool quiet, string s, optional<boost::filesystem::path> path)
-{
-       if (quiet) {
-               return;
-       }
-
-       if (path) {
-               cout << s << ": " << path->string() << "\n";
-       } else {
-               cout << s << "\n";
-       }
-}
-
-void
-progress ()
-{
-
-}
 
 int
 main (int argc, char* argv[])
@@ -136,31 +116,74 @@ main (int argc, char* argv[])
                exit (EXIT_FAILURE);
        }
 
+       auto stage = [quiet](string s, optional<boost::filesystem::path> path) {
+               if (quiet) {
+                       return;
+               }
+
+               if (path) {
+                       cout << s << ": " << path->string() << "\n";
+               } else {
+                       cout << s << "\n";
+               }
+       };
+
+       auto progress = [quiet](float amount) {
+               if (quiet) {
+                       return;
+               }
+               int const width = 60;
+               int const index = std::rint(amount * width);
+               cout << "[";
+               for (int i = 0; i < width; ++i) {
+                       if (i < index) {
+                               std::cout << "=";
+                       } else if (i == index) {
+                               std::cout << ">";
+                       } else {
+                               std::cout << " ";
+                       }
+               }
+               cout << "] " << std::rint(amount * 100) << "%\r";
+               cout.flush();
+       };
+
        vector<boost::filesystem::path> directories;
        directories.push_back (argv[optind]);
-       auto notes = dcp::verify (directories, bind(&stage, quiet, _1, _2), bind(&progress), "xsd");
+       auto notes = dcp::verify(directories, stage, progress);
        dcp::filter_notes (notes, ignore_missing_assets);
 
+       if (!quiet) {
+               cout << "\n";
+       }
+
        bool failed = false;
-       BOOST_FOREACH (dcp::VerificationNote i, notes) {
-               if (ignore_bv21_smpte && i.code() == dcp::VerificationNote::NOT_SMPTE) {
+       bool bv21_failed = false;
+       bool warned = false;
+       for (auto i: notes) {
+               if (ignore_bv21_smpte && i.code() == dcp::VerificationNote::Code::INVALID_STANDARD) {
                        continue;
                }
                switch (i.type()) {
-               case dcp::VerificationNote::VERIFY_ERROR:
+               case dcp::VerificationNote::Type::ERROR:
                        cout << "Error: " << note_to_string(i) << "\n";
                        failed = true;
                        break;
-               case dcp::VerificationNote::VERIFY_BV21_ERROR:
+               case dcp::VerificationNote::Type::BV21_ERROR:
                        cout << "Bv2.1 error: " << note_to_string(i) << "\n";
+                       bv21_failed = true;
                        break;
-               case dcp::VerificationNote::VERIFY_WARNING:
+               case dcp::VerificationNote::Type::WARNING:
                        cout << "Warning: " << note_to_string(i) << "\n";
+                       warned = true;
                        break;
                }
        }
 
        if (!failed && !quiet) {
+               if (bv21_failed || warned) {
+                       cout << "\n";
+               }
                cout << "DCP verified OK.\n";
        }