diff options
Diffstat (limited to 'windows/findfile.c')
-rw-r--r-- | windows/findfile.c | 27 |
1 files changed, 27 insertions, 0 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. * |