diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-01-22 17:40:12 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-02-04 10:49:06 +0100 |
commit | 9a549094e02b046eb67a3c3a1ed8df96791825ca (patch) | |
tree | e6b867eac917fb852354e9171a2fefacbb474aa2 /platform | |
parent | 78376acea78056d9c20cc39bf98323adeedd22aa (diff) | |
download | qtlocation-mapboxgl-9a549094e02b046eb67a3c3a1ed8df96791825ca.tar.gz |
make ios compile
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/application_root.mm | 4 | ||||
-rw-r--r-- | platform/default/application_root.cpp | 5 | ||||
-rw-r--r-- | platform/default/asset_request_libuv.cpp | 14 | ||||
-rw-r--r-- | platform/ios/cache_database_library.mm | 21 |
4 files changed, 17 insertions, 27 deletions
diff --git a/platform/darwin/application_root.mm b/platform/darwin/application_root.mm index 19b872c54d..d4702c7ec5 100644 --- a/platform/darwin/application_root.mm +++ b/platform/darwin/application_root.mm @@ -5,8 +5,8 @@ namespace mbgl { namespace platform { -// Returns the path to the default shader cache on this system. -std::string applicationRoot() { +// Returns the path to the root folder of the application. +const std::string &applicationRoot() { static const std::string root = []() -> std::string { NSString *path = [[[NSBundle mainBundle] resourceURL] path]; return {[path cStringUsingEncoding : NSUTF8StringEncoding], diff --git a/platform/default/application_root.cpp b/platform/default/application_root.cpp index f25a44d46b..654d105c70 100644 --- a/platform/default/application_root.cpp +++ b/platform/default/application_root.cpp @@ -5,11 +5,10 @@ namespace mbgl { namespace platform { -// Returns the path the application root. -std::string applicationRoot() { +// Returns the path to the root folder of the application. +const std::string &applicationRoot() { static const std::string root = uv::cwd(); return root; } - } } diff --git a/platform/default/asset_request_libuv.cpp b/platform/default/asset_request_libuv.cpp index 006e573631..4a6fc88eb6 100644 --- a/platform/default/asset_request_libuv.cpp +++ b/platform/default/asset_request_libuv.cpp @@ -3,6 +3,7 @@ #include <mbgl/util/std.hpp> #include <mbgl/util/util.hpp> #include <mbgl/util/uv.hpp> +#include <mbgl/platform/platform.hpp> #include <uv.h> #include <boost/algorithm/string.hpp> @@ -47,7 +48,18 @@ AssetRequestImpl::~AssetRequestImpl() { AssetRequestImpl::AssetRequestImpl(AssetRequest *request_, uv_loop_t *loop) : request(request_) { req.data = this; - uv_fs_open(loop, &req, (request->resource.url.substr(8)).c_str(), O_RDONLY, S_IRUSR, fileOpened); + + const auto &url = request->resource.url; + std::string path; + if (url.size() <= 8 || url[8] == '/') { + // This is an empty or absolute path. + path = url.substr(8); + } else { + // This is a relative path. Prefix with the application root. + path = platform::applicationRoot() + "/" + url.substr(8); + } + + uv_fs_open(loop, &req, path.c_str(), O_RDONLY, S_IRUSR, fileOpened); } void AssetRequestImpl::fileOpened(uv_fs_t *req) { diff --git a/platform/ios/cache_database_library.mm b/platform/ios/cache_database_library.mm deleted file mode 100644 index 7989e73a4e..0000000000 --- a/platform/ios/cache_database_library.mm +++ /dev/null @@ -1,21 +0,0 @@ -#import <Foundation/Foundation.h> - -#include <mbgl/platform/platform.hpp> - -namespace mbgl { -namespace platform { - -// Returns the path to the default cache database on this system. -std::string defaultCacheDatabase() { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); - if ([paths count] == 0) { - // Disable the cache if we don't have a location to write. - return ""; - } - - NSString *libraryDirectory = [paths objectAtIndex:0]; - return [[libraryDirectory stringByAppendingPathComponent:@"cache.db"] UTF8String]; -} - -} -} |