mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
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
2 changed files with 9 additions and 3 deletions
|
@ -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 a new issue