std::shared_ptr
[dcpomatic.git] / src / lib / cross_osx.cc
index 412259e6a0e687ef62a23a1c899040c2b6c61c09..76c451a6f3df2078b77d3ed951421318592f0f18 100644 (file)
@@ -64,7 +64,7 @@ using std::cerr;
 using std::cout;
 using std::runtime_error;
 using std::map;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
 using boost::function;
 
@@ -117,7 +117,7 @@ directory_containing_executable ()
 
 
 boost::filesystem::path
-shared_path ()
+resources_path ()
 {
        return directory_containing_executable().parent_path() / "Resources";
 }
@@ -126,7 +126,14 @@ shared_path ()
 boost::filesystem::path
 xsd_path ()
 {
-       return shared_path() / "xsd";
+       return resources_path() / "xsd";
+}
+
+
+boost::filesystem::path
+tags_path ()
+{
+       return resources_path() / "tags";
 }
 
 
@@ -201,20 +208,22 @@ 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");
        }
 }
 
@@ -251,12 +260,6 @@ home_directory ()
                return getenv("HOME");
 }
 
-string
-command_and_read (string)
-{
-       return "";
-}
-
 /** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
 bool
 running_32_on_64 ()
@@ -583,3 +586,9 @@ DCPOMATIC_ENABLE_WARNINGS
        TransformProcessType (&serial, kProcessTransformToForegroundApplication);
 }
 
+
+string
+dcpomatic::get_process_id ()
+{
+       return dcp::raw_convert<string>(getpid());
+}