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 /macosx | |
parent | 78376acea78056d9c20cc39bf98323adeedd22aa (diff) | |
download | qtlocation-mapboxgl-9a549094e02b046eb67a3c3a1ed8df96791825ca.tar.gz |
make ios compile
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index a81d5e2c16..5c6e67d1bd 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -73,28 +73,30 @@ @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 ""; - } +const std::string &defaultCacheDatabase() { + static const std::string path = []() -> std::string { + 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"]; + NSString *p = [[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 ""; - } + if (![[NSFileManager defaultManager] createDirectoryAtPath:p + withIntermediateDirectories:YES + attributes:nil + error:nil]) { + // Disable the cache if we couldn't create the directory. + return ""; + } - return [[path stringByAppendingPathComponent:@"cache.db"] UTF8String]; + return [[p stringByAppendingPathComponent:@"cache.db"] UTF8String]; + }(); + return path; } - int main() { mbgl::Log::Set<mbgl::NSLogBackend>(); |