#include "dcpomatic_log.h"
#include "config.h"
#include "exceptions.h"
+#include "warnings.h"
#include <dcp/raw_convert.h>
#include <glib.h>
extern "C" {
#include <libavformat/avio.h>
}
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#if BOOST_VERSION >= 106100
#include <boost/dll/runtime_symbol_info.hpp>
#endif
+#include <ApplicationServices/ApplicationServices.h>
#include <sys/sysctl.h>
#include <mach-o/dyld.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
using std::cout;
using std::runtime_error;
using std::map;
-using boost::shared_ptr;
+using std::shared_ptr;
using boost::optional;
using boost::function;
boost::filesystem::path
-shared_path ()
+resources_path ()
{
return directory_containing_executable().parent_path() / "Resources";
}
+boost::filesystem::path
+xsd_path ()
+{
+ return resources_path() / "xsd";
+}
+
+
+boost::filesystem::path
+tags_path ()
+{
+ return resources_path() / "tags";
+}
+
+
void
run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
{
Waker::Waker ()
{
boost::mutex::scoped_lock lm (_mutex);
- /* We should use this */
- // IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id);
- /* but it's not available on 10.5, so we use this */
- IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_assertion_id);
+ IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id);
}
Waker::~Waker ()
void
start_tool (string executable, string app)
{
- boost::filesystem::path batch = directory_containing_executable();
- batch = batch.parent_path (); // MacOS
- batch = batch.parent_path (); // Contents
- batch = batch.parent_path (); // DCP-o-matic.app
- batch = batch.parent_path (); // Applications
- batch /= app;
- batch /= "Contents";
- batch /= "MacOS";
- batch /= executable;
+ boost::filesystem::path exe_path = directory_containing_executable();
+ exe_path = exe_path.parent_path (); // Contents
+ exe_path = exe_path.parent_path (); // DCP-o-matic 2.app
+ exe_path = exe_path.parent_path (); // Applications
+ exe_path /= app;
+ exe_path /= "Contents";
+ exe_path /= "MacOS";
+ exe_path /= executable;
pid_t pid = fork ();
if (pid == 0) {
- int const r = system (batch.string().c_str());
+ LOG_GENERAL ("start_tool %1 %2 with path %3", executable, app, exe_path.string());
+ int const r = system (exe_path.string().c_str());
exit (WEXITSTATUS (r));
+ } else if (pid == -1) {
+ LOG_ERROR_NC("Fork failed in start_tool");
}
}
return getenv("HOME");
}
-string
-command_and_read (string cmd)
-{
- return "";
-}
-
/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
bool
running_32_on_64 ()
vector<string> bits;
split(bits, path, boost::is_any_of("/"));
- BOOST_FOREACH (string i, bits) {
+ for (auto i: bits) {
if (starts_with(i, "PRT")) {
mp.prt = i;
}
CFRelease(session);
/* Mark disks containing mounted partitions as themselves mounted */
- BOOST_FOREACH (Disk& i, disks) {
+ for (auto& i: disks) {
if (!i.whole) {
continue;
}
- BOOST_FOREACH (Disk& j, disks) {
+ for (auto& j: disks) {
if (!j.mount_points.empty() && starts_with(j.mount_point, i.mount_point)) {
LOG_DISK("Marking %1 as mounted because %2 is", i.mount_point, j.mount_point);
std::copy(j.mount_points.begin(), j.mount_points.end(), back_inserter(i.mount_points));
/* Make a map of the PRT codes and mount points of mounted, synthesized disks */
map<string, vector<boost::filesystem::path> > mounted_synths;
- BOOST_FOREACH (Disk& i, disks) {
+ for (auto& i: disks) {
if (!i.real && !i.mount_points.empty()) {
LOG_DISK("Found a mounted synth %1 with %2", i.mount_point, i.prt);
mounted_synths[i.prt] = i.mount_points;
}
/* Mark containers of those mounted synths as themselves mounted */
- BOOST_FOREACH (Disk& i, disks) {
+ for (auto& i: disks) {
if (i.real) {
map<string, vector<boost::filesystem::path> >::const_iterator j = mounted_synths.find(i.prt);
if (j != mounted_synths.end()) {
}
vector<Drive> drives;
- BOOST_FOREACH (Disk& i, disks) {
+ for (auto& i: disks) {
if (i.whole) {
/* A whole disk that is not a container for a mounted synth */
drives.push_back(Drive(i.mount_point, i.mount_points, i.size, i.vendor, i.model));
}
-void done_callback(DADiskRef disk, DADissenterRef dissenter, void* context)
+void done_callback(DADiskRef, DADissenterRef dissenter, void* context)
{
LOG_DISK_NC("Unmount finished");
bool* success = reinterpret_cast<bool*> (context);
}
+
+void
+make_foreground_application ()
+{
+ ProcessSerialNumber serial;
+DCPOMATIC_DISABLE_WARNINGS
+ GetCurrentProcess (&serial);
+DCPOMATIC_ENABLE_WARNINGS
+ TransformProcessType (&serial, kProcessTransformToForegroundApplication);
+}
+
+
+string
+dcpomatic::get_process_id ()
+{
+ return dcp::raw_convert<string>(getpid());
+}