[Bf-blender-cvs] [db43aa77292] master: Fix T102201: File selector shows "\" before folder names on WIN32

Campbell Barton noreply at git.blender.org
Wed Nov 2 04:12:29 CET 2022


Commit: db43aa772925d4f6bd311858cd1ee4fe9aebc4e8
Author: Campbell Barton
Date:   Wed Nov 2 14:07:54 2022 +1100
Branches: master
https://developer.blender.org/rBdb43aa772925d4f6bd311858cd1ee4fe9aebc4e8

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]: 8f7ab1bf46d5e8610b167180b7631ff62e718a08

===================================================================

M	source/blender/blenlib/intern/path_util.c

===================================================================

diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index f46c2e65395..7c08eeedaa2 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -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;



More information about the Bf-blender-cvs mailing list