summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-03-29 20:57:14 +0200
committerCarl Hetherington <cth@carlh.net>2020-03-29 20:57:14 +0200
commit87bcb59c8d791624f60f0d3325108d4156489bb6 (patch)
tree10b6820a68cac5421e051382bcf359bca4c64960 /src
parent9ac8c9dfb2cc2f8264a6c641718558a3344e22d2 (diff)
Use boost::dll::program_location() rather than home-baked versions.
Diffstat (limited to 'src')
-rw-r--r--src/lib/cross_linux.cc3
-rw-r--r--src/lib/cross_osx.cc13
-rw-r--r--src/lib/cross_windows.cc6
3 files changed, 6 insertions, 16 deletions
diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc
index 06c9b521b..239d10c31 100644
--- a/src/lib/cross_linux.cc
+++ b/src/lib/cross_linux.cc
@@ -31,6 +31,7 @@ extern "C" {
}
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
+#include <boost/dll/runtime_symbol_info.hpp>
#include <unistd.h>
#include <mntent.h>
#include <sys/types.h>
@@ -142,7 +143,7 @@ openssl_path ()
boost::filesystem::path
dist_writer_path ()
{
- return "dcpomatic2_dist_writer";
+ return boost::dll::program_location().parent_path() / "dcpomatic2_dist_writer";
}
/* Apparently there is no way to create an ofstream using a UTF-8
diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc
index 52d3d647b..115d3e91e 100644
--- a/src/lib/cross_osx.cc
+++ b/src/lib/cross_osx.cc
@@ -31,6 +31,7 @@ extern "C" {
}
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
+#include <boost/dll/runtime_symbol_info.hpp>
#include <sys/sysctl.h>
#include <mach-o/dyld.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
@@ -89,17 +90,7 @@ cpu_info ()
boost::filesystem::path
app_contents ()
{
- uint32_t size = 1024;
- char buffer[size];
- if (_NSGetExecutablePath (buffer, &size)) {
- throw runtime_error ("_NSGetExecutablePath failed");
- }
-
- boost::filesystem::path path (buffer);
- path = boost::filesystem::canonical (path);
- path = path.parent_path ();
- path = path.parent_path ();
- return path;
+ return boost::dll::program_location().parent_path().parent_path();
}
boost::filesystem::path
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc
index 8d3ddbb8f..697b45ef0 100644
--- a/src/lib/cross_windows.cc
+++ b/src/lib/cross_windows.cc
@@ -32,6 +32,7 @@ extern "C" {
}
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
+#include <boost/dll/runtime_symbol_info.hpp>
#include <windows.h>
#include <winternl.h>
#include <winioctl.h>
@@ -182,10 +183,7 @@ mount_info ()
static boost::filesystem::path
executable_path ()
{
- wchar_t dir[512];
- GetModuleFileName (GetModuleHandle(0), dir, sizeof(dir));
- PathRemoveFileSpec (dir);
- return dir;
+ return boost::dll::program_location().parent_path();
}
boost::filesystem::path