[vlc-devel] commit: file: handle fd://<fd>/<path> ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 16 17:56:57 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan 16 18:34:31 2010 +0200| [c6ab35dbc2e591b3d15ab6d2fed0d3cd49fb4b38] | committer: Rémi Denis-Courmont 

file: handle fd://<fd>/<path>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c6ab35dbc2e591b3d15ab6d2fed0d3cd49fb4b38
---

 modules/access/file.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/modules/access/file.c b/modules/access/file.c
index bd166c7..0a9852f 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -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);




More information about the vlc-devel mailing list