From d6874d05b1800f3f68cf109fb7818b68b59c213c Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 15 Nov 2008 15:28:17 +0000 Subject: Allow opening of local files from anywhere, not just the parent of the current dir. svn path=/trunk/netsurf/; revision=5695 --- amiga/misc.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'amiga/misc.c') diff --git a/amiga/misc.c b/amiga/misc.c index 851f3c837..c77788eae 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -1,5 +1,4 @@ /* - * Copyright 2004 James Bursa * Copyright 2008 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ @@ -24,6 +23,7 @@ #include #include "utils/messages.h" #include +#include void warn_user(const char *warning, const char *detail) { @@ -51,14 +51,36 @@ void die(const char *error) char *url_to_path(const char *url) { - return (char *)strdup(url + 5); + char *tmps,*unesc; + CURL *curl; + + if(tmps = strchr(url,'/')) + { + if(tmps = strchr(tmps+1,'/')) + { + if(tmps = strchr(tmps+1,'/')) + { + if(curl = curl_easy_init()) + { + unesc = curl_easy_unescape(curl,tmps+1,0,NULL); + tmps = strdup(unesc); + curl_free(unesc); + curl_easy_cleanup(curl); + return tmps; + + } + } + } + } + + return strdup((char *)url); } char *path_to_url(const char *path) { - char *r = malloc(strlen(path) + 7 + 1); + char *r = malloc(strlen(path) + 8 + 1); - strcpy(r, "file://"); + strcpy(r, "file:///"); strcat(r, path); return r; -- cgit v1.2.3