Use boost::dll::program_location() rather than home-baked versions.
authorCarl Hetherington <cth@carlh.net>
Sun, 29 Mar 2020 18:57:14 +0000 (20:57 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 29 Mar 2020 18:57:14 +0000 (20:57 +0200)
src/lib/cross_linux.cc
src/lib/cross_osx.cc
src/lib/cross_windows.cc

index 06c9b521be31aa4eae1f03b29e4186d2cd4ae76a..239d10c31b03d728037eef97c38fa974d8104dfc 100644 (file)
@@ -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
index 52d3d647b1b568070955eadcc9a780de64424fcc..115d3e91ec89932df9c4ccd02044f9e7dedd0c71 100644 (file)
@@ -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
index 8d3ddbb8fd30c1f3468bf71ffbac3186022df999..697b45ef0e1b03348648de2e8934c248c351d718 100644 (file)
@@ -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