[vlc-commits] file: fix file/network caching detection for windows

Pierre Ynard git at videolan.org
Mon Sep 5 02:29:14 CEST 2011


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Mon Sep  5 02:28:06 2011 +0200| [54ce59969ad7eb981b0d410b3c5040ee5156a3a1] | committer: Pierre Ynard

file: fix file/network caching detection for windows

Untested

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

 modules/access/file.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/modules/access/file.c b/modules/access/file.c
index 706b355..d13f01d 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -71,8 +71,6 @@
 #      undef lseek
 #   endif
 #   define lseek _lseeki64
-#elif defined( UNDER_CE )
-# define PathIsNetworkPathW(wpath) (! wcsncmp(wpath, L"\\\\", 2))
 #endif
 
 #include <vlc_fs.h>
@@ -88,6 +86,7 @@ struct access_sys_t
     bool b_pace_control;
 };
 
+#ifndef WIN32
 static bool IsRemote (int fd)
 {
 #if defined (HAVE_FSTATVFS) && defined (MNT_LOCAL)
@@ -122,6 +121,22 @@ static bool IsRemote (int fd)
 
 #endif
 }
+# define IsRemote(fd,path) IsRemote(fd)
+
+#else /* WIN32 */
+static bool IsRemote (const char *path)
+{
+# ifndef UNDER_CE
+    wchar_t *wpath = ToWide (path);
+    bool is_remote = (wpath != NULL && PathIsNetworkPathW (wpath));
+    free (wpath);
+    return is_remote;
+# else
+    return (! strncmp(path, "\\\\", 2));
+# endif
+}
+# define IsRemote(fd,path) IsRemote(path)
+#endif
 
 #ifndef HAVE_POSIX_FADVISE
 # define posix_fadvise(fd, off, len, adv)
@@ -133,9 +148,6 @@ static bool IsRemote (int fd)
 int FileOpen( vlc_object_t *p_this )
 {
     access_t     *p_access = (access_t*)p_this;
-#ifdef WIN32
-    bool is_remote = false;
-#endif
 
     /* Open file */
     int fd = -1;
@@ -365,7 +377,7 @@ int FileControl( access_t *p_access, int i_query, va_list args )
         /* */
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
-            if (IsRemote (p_sys->fd))
+            if (IsRemote (p_sys->fd, p_access->psz_filepath))
                 *pi_64 = var_InheritInteger (p_access, "network-caching");
             else
                 *pi_64 = var_InheritInteger (p_access, "file-caching");



More information about the vlc-commits mailing list