Cleanup: use a lambda.
[dcpomatic.git] / src / lib / cross_osx.cc
index 3b04f1011d40bd1daed90ac1a26c041ef833a7d4..5596e6ecbc3a42f51628aa677288a12d61ad7aa4 100644 (file)
@@ -25,6 +25,7 @@
 #include "dcpomatic_log.h"
 #include "config.h"
 #include "exceptions.h"
+#include <dcp/filesystem.h>
 #include <dcp/raw_convert.h>
 #include <glib.h>
 #include <boost/algorithm/string.hpp>
@@ -84,7 +85,7 @@ cpu_info ()
 boost::filesystem::path
 directory_containing_executable ()
 {
-       return boost::filesystem::canonical(boost::dll::program_location()).parent_path();
+       return dcp::filesystem::canonical(boost::dll::program_location()).parent_path();
 }
 
 
@@ -103,13 +104,18 @@ libdcp_resources_path ()
 
 
 void
-run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
+run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool err, string args)
 {
        auto path = directory_containing_executable () / "ffprobe";
+       if (!dcp::filesystem::exists(path)) {
+               /* This is a hack but we need ffprobe during tests */
+               path = "/Users/ci/workspace/bin/ffprobe";
+       }
+       string const redirect = err ? "2>" : ">";
 
-       string ffprobe = "\"" + path.string() + "\" \"" + content.string() + "\" 2> \"" + out.string() + "\"";
+       auto const ffprobe = String::compose("\"%1\" %2 \"%3\" %4 \"%5\"", path, args.empty() ? " " : args, content.string(), redirect, out.string());
        LOG_GENERAL (N_("Probing with %1"), ffprobe);
-       system (ffprobe.c_str ());
+       system (ffprobe.c_str());
 }