]> git.sesse.net Git - vlc/blobdiff - modules/access/file.c
file.c: Typo fix
[vlc] / modules / access / file.c
index f443a7f3418848436d647760a092a28ee1a6f6f5..9d3de77498297f693d078b00e793adbb3f5ceab2 100644 (file)
 #ifdef HAVE_FCNTL_H
 #   include <fcntl.h>
 #endif
-#if defined (__linux__)
-#   include <sys/vfs.h>
+#ifdef HAVE_FSTATVFS
+#   include <sys/statvfs.h>
+#   if defined (HAVE_SYS_MOUNT_H)
+#      include <sys/param.h>
+#      include <sys/mount.h>
+#   endif
+#endif
 #ifdef HAVE_LINUX_MAGIC_H
+#   include <sys/vfs.h>
 #   include <linux/magic.h>
 #endif
-#elif defined (HAVE_SYS_MOUNT_H)
-#   include <sys/param.h>
-#   include <sys/mount.h>
-#endif
 
 #if defined( WIN32 )
 #   include <io.h>
@@ -58,8 +60,8 @@
 #   include <shlwapi.h>
 #else
 #   include <unistd.h>
-#   include <poll.h>
 #endif
+#include <dirent.h>
 
 #if defined( WIN32 ) && !defined( UNDER_CE )
 #   ifdef lseek
@@ -68,7 +70,6 @@
 #   define lseek _lseeki64
 #elif defined( UNDER_CE )
 /* FIXME the commandline on wince is a mess */
-# define dup(a) -1
 # define PathIsNetworkPathW(wpath) (! wcsncmp(wpath, L"\\\\", 2))
 #endif
 
@@ -89,17 +90,20 @@ struct access_sys_t
 #ifndef WIN32
 static bool IsRemote (int fd)
 {
-#ifdef HAVE_FSTATFS
+#if defined (HAVE_FSTATVFS) && defined (MNT_LOCAL)
+    struct statvfs stf;
+
+    if (fstatvfs (fd, &stf))
+        return false;
+    /* fstatvfs() is in POSIX, but MNT_LOCAL is not */
+    return !(stf.f_flag & MNT_LOCAL);
+
+#elif defined (HAVE_LINUX_MAGIC_H)
     struct statfs stf;
 
     if (fstatfs (fd, &stf))
         return false;
 
-#if defined(MNT_LOCAL)
-    return !(stf.f_flags & MNT_LOCAL);
-
-#else
-#   ifdef HAVE_LINUX_MAGIC_H
     switch (stf.f_type)
     {
         case AFS_SUPER_MAGIC:
@@ -111,9 +115,8 @@ static bool IsRemote (int fd)
             return true;
     }
     return false;
-#   endif
-#endif
-#else /* !HAVE_FSTATFS */
+
+#else
     (void)fd;
     return false;
 
@@ -131,7 +134,7 @@ static bool IsRemote (int fd)
 int Open( vlc_object_t *p_this )
 {
     access_t     *p_access = (access_t*)p_this;
-    const char   *path = p_access->psz_path;
+    const char   *path = p_access->psz_filepath;
 #ifdef WIN32
     bool is_remote = false;
 #endif
@@ -145,19 +148,17 @@ int Open( vlc_object_t *p_this )
         int oldfd = strtol (path, &end, 10);
 
         if (*end == '\0')
-            fd = dup (oldfd);
-#ifdef HAVE_FDOPENDIR
+            fd = vlc_dup (oldfd);
         else if (*end == '/' && end > path)
         {
             char *name = decode_URI_duplicate (end - 1);
-            if (name != NULL) /* TODO: ToLocale(), FD_CLOEXEC */
+            if (name != NULL)
             {
                 name[0] = '.';
-                fd = openat (oldfd, name, O_RDONLY | O_NONBLOCK);
+                fd = vlc_openat (oldfd, name, O_RDONLY | O_NONBLOCK);
                 free (name);
             }
         }
-#endif
     }
     else
     {
@@ -192,8 +193,6 @@ int Open( vlc_object_t *p_this )
      * how to parse the data. The directory plugin will do it. */
     if (S_ISDIR (st.st_mode))
     {
-        if (!strcasecmp (p_access->psz_access, "fd"))
-            goto error; /* fd:// not supported for directories yet */
 #ifdef HAVE_FDOPENDIR
         DIR *handle = fdopendir (fd);
         if (handle == NULL)