diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2010-04-18 12:37:46 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2010-04-18 12:37:46 +0000 |
commit | 9a95ad79d184510322f4aa505eded83a19fec49a (patch) | |
tree | 9f29859865be28abb4f9088afb414f681ce24818 | |
parent | f81ea3419e1c2374da0c1440755f71d875d6ff6c (diff) | |
download | netsurf-9a95ad79d184510322f4aa505eded83a19fec49a.tar.gz netsurf-9a95ad79d184510322f4aa505eded83a19fec49a.tar.bz2 |
fix url to path on doze
svn path=/trunk/netsurf/; revision=10427
-rw-r--r-- | windows/findfile.c | 27 | ||||
-rw-r--r-- | windows/misc.c | 5 |
2 files changed, 27 insertions, 5 deletions
diff --git a/windows/findfile.c b/windows/findfile.c index f4f5e4557..1516a9fce 100644 --- a/windows/findfile.c +++ b/windows/findfile.c @@ -57,6 +57,33 @@ char *path_to_url(const char *path) return url; } + +char *url_to_path(const char *url) +{ + char *url_path = curl_unescape(url, 0); + char *path; + char *sidx; + + if ((url_path[FILE_SCHEME_PREFIX_LEN + 1] == ':') || + (url_path[FILE_SCHEME_PREFIX_LEN + 1] == '|')) { + /* url_path contains a drive: prefix */ + path = strdup(url_path + FILE_SCHEME_PREFIX_LEN); + + /* swap / for \ */ + sidx = strrchr(path, '/'); + while (sidx != NULL) { + *sidx = '\\'; + sidx = strrchr(path, '/'); + } + } else { + /* return the absolute path including leading / */ + path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1)); + } + curl_free(url_path); + + return path; +} + /** * Locate a shared resource file by searching known places in order. * diff --git a/windows/misc.c b/windows/misc.c index 002297665..7a6fc3206 100644 --- a/windows/misc.c +++ b/windows/misc.c @@ -46,11 +46,6 @@ bool cookies_update(const char *domain, const struct cookie_data *data) return true; } -char *url_to_path(const char *url) -{ - return strdup(url + 5); -} - /** * Return the filename part of a full path * |