Handles "\\hostname" properly.
On Windows, error out on "X:directory" instead of aborting. Looking up
the current directory of the specified drive letter would be a better,
though.
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 ("/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);*/
/*int fd = open (".", O_RDONLY);
assert (fd != -1);*/
if (isalpha (path[0]) && (path[1] == ':'))
{
if (isalpha (path[0]) && (path[1] == ':'))
{
- if (asprintf (&buf, "%s:///%c:", scheme ? scheme : "file", path[0]) == -1)
+ if (asprintf (&buf, "%s:///%c:", scheme ? scheme : "file",
+ path[0]) == -1)
+# warning Drive letter-relative path not implemented!
+ if (path[0] != DIR_SEP_CHAR)
+ return NULL;
snprintf (buf, sizeof (SMB_SCHEME) + 3 + hostlen,
SMB_SCHEME"://%s", path + 2);
path += 2 + hostlen;
snprintf (buf, sizeof (SMB_SCHEME) + 3 + hostlen,
SMB_SCHEME"://%s", path + 2);
path += 2 + hostlen;
+
+ if (path[0] == '\0')
+ return buf; /* Hostname without path */
}
else
if (path[0] != DIR_SEP_CHAR)
}
else
if (path[0] != DIR_SEP_CHAR)