use the default cache location on ios to avoid writing to unwritable file system locations
This commit is contained in:
19
common/ios.mm
Normal file
19
common/ios.mm
Normal 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.
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Submodule ios/mapbox-gl-cocoa updated: f3829151ab...c22686c5bc
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user