Better support for UNC paths in tr_sys_path_is_relative
Accept \\ and // and valid UNC path prefixes, but not \/ or /\.
This commit is contained in:
parent
5f420cafda
commit
abb572fe26
|
@ -333,16 +333,22 @@ test_path_is_relative (void)
|
|||
#ifdef _WIN32
|
||||
|
||||
check (tr_sys_path_is_relative ("/"));
|
||||
check (tr_sys_path_is_relative ("//x"));
|
||||
check (tr_sys_path_is_relative ("\\x"));
|
||||
check (tr_sys_path_is_relative ("/x"));
|
||||
check (tr_sys_path_is_relative ("\\x\\y"));
|
||||
check (tr_sys_path_is_relative ("/x/y"));
|
||||
check (tr_sys_path_is_relative ("C:x"));
|
||||
check (tr_sys_path_is_relative ("C:x\\y"));
|
||||
check (tr_sys_path_is_relative ("C:x/y"));
|
||||
|
||||
check (!tr_sys_path_is_relative ("\\\\"));
|
||||
check (!tr_sys_path_is_relative ("//"));
|
||||
check (!tr_sys_path_is_relative ("\\\\x"));
|
||||
check (!tr_sys_path_is_relative ("//x"));
|
||||
check (!tr_sys_path_is_relative ("\\\\x\\y"));
|
||||
check (!tr_sys_path_is_relative ("//x/y"));
|
||||
check (!tr_sys_path_is_relative ("\\\\.\\x"));
|
||||
check (!tr_sys_path_is_relative ("//./x"));
|
||||
|
||||
check (!tr_sys_path_is_relative ("a:"));
|
||||
check (!tr_sys_path_is_relative ("a:\\"));
|
||||
|
|
|
@ -367,11 +367,11 @@ tr_sys_path_is_relative (const char * path)
|
|||
assert (path != NULL);
|
||||
|
||||
/* UNC path: `\\...`. */
|
||||
if (path[0] == '\\' && path[1] == '\\')
|
||||
if (is_unc_path (path))
|
||||
return false;
|
||||
|
||||
/* Local path: `X:` or `X:\...`. */
|
||||
if (isalpha (path[0]) && path[1] == ':' && (path[2] == '\0' || path[2] == '\\' || path[2] == '/'))
|
||||
if (isalpha (path[0]) && path[1] == ':' && (path[2] == '\0' || is_slash (path[2])))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue