summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-23 02:54:20 -0800
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:49:07 +0100
commit6f349a796c718b598acd72d541eea7bcc4649325 (patch)
treefd619e3d49d5eab0cd48ea403b513be811c273aa /platform
parent1c91f09fdafdaced5b48ac66390bc9733e50a4c8 (diff)
downloadqtlocation-mapboxgl-6f349a796c718b598acd72d541eea7bcc4649325.tar.gz
execute the correct server path and use the exepath for application root rather than the cwd
Diffstat (limited to 'platform')
-rw-r--r--platform/default/application_root.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/platform/default/application_root.cpp b/platform/default/application_root.cpp
index 654d105c70..6669a049a4 100644
--- a/platform/default/application_root.cpp
+++ b/platform/default/application_root.cpp
@@ -1,14 +1,28 @@
#include <mbgl/platform/platform.hpp>
-#include <mbgl/util/uv.hpp>
+#include <uv.h>
+#include <libgen.h>
namespace mbgl {
namespace platform {
// Returns the path to the root folder of the application.
const std::string &applicationRoot() {
- static const std::string root = uv::cwd();
+ static const std::string root = []() -> std::string {
+ size_t max = 0;
+ std::string dir;
+ do {
+ // Gradually increase the length of the string in case the path was truncated.
+ max += 256;
+ dir.resize(max);
+ uv_exepath(const_cast<char *>(dir.data()), &max);
+ } while (max == dir.size());
+ dir.resize(max - 1);
+ dir = dirname(const_cast<char *>(dir.c_str()));
+ return dir;
+ }();
return root;
}
+
}
}