summaryrefslogtreecommitdiff
path: root/amiga/misc.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2010-07-11 20:42:06 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2010-07-11 20:42:06 +0000
commitd4c519cc05536486c202a399826633b1b025c22a (patch)
treeb02cd9e1c5a29cf9a69ad9ac3407fea0727eae02 /amiga/misc.c
parent1c48e85ce9b7c82cb6b5e5d3bee88ad77d001c1c (diff)
downloadnetsurf-d4c519cc05536486c202a399826633b1b025c22a.tar.gz
netsurf-d4c519cc05536486c202a399826633b1b025c22a.tar.bz2
Amiga file: URIs now translate the : in device names to / (and back), which conforms
better to the spec (: will still work for compatibility, but may have problems). This fixes a problem with directory browsing. Directory parent link now uses the full parent path returned by url_parent instead of one relative to the current directory. svn path=/trunk/netsurf/; revision=10629
Diffstat (limited to 'amiga/misc.c')
-rwxr-xr-xamiga/misc.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/amiga/misc.c b/amiga/misc.c
index e07f9ecbd..04e38469a 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -59,7 +59,7 @@ void die(const char *error)
char *url_to_path(const char *url)
{
- char *tmps, *unesc;
+ char *tmps, *unesc, *slash, *colon, *url2;
CURL *curl;
if (strncmp(url, "file://", SLEN("file://")) != 0)
@@ -72,25 +72,57 @@ char *url_to_path(const char *url)
url += SLEN("/");
+ url2 = malloc(strlen(url) + 2);
+ strcpy(url2, url);
+
+ colon = strchr(url2, ':');
+ if(colon == NULL)
+ {
+ if(slash = strchr(url2, '/'))
+ {
+ *slash = ':';
+ }
+ else
+ {
+ int len = strlen(url2);
+ url2[len] = ':';
+ url2[len + 1] = '\0';
+ }
+ }
+
if(curl = curl_easy_init())
{
- unesc = curl_easy_unescape(curl,url,0,NULL);
+ unesc = curl_easy_unescape(curl,url2,0,NULL);
tmps = strdup(unesc);
+ free(url2);
curl_free(unesc);
curl_easy_cleanup(curl);
return tmps;
}
- return strdup((char *)url);
+ return (char *)url2;
}
char *path_to_url(const char *path)
{
- char *r = malloc(strlen(path) + SLEN("file:///") + 1);
+ char *colon = NULL;
+ char *r = NULL;
+ char newpath[1024 + strlen(path)];
+ BPTR lock = 0;
- strcpy(r, "file:///");
- strcat(r, path);
+ if(lock = Lock(path, MODE_OLDFILE))
+ {
+ DevNameFromLock(lock, newpath, sizeof newpath, DN_FULLPATH);
+ UnLock(lock);
+ }
+ r = malloc(strlen(newpath) + SLEN("file:///") + 1);
+
+ if(colon = strchr(newpath, ':')) *colon = '/';
+
+ strcpy(r, "file:///");
+ strcat(r, newpath);
+printf("ptu %s => %s\n",path, r);
return r;
}