[vlc-devel] [WIP PATCH 3/4] text: deduce magnet links as if the scheme was provided

Rémi Denis-Courmont remi at remlab.net
Thu Jan 29 16:25:41 CET 2015


Le jeudi 29 janvier 2015, 16:04:01 Jonathan Calmels a écrit :
> ---
>  src/text/url.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/text/url.c b/src/text/url.c
> index cd7e488..860e073 100644
> --- a/src/text/url.c
> +++ b/src/text/url.c
> @@ -146,7 +146,7 @@ char *encode_URI_component (const char *str)
>  /**
>   * Builds a URL representation from a local file path.
>   * @param path path to convert (or URI to copy)
> - * @param scheme URI scheme to use (default is auto: "file", "fd" or "smb")
> + * @param scheme URI scheme to use (default is auto: "file", "fd",
> "magnet" or "smb") * @return a nul-terminated URI string (use free() to
> release it), * or NULL in case of error (errno will be set accordingly)
>   */
> @@ -164,6 +164,12 @@ char *vlc_path2uri (const char *path, const char
> *scheme)
> 
>      char *buf;
> 
> +    if (scheme == NULL && !strncmp (path, "magnet:?", 8)) {
> +        if (asprintf (&buf, "%s://%s", "magnet", path) == -1)
> +            buf = NULL;
> +        return buf;
> +    }

"magnet:?" is a legal local file name on my system and I can no longer open it 
with this patch.

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list