diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-01-21 19:30:58 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-02-04 10:49:05 +0100 |
commit | 8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd (patch) | |
tree | e3f0e8f4b16071667c6a4fdf706740335500dbc6 /macosx | |
parent | 5503aef6907b1fea74d6bdbe696f02b9f016f752 (diff) | |
download | qtlocation-mapboxgl-8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd.tar.gz |
rearrange tests and add storage tests
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index 6956f04d6d..a81d5e2c16 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -72,12 +72,35 @@ } @end +// Returns the path to the default cache database on this system. +std::string defaultCacheDatabase() { + NSArray *paths = + NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + if ([paths count] == 0) { + // Disable the cache if we don't have a location to write. + return ""; + } + + NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Mapbox GL"]; + + if (![[NSFileManager defaultManager] createDirectoryAtPath:path + withIntermediateDirectories:YES + attributes:nil + error:nil]) { + // Disable the cache if we couldn't create the directory. + return ""; + } + + return [[path stringByAppendingPathComponent:@"cache.db"] UTF8String]; +} + + int main() { mbgl::Log::Set<mbgl::NSLogBackend>(); GLFWView view; - mbgl::SQLiteCache cache(mbgl::platform::defaultCacheDatabase()); + mbgl::SQLiteCache cache(defaultCacheDatabase()); mbgl::DefaultFileSource fileSource(&cache); mbgl::Map map(view, fileSource); |