[Bf-blender-cvs] [aa24704] master: Fix T44235: UNC Path Fails in open.

Bastien Montagne noreply at git.blender.org
Wed Apr 8 21:59:56 CEST 2015


Commit: aa24704749861e8f1691347ced0f28522cb0e61e
Author: Bastien Montagne
Date:   Wed Apr 8 21:57:49 2015 +0200
Branches: master
https://developer.blender.org/rBaa24704749861e8f1691347ced0f28522cb0e61e

Fix T44235: UNC Path Fails in open.

Here again, stat on '\\MYSERVER\foo\..' does not work...

Anyway, we can handle this in a much much simpler way using
BLI_access and BLI_parent_dir...

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

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 7273901..58b01f7 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -57,6 +57,8 @@
 #  include <shlobj.h>
 #  include "BLI_winstuff.h"
 #  include "MEM_guardedalloc.h"
+#else
+#  include "unistd.h"
 #endif /* WIN32 */
 
 /* local */
@@ -743,7 +745,7 @@ bool BLI_parent_dir(char *path)
 	BLI_cleanup_dir(NULL, tmp); /* does all the work of normalizing the path for us */
 
 	if (!BLI_testextensie(tmp, parent_dir)) {
-		BLI_strncpy(path, tmp, sizeof(tmp));
+		strcpy(path, tmp);  /* We assume pardir is always shorter... */
 		return true;
 	}
 	else {
@@ -1109,33 +1111,18 @@ void BLI_char_switch(char *string, char from, char to)
  */
 void BLI_make_exist(char *dir)
 {
-	int a;
-	char par_path[PATH_MAX + 3];
-
-	BLI_char_switch(dir, ALTSEP, SEP);
+	bool valid_path = true;
 
-	a = strlen(dir);
+	/* Loop as long as cur path is not a dir, and we can get a parent path. */
+	while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir)));
 
-	for (BLI_join_dirfile(par_path, sizeof(par_path), dir, FILENAME_PARENT);
-	     !(BLI_is_dir(dir) && BLI_exists(par_path));
-	     BLI_join_dirfile(par_path, sizeof(par_path), dir, FILENAME_PARENT))
-	{
-		a--;
-		while (dir[a] != SEP) {
-			a--;
-			if (a <= 0) break;
-		}
-		if (a >= 0) {
-			dir[a + 1] = '\0';
-		}
-		else {
+	/* If we could not find an existing dir, use default root... */
+	if (!valid_path || !dir[0]) {
 #ifdef WIN32
-			get_default_root(dir);
+		get_default_root(dir);
 #else
-			strcpy(dir, "/");
+		strcpy(dir, "/");
 #endif
-			break;
-		}
 	}
 }




More information about the Bf-blender-cvs mailing list