summaryrefslogtreecommitdiff
path: root/cocoa/fetch.m
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa/fetch.m')
-rw-r--r--cocoa/fetch.m34
1 files changed, 24 insertions, 10 deletions
diff --git a/cocoa/fetch.m b/cocoa/fetch.m
index ff1496246..df424c3e8 100644
--- a/cocoa/fetch.m
+++ b/cocoa/fetch.m
@@ -19,7 +19,10 @@
#import <Cocoa/Cocoa.h>
#import "utils/log.h"
-#import "content/fetch.h"
+#import "utils/nsurl.h"
+#import "desktop/gui.h"
+
+#import "cocoa/fetch.h"
static char cocoafiletype[200];
@@ -40,9 +43,9 @@ static const struct mimemap_s {
};
-const char *fetch_filetype(const char *unix_path)
+static const char *fetch_filetype(const char *unix_path)
{
- NSString *uti;
+ NSString *uti;
NSString *mimeType = nil;
NSError *utiError = nil;
@@ -56,7 +59,7 @@ const char *fetch_filetype(const char *unix_path)
LOG(("uti call failed"));
- strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
+ strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
return cocoafiletype;
}
@@ -81,19 +84,30 @@ const char *fetch_filetype(const char *unix_path)
eidx++;
}
- strncpy(cocoafiletype,
- cocoamimemap[eidx].mimetype,
+ strncpy(cocoafiletype,
+ cocoamimemap[eidx].mimetype,
sizeof(cocoafiletype));
}
}
LOG(( "\tMIME type for '%s' is '%s'", unix_path, cocoafiletype ));
-
+
return cocoafiletype;
}
-
-char *fetch_mimetype(const char *ro_path)
+static nsurl *gui_get_resource_url(const char *path)
{
- return strdup( fetch_filetype( ro_path ) );
+ nsurl *url = NULL;
+ NSString *nspath = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: path] ofType: @""];
+ if (nspath == nil) return NULL;
+ nsurl_create([[[NSURL fileURLWithPath: nspath] absoluteString] UTF8String], &url);
+ return url;
}
+
+static struct gui_fetch_table fetch_table = {
+ .filetype = fetch_filetype,
+
+ .get_resource_url = gui_get_resource_url,
+};
+
+struct gui_fetch_table *cocoa_fetch_table = &fetch_table;