#ifdef DCPOMATIC_DISK
extern boost::filesystem::path disk_writer_path ();
#endif
-#ifdef DCPOMATIC_OSX
-extern boost::filesystem::path app_contents ();
-#endif
#ifdef DCPOMATIC_WINDOWS
extern void maybe_open_console ();
#endif
extern boost::filesystem::path shared_path ();
extern FILE * fopen_boost (boost::filesystem::path, std::string);
extern int dcpomatic_fseek (FILE *, int64_t, int);
-extern void start_batch_converter (boost::filesystem::path dcpomatic);
-extern void start_player (boost::filesystem::path dcpomatic);
+extern void start_batch_converter ();
+extern void start_player ();
extern uint64_t thread_id ();
extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags);
extern boost::filesystem::path home_directory ();
extern bool running_32_on_64 ();
extern void unprivileged ();
extern boost::filesystem::path config_path ();
+extern boost::filesystem::path directory_containing_executable ();
class PrivilegeEscalator
{
return m;
}
+
+boost::filesystem::path
+directory_containing_executable ()
+{
+#if BOOST_VERSION >= 106100
+ return boost::dll::program_location().parent_path();
+#else
+ char buffer[PATH_MAX];
+ ssize_t N = readlink ("/proc/self/exe", buffer, PATH_MAX);
+ return boost::filesystem::path(string(buffer, N)).parent_path();
+#endif
+}
+
+
boost::filesystem::path
openssl_path ()
{
- return "dcpomatic2_openssl";
+ return directory_containing_executable() / "dcpomatic2_openssl";
}
+
#ifdef DCPOMATIC_DISK
boost::filesystem::path
disk_writer_path ()
{
- return boost::dll::program_location().parent_path() / "dcpomatic2_disk_writer";
+ return directory_containing_executable() / "dcpomatic2_disk_writer";
}
#endif
+
/* Apparently there is no way to create an ofstream using a UTF-8
filename under Windows. We are hence reduced to using fopen
with this wrapper.
}
+
void
-start_tool (boost::filesystem::path dcpomatic, string executable, string)
+start_tool (string executable)
{
- boost::filesystem::path batch = dcpomatic.parent_path() / executable;
+ boost::filesystem::path batch = directory_containing_executable() / executable;
pid_t pid = fork ();
if (pid == 0) {
}
}
+
void
-start_batch_converter (boost::filesystem::path dcpomatic)
+start_batch_converter ()
{
- start_tool (dcpomatic, "dcpomatic2_batch", "DCP-o-matic\\ 2\\ Batch\\ Converter.app");
+ start_tool ("dcpomatic2_batch");
}
+
void
-start_player (boost::filesystem::path dcpomatic)
+start_player ()
{
- start_tool (dcpomatic, "dcpomatic2_player", "DCP-o-matic\\ 2\\ Player.app");
+ start_tool ("dcpomatic2_player");
}
+
uint64_t
thread_id ()
{
#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 <sys/sysctl.h>
#include <mach-o/dyld.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
return info;
}
-/** @return Path of the Contents directory in the .app */
+
boost::filesystem::path
-app_contents ()
+directory_containing_executable ()
{
- /* Could use boost::dll::program_location().parent_path().parent_path() but that
- * boost library isn't in the 10.6 environment we're currently using and I don't
- * really want to change it right now.
- */
+#if BOOST_VERSION >= 106100
+ return boost::dll::program_location().parent_path();
+#else
uint32_t size = 1024;
char buffer[size];
if (_NSGetExecutablePath (buffer, &size)) {
boost::filesystem::path path (buffer);
path = boost::filesystem::canonical (path);
- path = path.parent_path ();
- path = path.parent_path ();
- return path;
+ return path.parent_path ();
+#endif
}
+
boost::filesystem::path
shared_path ()
{
- return app_contents() / "Resources";
+ return directory_containing_executable().parent_path() / "Resources";
}
+
void
run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
{
- boost::filesystem::path path = app_contents();
- path /= "MacOS";
- path /= "ffprobe";
+ boost::filesystem::path path = directory_containing_executable () / "ffprobe";
string ffprobe = "\"" + path.string() + "\" \"" + content.string() + "\" 2> \"" + out.string() + "\"";
LOG_GENERAL (N_("Probing with %1"), ffprobe);
system (ffprobe.c_str ());
}
+
list<pair<string, string> >
mount_info ()
{
boost::filesystem::path
openssl_path ()
{
- boost::filesystem::path path = app_contents();
- path /= "MacOS";
- path /= "openssl";
- return path;
+ return directory_containing_executable() / "openssl";
}
+
#ifdef DCPOMATIC_DISK
/* Note: this isn't actually used at the moment as the disk writer is started as a service */
boost::filesystem::path
disk_writer_path ()
{
- boost::filesystem::path path = app_contents();
- path /= "MacOS";
- path /= "dcpomatic2_disk_writer";
- return path;
+ return directory_containing_executable() / "dcpomatic2_disk_writer";
}
#endif
}
void
-start_tool (boost::filesystem::path dcpomatic, string executable, string app)
+start_tool (string executable, string app)
{
- boost::filesystem::path batch = dcpomatic.parent_path ();
+ 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
}
}
+
void
-start_batch_converter (boost::filesystem::path dcpomatic)
+start_batch_converter ()
{
- start_tool (dcpomatic, "dcpomatic2_batch", "DCP-o-matic\\ 2\\ Batch\\ Converter.app");
+ start_tool ("dcpomatic2_batch", "DCP-o-matic\\ 2\\ Batch\\ Converter.app");
}
+
void
-start_player (boost::filesystem::path dcpomatic)
+start_player ()
{
- start_tool (dcpomatic, "dcpomatic2_player", "DCP-o-matic\\ 2\\ Player.app");
+ start_tool ("dcpomatic2_player", "DCP-o-matic\\ 2\\ Player.app");
}
+
uint64_t
thread_id ()
{
}
wchar_t dir[512];
- GetModuleFileName (GetModuleHandle (0), dir, sizeof (dir));
- PathRemoveFileSpec (dir);
+ MultiByteToWideChar (CP_UTF8, 0, directory_containing_executable().string().c_str(), -1, dir, sizeof(dir));
SetCurrentDirectory (dir);
STARTUPINFO startup_info;
return m;
}
-static boost::filesystem::path
-executable_path ()
+
+boost::filesystem::path
+directory_containing_executable ()
{
return boost::dll::program_location().parent_path();
}
+
boost::filesystem::path
shared_path ()
{
- return executable_path().parent_path();
+ return directory_containing_executable().parent_path();
}
+
boost::filesystem::path
openssl_path ()
{
- return executable_path() / "openssl.exe";
+ return directory_containing_executable() / "openssl.exe";
}
+
#ifdef DCPOMATIC_DISK
boost::filesystem::path
disk_writer_path ()
{
- return executable_path() / "dcpomatic2_disk_writer.exe";
+ return directory_containing_executable() / "dcpomatic2_disk_writer.exe";
}
#endif
+
/* Apparently there is no way to create an ofstream using a UTF-8
filename under Windows. We are hence reduced to using fopen
with this wrapper.
}
+
void
-start_tool (boost::filesystem::path dcpomatic, string executable, string)
+start_tool (string executable)
{
- boost::filesystem::path batch = dcpomatic.parent_path() / executable;
+ boost::filesystem::path batch = directory_containing_executable() / executable;
STARTUPINFO startup_info;
ZeroMemory (&startup_info, sizeof (startup_info));
CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
}
+
void
-start_batch_converter (boost::filesystem::path dcpomatic)
+start_batch_converter ()
{
- start_tool (dcpomatic, "dcpomatic2_batch", "DCP-o-matic\\ 2\\ Batch\\ Converter.app");
+ start_tool ("dcpomatic2_batch");
}
+
void
-start_player (boost::filesystem::path dcpomatic)
+start_player ()
{
- start_tool (dcpomatic, "dcpomatic2_player", "DCP-o-matic\\ 2\\ Player.app");
+ start_tool ("dcpomatic2_player");
}
+
uint64_t
thread_id ()
{
/* Add our library directory to the libltdl search path so that
xmlsec can find xmlsec1-openssl.
*/
- boost::filesystem::path lib = app_contents ();
+ boost::filesystem::path lib = directory_containing_executable().parent_path();
lib /= "Frameworks";
setenv ("LTDL_LIBRARY_PATH", lib.c_str (), 1);
#endif
}
/** @return false if we succeeded, true if not */
- bool send_to_other_tool (int port, function<void(boost::filesystem::path)> start, string message)
+ bool send_to_other_tool (int port, function<void()> start, string message)
{
/* i = 0; try to connect via socket
i = 1; try again, and then try to start the tool
}
if (i == 1) {
- start (wx_to_std (wxStandardPaths::Get().GetExecutablePath()));
+ start ();
}
dcpomatic_sleep_seconds (1);
_film->write_metadata ();
- if (send_to_other_tool (BATCH_JOB_PORT, bind (&start_batch_converter, _1), _film->directory()->string())) {
+ if (send_to_other_tool (BATCH_JOB_PORT, &start_batch_converter, _film->directory()->string())) {
error_dialog (this, _("Could not find batch converter."));
}
}
return;
}
- if (send_to_other_tool (PLAYER_PLAY_PORT, bind (&start_player, _1), _film->dir(_film->dcp_name(false)).string())) {
+ if (send_to_other_tool (PLAYER_PLAY_PORT, &start_player, _film->dir(_film->dcp_name(false)).string())) {
error_dialog (this, _("Could not find player."));
}
}