[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50722] trunk/blender/source/blender/ blenlib/intern/fileops.c: fix [#32572] Windows: False error on console when a new folder is created during a save or export operation

Campbell Barton ideasman42 at gmail.com
Tue Sep 18 12:51:49 CEST 2012


Revision: 50722
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50722
Author:   campbellbarton
Date:     2012-09-18 10:51:48 +0000 (Tue, 18 Sep 2012)
Log Message:
-----------
fix [#32572] Windows: False error on console when a new folder is created during a save or export operation

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/fileops.c

Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c	2012-09-18 10:31:00 UTC (rev 50721)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c	2012-09-18 10:51:48 UTC (rev 50722)
@@ -341,7 +341,7 @@
 {
 	char *lslash;
 	char tmp[MAXPATHLEN];
-	
+
 	/* First remove possible slash at the end of the dirname.
 	 * This routine otherwise tries to create
 	 * blah1/blah2/ (with slash) after creating
@@ -349,23 +349,29 @@
 
 	BLI_strncpy(tmp, dirname, sizeof(tmp));
 	lslash = BLI_last_slash(tmp);
-	
-	if (lslash == tmp + strlen(tmp) - 1) {
-		*lslash = 0;
+
+	if (lslash && (*(lslash + 1) == '\0')) {
+		*lslash = '\0';
 	}
-	
+
+	/* check special case "c:\foo", don't try create "c:", harmless but prints an error below */
+	if (isalpha(tmp[0]) && (tmp[1] == ':') && tmp[2] == '\0') return;
+
 	if (BLI_exists(tmp)) return;
 
 	lslash = BLI_last_slash(tmp);
+
 	if (lslash) {
 		/* Split about the last slash and recurse */
 		*lslash = 0;
 		BLI_dir_create_recursive(tmp);
 	}
-	
-	if (dirname[0]) /* patch, this recursive loop tries to create a nameless directory */
-		if (umkdir(dirname) == -1)
+
+	if (dirname[0]) {  /* patch, this recursive loop tries to create a nameless directory */
+		if (umkdir(dirname) == -1) {
 			printf("Unable to create directory %s\n", dirname);
+		}
+	}
 }
 
 int BLI_rename(const char *from, const char *to)




More information about the Bf-blender-cvs mailing list