diff Core/SystemToolbox.cpp @ 2933:4a38d7d4f0e0

new class: OrthancConfiguration
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Nov 2018 17:08:48 +0100
parents ad0e7def3338
children d924f9bb61cc
line wrap: on
line diff
--- a/Core/SystemToolbox.cpp	Tue Nov 13 17:50:03 2018 +0100
+++ b/Core/SystemToolbox.cpp	Tue Nov 27 17:08:48 2018 +0100
@@ -710,4 +710,31 @@
       } 
     }
   }
+
+
+  std::string SystemToolbox::InterpretRelativePath(const std::string& baseDirectory,
+                                                   const std::string& relativePath)
+  {
+    boost::filesystem::path base(baseDirectory);
+    boost::filesystem::path relative(relativePath);
+
+    /**
+       The following lines should be equivalent to this one: 
+
+       return (base / relative).string();
+
+       However, for some unknown reason, some versions of Boost do not
+       make the proper path resolution when "baseDirectory" is an
+       absolute path. So, a hack is used below.
+    **/
+
+    if (relative.is_absolute())
+    {
+      return relative.string();
+    }
+    else
+    {
+      return (base / relative).string();
+    }
+  }
 }