Fix T102201: File selector shows "\" before folder names on WIN32

Regression in [0] on WIN32 caused joining paths {"//", "path"} to
result in "//\path".
This made the file selector show paths with a "\" prefix.

Add an exception for WIN32 where an initial path of forward slashes
is joined without a back-slash.

[0]: 8f7ab1bf46
This commit is contained in:
Campbell Barton 2022-11-02 14:07:54 +11:00
parent 5a90bbf716
commit db43aa7729
Notes: blender-bot 2023-02-13 23:16:02 +01:00
Referenced by issue #102201, Regression: Blender 3.4 -  (any directory) shows "\" or "\.." before their folder name and file name.
1 changed files with 21 additions and 0 deletions

View File

@ -1500,6 +1500,27 @@ size_t BLI_path_join_array(char *__restrict dst,
return ofs;
}
#ifdef WIN32
/* Special case "//" for relative paths, don't use separator #SEP
* as this has a special meaning on both WIN32 & UNIX.
* Without this check joining `"//", "path"`. results in `"//\path"`. */
if (ofs != 0) {
size_t i;
for (i = 0; i < ofs; i++) {
if (dst[i] != '/') {
break;
}
}
if (i == ofs) {
/* All slashes, keep them as-is, and join the remaining path array. */
return path_array_num > 1 ?
BLI_path_join_array(
dst + ofs, dst_len - ofs, &path_array[1], path_array_num - 1) :
ofs;
}
}
#endif
/* Remove trailing slashes, unless there are *only* trailing slashes
* (allow `//` or `//some_path` as the first argument). */
bool has_trailing_slash = false;