diff Core/Toolbox.cpp @ 1145:0479d02c6778

Plugins can retrieve the path to Orthanc and to its configuration file
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 11 Sep 2014 13:06:16 +0200
parents 929bf8c2123d
children 6e7e5ed91c2d
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Thu Sep 11 10:26:32 2014 +0200
+++ b/Core/Toolbox.cpp	Thu Sep 11 13:06:16 2014 +0200
@@ -494,7 +494,7 @@
 
 
 #if defined(_WIN32)
-  std::string Toolbox::GetPathToExecutable()
+  static std::string GetPathToExecutableInternal()
   {
     // Yes, this is ugly, but there is no simple way to get the 
     // required buffer size, so we use a big constant
@@ -504,7 +504,7 @@
   }
 
 #elif defined(__linux) || defined(__FreeBSD_kernel__)
-  std::string Toolbox::GetPathToExecutable()
+  static std::string GetPathToExecutableInternal()
   {
     std::vector<char> buffer(PATH_MAX + 1);
     ssize_t bytes = readlink("/proc/self/exe", &buffer[0], buffer.size() - 1);
@@ -517,7 +517,7 @@
   }
 
 #elif defined(__APPLE__) && defined(__MACH__)
-  std::string Toolbox::GetPathToExecutable()
+  static std::string GetPathToExecutableInternal()
   {
     char pathbuf[PATH_MAX + 1];
     unsigned int  bufsize = static_cast<int>(sizeof(pathbuf));
@@ -532,10 +532,17 @@
 #endif
 
 
+  std::string Toolbox::GetPathToExecutable()
+  {
+    boost::filesystem::path p(GetPathToExecutableInternal());
+    return boost::filesystem::absolute(p).string();
+  }
+
+
   std::string Toolbox::GetDirectoryOfExecutable()
   {
-    boost::filesystem::path p(GetPathToExecutable());
-    return p.parent_path().string();
+    boost::filesystem::path p(GetPathToExecutableInternal());
+    return boost::filesystem::absolute(p.parent_path()).string();
   }