[vlc-commits] [Git][videolan/vlc][master] access: file: simplify the check of remote path on Windows
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Aug 30 15:29:08 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
a89c7662 by Steve Lhomme at 2022-08-30T15:06:01+00:00
access: file: simplify the check of remote path on Windows
PathIsNetworkPathW() is a basic function that only checks for \\ and
[a-zA-Z]:\\ pathes [1]. It's also not available on UWP apps.
We can do the same by checking the UTF-8 string directly without even a
conversion to wide char string.
[1] https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathisnetworkpathw
- - - - -
2 changed files:
- modules/access/Makefile.am
- modules/access/file.c
Changes:
=====================================
modules/access/Makefile.am
=====================================
@@ -21,9 +21,6 @@ endif
libfilesystem_plugin_la_SOURCES = access/fs.h access/file.c access/directory.c access/fs.c
libfilesystem_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
-if HAVE_WIN32
-libfilesystem_plugin_la_LIBADD = -lshlwapi
-endif
access_LTLIBRARIES += libfilesystem_plugin.la
if HAVE_EMSCRIPTEN
=====================================
modules/access/file.c
=====================================
@@ -47,9 +47,6 @@
#if defined( _WIN32 )
# include <io.h>
# include <ctype.h>
-#if !defined(VLC_WINSTORE_APP)
-# include <shlwapi.h> // for PathIsNetworkPathW
-#endif
#else
# include <unistd.h>
#endif
@@ -120,17 +117,25 @@ static bool IsRemote (int fd)
}
# define IsRemote(fd,path) IsRemote(fd)
-#else /* _WIN32 || __OS2__ */
+#elif defined(_WIN32)
+
+static bool IsRemote(int fd, const char *path)
+{
+ VLC_UNUSED(fd);
+
+ size_t len = strlen(path);
+ if (len < 2)
+ return false;
+ if (path[0] == '\\' && path[1] == '\\')
+ return true;
+ return false;
+}
+
+#else /* __OS2__ */
+
static bool IsRemote (const char *path)
{
-# if !defined(__OS2__) && !defined(VLC_WINSTORE_APP)
- 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
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a89c7662b3cc7956547ed00730a002fa8a962a26
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a89c7662b3cc7956547ed00730a002fa8a962a26
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list