X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcross.cc;h=4e801f44cb4940fb1667ffd897b6de57ba93dc9f;hb=3739c62f626b65da929d37fb7efc44a8e349e6f1;hp=24abf2c0a99a64a74df01f814394f7417148a7cc;hpb=f8d4df639e7d6dba17b0cddfe131b20b5422c512;p=dcpomatic.git diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 24abf2c0a..4e801f44c 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -353,3 +353,45 @@ 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::path 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"; + batch /= "Contents"; + batch /= "MacOS"; + batch /= "dcpomatic2_batch"; +#endif + +#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_OSX) + pid_t pid = fork (); + if (pid == 0) { + std::cout << "start " << batch << " from " << dcpomatic << "\n"; + int const r = system (batch.string().c_str()); + exit (WEXITSTATUS (r)); + } +#endif + +#ifdef DCPOMATIC_WINDOWS + STARTUPINFO startup_info; + ZeroMemory (&startup_info, sizeof (startup_info)); + startup_info.cb = sizeof (startup_info); + + PROCESS_INFORMATION process_info; + ZeroMemory (&process_info, sizeof (process_info)); + + wchar_t cmd[512]; + MultiByteToWideChar (CP_UTF8, 0, batch.string().c_str(), -1, cmd, sizeof(cmd)); + CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info); +#endif +}