]> git.sesse.net Git - vlc/commitdiff
file: handle fd://<fd>/<path>
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 16 Jan 2010 16:34:31 +0000 (18:34 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 16 Jan 2010 16:34:31 +0000 (18:34 +0200)
modules/access/file.c

index bd166c760c13b8b59a48c49713ab8069ae709f57..0a9852f75cf7f29dd1367615d34e429073064ad8 100644 (file)
@@ -73,6 +73,7 @@
 #endif
 
 #include <vlc_charset.h>
+#include <vlc_url.h>
 
 struct access_sys_t
 {
@@ -139,7 +140,25 @@ int Open( vlc_object_t *p_this )
     int fd = -1;
 
     if (!strcasecmp (p_access->psz_access, "fd"))
-        fd = dup (atoi (path));
+    {
+        char *end;
+        int oldfd = strtol (path, &end, 10);
+
+        if (*end == '\0')
+            fd = dup (oldfd);
+#ifdef HAVE_FDOPENDIR
+        else if (*end == '/' && end > path)
+        {
+            char *name = decode_URI_duplicate (end - 1);
+            if (name != NULL) /* TODO: ToLocale(), FD_CLOEXEC */
+            {
+                name[0] = '.';
+                fd = openat (oldfd, name, O_RDONLY | O_NONBLOCK);
+                free (name);
+            }
+        }
+#endif
+    }
     else
     {
         msg_Dbg (p_access, "opening file `%s'", path);