Commit 74167c1e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_path2ri: set errno to disthinguish errors (refs #10792)

parent 90b73bf5
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
# include "config.h" # include "config.h"
#endif #endif
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
...@@ -147,12 +148,15 @@ char *encode_URI_component (const char *str) ...@@ -147,12 +148,15 @@ char *encode_URI_component (const char *str)
* @param path path to convert (or URI to copy) * @param path path to convert (or URI to copy)
* @param scheme URI scheme to use (default is auto: "file", "fd" or "smb") * @param scheme URI scheme to use (default is auto: "file", "fd" or "smb")
* @return a nul-terminated URI string (use free() to release it), * @return a nul-terminated URI string (use free() to release it),
* or NULL in case of error * or NULL in case of error (errno will be set accordingly)
*/ */
char *vlc_path2uri (const char *path, const char *scheme) char *vlc_path2uri (const char *path, const char *scheme)
{ {
if (path == NULL) if (path == NULL)
{
errno = EINVAL;
return NULL; return NULL;
}
if (scheme == NULL && !strcmp (path, "-")) if (scheme == NULL && !strcmp (path, "-"))
return strdup ("fd://0"); // standard input return strdup ("fd://0"); // standard input
/* Note: VLC cannot handle URI schemes without double slash after the /* Note: VLC cannot handle URI schemes without double slash after the
...@@ -180,15 +184,21 @@ char *vlc_path2uri (const char *path, const char *scheme) ...@@ -180,15 +184,21 @@ char *vlc_path2uri (const char *path, const char *scheme)
path += 2; path += 2;
# warning Drive letter-relative path not implemented! # warning Drive letter-relative path not implemented!
if (path[0] != DIR_SEP_CHAR) if (path[0] != DIR_SEP_CHAR)
{
errno = ENOTSUP;
return NULL; return NULL;
} }
}
else else
#endif #endif
if (!strncmp (path, "\\\\", 2)) if (!strncmp (path, "\\\\", 2))
{ /* Windows UNC paths */ { /* Windows UNC paths */
#if !defined( _WIN32 ) && !defined( __OS2__ ) #if !defined( _WIN32 ) && !defined( __OS2__ )
if (scheme != NULL) if (scheme != NULL)
{
errno = ENOTSUP;
return NULL; /* remote files not supported */ return NULL; /* remote files not supported */
}
/* \\host\share\path -> smb://host/share/path */ /* \\host\share\path -> smb://host/share/path */
if (strchr (path + 2, '\\') != NULL) if (strchr (path + 2, '\\') != NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment