Basics of send-to-batch-converter; not tested on Windows nor OS X.
[dcpomatic.git] / src / lib / cross.cc
index 9ca3fe2b09b250e54602dd96192e77d0cc3a8268..6398e36764be282f60b355fa06613f79c810f7bc 100644 (file)
@@ -56,6 +56,7 @@ using std::ifstream;
 using std::string;
 using std::wstring;
 using std::make_pair;
+using std::runtime_error;
 using boost::shared_ptr;
 
 /** @param s Number of seconds to sleep for */
@@ -140,7 +141,7 @@ app_contents ()
        uint32_t size = 1024;
        char buffer[size];
        if (_NSGetExecutablePath (buffer, &size)) {
-               throw StringError ("_NSGetExecutablePath failed");
+               throw runtime_error ("_NSGetExecutablePath failed");
        }
 
        boost::filesystem::path path (buffer);
@@ -252,7 +253,7 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share
        path /= "MacOS";
        path /= "ffprobe";
 
-       string ffprobe = path.string() + " \"" + content.string() + "\" 2> \"" + out.string() + "\"";
+       string ffprobe = "\"" + path.string() + "\" \"" + content.string() + "\" 2> \"" + out.string() + "\"";
        LOG_GENERAL (N_("Probing with %1"), ffprobe);
        system (ffprobe.c_str ());
 #endif
@@ -352,3 +353,29 @@ Waker::~Waker ()
        IOPMAssertionRelease (_assertion_id);
 #endif
 }
+
+void
+start_batch_converter (boost::filesystem::path dcpomatic)
+{
+#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_WINDOWS)
+       boost::filesystem::path batch = dcpomatic.parent_path() / "dcpomatic2_batch";
+#endif
+
+#ifdef DCPOMATIC_OSX
+       boost::filesystem::patch batch = dcpomatic.parent_path ();
+       batch = batch.parent_path (); // MacOS
+       batch = batch.parent_path (); // Contents
+       batch = batch.parent_path (); // DCP-o-matic.app
+       batch = batch.parent_path (); // Applications
+       batch /= "DCP-o-matic 2 Batch Converter.app" / "Contents" / "MacOS" / "dcpomatic2_batch";
+#endif
+
+#ifdef DCPOMATIC_LINUX
+       pid_t pid = fork ();
+       if (pid == 0) {
+               int const r = system (batch.string().c_str ());
+               exit (WEXITSTATUS (r));
+       }
+#endif
+
+}