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

Jonathan Calmels jbjcalmels at gmail.com
Thu Jan 29 16:04:01 CET 2015


---
 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;
+    }
+
 #ifdef __OS2__
     char p[strlen (path) + 1];
 
-- 
2.2.2




More information about the vlc-devel mailing list