From: Pierre Ynard Date: Mon, 5 Sep 2011 00:28:06 +0000 (+0200) Subject: file: fix file/network caching detection for windows X-Git-Tag: 1.2.0-pre1~845 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=54ce59969ad7eb981b0d410b3c5040ee5156a3a1;p=vlc file: fix file/network caching detection for windows Untested --- diff --git a/modules/access/file.c b/modules/access/file.c index 706b355215..d13f01de87 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 @@ -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");