[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13038] trunk/blender/source/creator/ creator.c: forgot to test if the paths absolute in last commit

Campbell Barton ideasman42 at gmail.com
Fri Dec 28 22:42:02 CET 2007


Revision: 13038
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13038
Author:   campbellbarton
Date:     2007-12-28 22:42:01 +0100 (Fri, 28 Dec 2007)

Log Message:
-----------
forgot to test if the paths absolute in last commit

Modified Paths:
--------------
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2007-12-28 21:16:00 UTC (rev 13037)
+++ trunk/blender/source/creator/creator.c	2007-12-28 21:42:01 UTC (rev 13038)
@@ -690,32 +690,45 @@
 		else {
 			
 			/* Make the path absolute because its needed for relative linked blends to be found */
+			int abs = 0;
+			int filelen;
 			char cwd[FILE_MAXDIR + FILE_MAXFILE];
 			char filename[FILE_MAXDIR + FILE_MAXFILE];
 			cwd[0] = filename[0] = '\0';
 			
-			BLI_getwdN(cwd); /* incase the full path to the blend isnt used */
+			BLI_strncpy(filename, argv[a], sizeof(filename));
+			filelen = strlen(filename);
 			
-			if (cwd[0] == '\0') {
-				printf(
-				 "Could not get the current working directory - $PWD for an unknown reason.\n\t"
-				 "Relative linked files will not load if the entire blend path is not used.\n\t"
-				 "The 'Play' button may also fail.\n"
-				);
-			} else {
-				/* uses the blend path relative to cwd important for loading relative linked files.
-				 *
-				 * cwd should contain c:\ etc on win32 so the relbase can be NULL
-				 * relbase being NULL also prevents // being misunderstood as relative to the current
-				 * blend file which isnt a feature we want to use in this case since were dealing
-				 * with a path from the command line, rather then from inside Blender */
+			/* relative path checks, could do more tests here... */
+#ifdef WIN32
+			/* Account for X:/ and X:\ - should be enough */
+			if (filelen >= 3 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/'))
+				abs = 1;
+#else
+			if (filelen >= 2 && filename[0] == '/')
+				abs = 1	;
+#endif
+			if (!abs) {
+				BLI_getwdN(cwd); /* incase the full path to the blend isnt used */
 				
-				BLI_make_file_string(NULL, filename, cwd, argv[a]); 
+				if (cwd[0] == '\0') {
+					printf(
+					"Could not get the current working directory - $PWD for an unknown reason.\n\t"
+					"Relative linked files will not load if the entire blend path is not used.\n\t"
+					"The 'Play' button may also fail.\n"
+					);
+				} else {
+					/* uses the blend path relative to cwd important for loading relative linked files.
+					*
+					* cwd should contain c:\ etc on win32 so the relbase can be NULL
+					* relbase being NULL also prevents // being misunderstood as relative to the current
+					* blend file which isnt a feature we want to use in this case since were dealing
+					* with a path from the command line, rather then from inside Blender */
+					
+					BLI_make_file_string(NULL, filename, cwd, argv[a]); 
+				}
 			}
 			
-			if (filename[0] == '\0') /* above commands failed, just copy the path */
-				BLI_strncpy(filename, argv[a], sizeof(filename));
-			
 			if (G.background) {
 				BKE_read_file(filename, NULL);
 				sound_initialize_sounds();





More information about the Bf-blender-cvs mailing list