Caching bin path

This commit is contained in:
Daniel Wolf 2016-09-18 22:00:08 +02:00
parent 0ab009e17a
commit cf13499158
1 changed files with 25 additions and 22 deletions

View File

@ -11,6 +11,7 @@ using boost::filesystem::path;
using std::string; using std::string;
path getBinPath() { path getBinPath() {
static const path binPath = [] {
try { try {
// Determine path length // Determine path length
int pathLength = wai_getExecutablePath(nullptr, 0, nullptr); int pathLength = wai_getExecutablePath(nullptr, 0, nullptr);
@ -34,6 +35,8 @@ path getBinPath() {
} catch (...) { } catch (...) {
std::throw_with_nested(std::runtime_error("Could not determine path of bin directory.")); std::throw_with_nested(std::runtime_error("Could not determine path of bin directory."));
} }
}();
return binPath;
} }
path getBinDirectory() { path getBinDirectory() {