diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-09-24 17:08:44 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-09-24 17:08:44 +0200 |
commit | 1209744b38da0252731812d4cc5371be960fb3c3 (patch) | |
tree | 7e845b30550d6ca72f1580cb51490139f0e8ca18 | |
parent | 992d9ff051ecd45f83160930c43c9d5a2da04048 (diff) | |
download | qtlocation-mapboxgl-1209744b38da0252731812d4cc5371be960fb3c3.tar.gz |
use the default cache location on ios to avoid writing to unwritable file system locations
-rw-r--r-- | common/ios.mm | 19 | ||||
-rw-r--r-- | include/mbgl/platform/platform.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/storage/file_source.hpp | 2 | ||||
m--------- | ios/mapbox-gl-cocoa | 0 | ||||
-rw-r--r-- | src/map/map.cpp | 2 | ||||
-rw-r--r-- | src/storage/file_source.cpp | 4 |
6 files changed, 26 insertions, 4 deletions
diff --git a/common/ios.mm b/common/ios.mm new file mode 100644 index 0000000000..1076343e24 --- /dev/null +++ b/common/ios.mm @@ -0,0 +1,19 @@ +#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); + NSString *libraryDirectory = [paths objectAtIndex:0]; + return [[libraryDirectory stringByAppendingPathComponent:@"cache.db"] UTF8String]; +} + +} +} + + +// Returns the path to the default cache database on this system. diff --git a/include/mbgl/platform/platform.hpp b/include/mbgl/platform/platform.hpp index 6356d81bb1..b7107bb9cd 100644 --- a/include/mbgl/platform/platform.hpp +++ b/include/mbgl/platform/platform.hpp @@ -17,6 +17,9 @@ std::string uppercase(const std::string &string); // Lowercase a string, potentially using platform-specific routines. std::string lowercase(const std::string &string); +// Returns the path to the default cache database on this system. +std::string defaultCacheDatabase(); + // Shows an alpha image with the specified dimensions in a named window. void show_debug_image(std::string name, const char *data, size_t width, size_t height); diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp index 06d416d0c6..5933aea483 100644 --- a/include/mbgl/storage/file_source.hpp +++ b/include/mbgl/storage/file_source.hpp @@ -24,7 +24,7 @@ private: FileSource& operator=(FileSource &&) = delete; public: - FileSource(uv_loop_t *loop); + FileSource(uv_loop_t *loop, const std::string &path); ~FileSource(); public: diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa -Subproject f3829151abb7582568433c159eb3a7e50a7ab7d +Subproject c22686c5bc9f1cafd37b684bab31b70a38ed649 diff --git a/src/map/map.cpp b/src/map/map.cpp index eabf7b8fe8..05c56c10ee 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -571,7 +571,7 @@ void Map::prepare() { view.make_active(); if (!fileSource) { - fileSource = std::make_shared<FileSource>(**loop); + fileSource = std::make_shared<FileSource>(**loop, platform::defaultCacheDatabase()); glyphStore = std::make_shared<GlyphStore>(fileSource); } diff --git a/src/storage/file_source.cpp b/src/storage/file_source.cpp index ef2b036e50..52a3872cb9 100644 --- a/src/storage/file_source.cpp +++ b/src/storage/file_source.cpp @@ -8,9 +8,9 @@ namespace mbgl { -FileSource::FileSource(uv_loop_t *loop_) +FileSource::FileSource(uv_loop_t *loop_, const std::string &path) : thread_id(uv_thread_self()), - store(util::ptr<SQLiteStore>(new SQLiteStore(loop_, "cache.db"))), + store(util::ptr<SQLiteStore>(new SQLiteStore(loop_, path))), loop(loop_), queue(new uv_messenger_t) { |