summaryrefslogtreecommitdiff
path: root/common/osx.mm
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-09-26 16:10:39 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-09-26 16:10:39 +0200
commitb9628c86543ffe819b030c3d84f65fa09e084850 (patch)
treee98e154b307a6a2b9eaa88c40d9c7fff8702e308 /common/osx.mm
parent1209744b38da0252731812d4cc5371be960fb3c3 (diff)
downloadqtlocation-mapboxgl-b9628c86543ffe819b030c3d84f65fa09e084850.tar.gz
add etag support and if-none-match/if-modified-since to cocoa http handling
Diffstat (limited to 'common/osx.mm')
-rw-r--r--common/osx.mm31
1 files changed, 31 insertions, 0 deletions
diff --git a/common/osx.mm b/common/osx.mm
new file mode 100644
index 0000000000..974ea537cb
--- /dev/null
+++ b/common/osx.mm
@@ -0,0 +1,31 @@
+#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(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];
+}
+
+}
+}