use the default cache location on ios to avoid writing to unwritable file system locations

This commit is contained in:
Konstantin Käfer
2014-09-24 17:08:44 +02:00
parent 992d9ff051
commit 1209744b38
6 changed files with 27 additions and 5 deletions

19
common/ios.mm Normal file
View File

@@ -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.

View File

@@ -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);

View File

@@ -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:

View File

@@ -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);
}

View File

@@ -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) {