[vlc-commits] vlc_path2uri: allow file names starting with a pair of backslashes
Rémi Denis-Courmont
git at videolan.org
Tue Mar 3 21:22:41 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 3 22:18:48 2015 +0200| [84ea87f354ce88a9e86c259424027578f0c3252d] | committer: Rémi Denis-Courmont
vlc_path2uri: allow file names starting with a pair of backslashes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=84ea87f354ce88a9e86c259424027578f0c3252d
---
src/test/url.c | 3 ---
src/text/url.c | 34 ++++------------------------------
2 files changed, 4 insertions(+), 33 deletions(-)
diff --git a/src/test/url.c b/src/test/url.c
index 5fc01e6..c199271 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -124,9 +124,6 @@ int main (void)
test_path ("/home/john//too///many//slashes",
"file:///home/john//too///many//slashes");
test_path ("/home/john/music.ogg", "file:///home/john/music.ogg");
- test_path ("\\\\server/pub/music.ogg", "smb://server/pub/music.ogg");
- test_path ("\\\\server\\pub\\music.ogg", "smb://server/pub/music.ogg");
- test_path ("\\\\server", "smb://server");
/*int fd = open (".", O_RDONLY);
assert (fd != -1);*/
diff --git a/src/text/url.c b/src/text/url.c
index cd7e488..9283520 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -174,7 +174,7 @@ char *vlc_path2uri (const char *path, const char *scheme)
path = p;
#endif
-#if defined( _WIN32 ) || defined( __OS2__ )
+#if defined (_WIN32) || defined (__OS2__)
/* Drive letter */
if (isalpha ((unsigned char)path[0]) && (path[1] == ':'))
{
@@ -190,47 +190,21 @@ char *vlc_path2uri (const char *path, const char *scheme)
}
}
else
-#endif
if (!strncmp (path, "\\\\", 2))
{ /* Windows UNC paths */
-#if !defined( _WIN32 ) && !defined( __OS2__ )
- if (scheme != NULL)
- {
- errno = ENOTSUP;
- return NULL; /* remote files not supported */
- }
-
- /* \\host\share\path -> smb://host/share/path */
- if (strchr (path + 2, '\\') != NULL)
- { /* Convert backslashes to slashes */
- char *dup = strdup (path);
- if (dup == NULL)
- return NULL;
- for (size_t i = 2; dup[i]; i++)
- if (dup[i] == '\\')
- dup[i] = DIR_SEP_CHAR;
-
- char *ret = vlc_path2uri (dup, scheme);
- free (dup);
- return ret;
- }
-# define SMB_SCHEME "smb"
-#else
/* \\host\share\path -> file://host/share/path */
-# define SMB_SCHEME "file"
-#endif
size_t hostlen = strcspn (path + 2, DIR_SEP);
- buf = malloc (sizeof (SMB_SCHEME) + 3 + hostlen);
+ buf = malloc (7 + hostlen);
if (buf != NULL)
- snprintf (buf, sizeof (SMB_SCHEME) + 3 + hostlen,
- SMB_SCHEME"://%s", path + 2);
+ snprintf (buf, 7 + hostlen, "file://%s", path + 2);
path += 2 + hostlen;
if (path[0] == '\0')
return buf; /* Hostname without path */
}
else
+#endif
if (path[0] != DIR_SEP_CHAR)
{ /* Relative path: prepend the current working directory */
char *cwd, *ret;
More information about the vlc-commits
mailing list