projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
816872f
)
Clean up handling of paths relative to the executable.
author
Carl Hetherington
<cth@carlh.net>
Wed, 3 Jun 2020 10:21:28 +0000
(12:21 +0200)
committer
Carl Hetherington
<cth@carlh.net>
Wed, 3 Jun 2020 23:20:11 +0000
(
01:20
+0200)
src/lib/cross.h
patch
|
blob
|
history
src/lib/cross_linux.cc
patch
|
blob
|
history
src/lib/cross_osx.cc
patch
|
blob
|
history
src/lib/cross_windows.cc
patch
|
blob
|
history
src/lib/util.cc
patch
|
blob
|
history
src/tools/dcpomatic.cc
patch
|
blob
|
history
diff --git
a/src/lib/cross.h
b/src/lib/cross.h
index 1145812696ddbda442bae1ef16315f6001dc53c0..4d3d2b2c79f21ca7891d0383a3912a68bea1cc44 100644
(file)
--- a/
src/lib/cross.h
+++ b/
src/lib/cross.h
@@
-49,17
+49,14
@@
extern boost::filesystem::path openssl_path ();
#ifdef DCPOMATIC_DISK
extern boost::filesystem::path disk_writer_path ();
#endif
#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);
#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 uint64_t thread_id ();
extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags);
extern boost::filesystem::path home_directory ();
@@
-67,6
+64,7
@@
extern std::string command_and_read (std::string cmd);
extern bool running_32_on_64 ();
extern void unprivileged ();
extern boost::filesystem::path config_path ();
extern bool running_32_on_64 ();
extern void unprivileged ();
extern boost::filesystem::path config_path ();
+extern boost::filesystem::path directory_containing_executable ();
class PrivilegeEscalator
{
class PrivilegeEscalator
{
diff --git
a/src/lib/cross_linux.cc
b/src/lib/cross_linux.cc
index c8b890bf111f94681d8516f912206ab2f27962fe..7b807a44120ac10d62fc249896ac6fd894eb69bd 100644
(file)
--- a/
src/lib/cross_linux.cc
+++ b/
src/lib/cross_linux.cc
@@
-140,20
+140,36
@@
mount_info ()
return m;
}
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 ()
{
boost::filesystem::path
openssl_path ()
{
- return "dcpomatic2_openssl";
+ return
directory_containing_executable() /
"dcpomatic2_openssl";
}
}
+
#ifdef DCPOMATIC_DISK
boost::filesystem::path
disk_writer_path ()
{
#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
}
#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.
/* 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.
@@
-186,10
+202,11
@@
Waker::~Waker ()
}
}
+
void
void
-start_tool (
boost::filesystem::path dcpomatic, string executable, string
)
+start_tool (
string executable
)
{
{
- boost::filesystem::path batch = d
cpomatic.parent_path
() / executable;
+ boost::filesystem::path batch = d
irectory_containing_executable
() / executable;
pid_t pid = fork ();
if (pid == 0) {
pid_t pid = fork ();
if (pid == 0) {
@@
-198,18
+215,21
@@
start_tool (boost::filesystem::path dcpomatic, string executable, string)
}
}
}
}
+
void
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
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 ()
{
uint64_t
thread_id ()
{
diff --git
a/src/lib/cross_osx.cc
b/src/lib/cross_osx.cc
index a15ad032257be78bc907b2d107e6d54190186900..574cc8660887b059185dc5d120fa18fb6d114af7 100644
(file)
--- a/
src/lib/cross_osx.cc
+++ b/
src/lib/cross_osx.cc
@@
-32,6
+32,9
@@
extern "C" {
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#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>
#include <sys/sysctl.h>
#include <mach-o/dyld.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
@@
-91,14
+94,13
@@
cpu_info ()
return info;
}
return info;
}
-/** @return Path of the Contents directory in the .app */
+
boost::filesystem::path
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)) {
uint32_t size = 1024;
char buffer[size];
if (_NSGetExecutablePath (buffer, &size)) {
@@
-107,29
+109,29
@@
app_contents ()
boost::filesystem::path path (buffer);
path = boost::filesystem::canonical (path);
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 ()
{
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)
{
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 ());
}
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 ()
{
list<pair<string, string> >
mount_info ()
{
@@
-140,21
+142,16
@@
mount_info ()
boost::filesystem::path
openssl_path ()
{
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 ()
{
#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
}
#endif
@@
-196,9
+193,9
@@
Waker::~Waker ()
}
void
}
void
-start_tool (
boost::filesystem::path dcpomatic,
string executable, string app)
+start_tool (string executable, string app)
{
{
- boost::filesystem::path batch = d
cpomatic.parent_path
();
+ boost::filesystem::path batch = d
irectory_containing_executable
();
batch = batch.parent_path (); // MacOS
batch = batch.parent_path (); // Contents
batch = batch.parent_path (); // DCP-o-matic.app
batch = batch.parent_path (); // MacOS
batch = batch.parent_path (); // Contents
batch = batch.parent_path (); // DCP-o-matic.app
@@
-215,18
+212,21
@@
start_tool (boost::filesystem::path dcpomatic, string executable, string app)
}
}
}
}
+
void
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
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 ()
{
uint64_t
thread_id ()
{
diff --git
a/src/lib/cross_windows.cc
b/src/lib/cross_windows.cc
index 8ccc790d6c287e4a1b6592fe00724671b87f6c64..d732e9fe5e71c426c255429c6ce6a90ad16874c3 100644
(file)
--- a/
src/lib/cross_windows.cc
+++ b/
src/lib/cross_windows.cc
@@
-127,8
+127,7
@@
run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
}
wchar_t dir[512];
}
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;
SetCurrentDirectory (dir);
STARTUPINFO startup_info;
@@
-185,32
+184,37
@@
mount_info ()
return m;
}
return m;
}
-static boost::filesystem::path
-executable_path ()
+
+boost::filesystem::path
+directory_containing_executable ()
{
return boost::dll::program_location().parent_path();
}
{
return boost::dll::program_location().parent_path();
}
+
boost::filesystem::path
shared_path ()
{
boost::filesystem::path
shared_path ()
{
- return
executable_path
().parent_path();
+ return
directory_containing_executable
().parent_path();
}
}
+
boost::filesystem::path
openssl_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 ()
{
#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
}
#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.
/* 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.
@@
-246,10
+250,11
@@
Waker::~Waker ()
}
}
+
void
void
-start_tool (
boost::filesystem::path dcpomatic, string executable, string
)
+start_tool (
string executable
)
{
{
- boost::filesystem::path batch = d
cpomatic.parent_path
() / executable;
+ boost::filesystem::path batch = d
irectory_containing_executable
() / executable;
STARTUPINFO startup_info;
ZeroMemory (&startup_info, sizeof (startup_info));
STARTUPINFO startup_info;
ZeroMemory (&startup_info, sizeof (startup_info));
@@
-263,18
+268,21
@@
start_tool (boost::filesystem::path dcpomatic, string executable, string)
CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
}
CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
}
+
void
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
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 ()
{
uint64_t
thread_id ()
{
diff --git
a/src/lib/util.cc
b/src/lib/util.cc
index bff205cfb3496dcef7bd58575cb36a9b4f8d9293..e0efbc6f5254da21a9dc8d5801c1e8d2acf1746a 100644
(file)
--- a/
src/lib/util.cc
+++ b/
src/lib/util.cc
@@
-362,7
+362,7
@@
dcpomatic_setup ()
/* Add our library directory to the libltdl search path so that
xmlsec can find xmlsec1-openssl.
*/
/* 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
lib /= "Frameworks";
setenv ("LTDL_LIBRARY_PATH", lib.c_str (), 1);
#endif
diff --git
a/src/tools/dcpomatic.cc
b/src/tools/dcpomatic.cc
index 3168197d519b49d00eef7249734824f51e5deb5e..cef7cf602c76f7f7389aad93cb584bce8d8e76b3 100644
(file)
--- a/
src/tools/dcpomatic.cc
+++ b/
src/tools/dcpomatic.cc
@@
-812,7
+812,7
@@
private:
}
/** @return false if we succeeded, true if not */
}
/** @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
{
/* i = 0; try to connect via socket
i = 1; try again, and then try to start the tool
@@
-838,7
+838,7
@@
private:
}
if (i == 1) {
}
if (i == 1) {
- start (
wx_to_std (wxStandardPaths::Get().GetExecutablePath())
);
+ start ();
}
dcpomatic_sleep_seconds (1);
}
dcpomatic_sleep_seconds (1);
@@
-864,7
+864,7
@@
private:
_film->write_metadata ();
_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."));
}
}
error_dialog (this, _("Could not find batch converter."));
}
}
@@
-875,7
+875,7
@@
private:
return;
}
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."));
}
}
error_dialog (this, _("Could not find player."));
}
}