[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13037] trunk/blender/source/creator/ creator.c:
Campbell Barton
ideasman42 at gmail.com
Fri Dec 28 22:16:00 CET 2007
Revision: 13037
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13037
Author: campbellbarton
Date: 2007-12-28 22:16:00 +0100 (Fri, 28 Dec 2007)
Log Message:
-----------
Fix for [#7866] Relative Path to library from command line
http://projects.blender.org/tracker/index.php?func=detail&aid=7866&group_id=9&atid=125
where linked relative blend files would not load when the absolute path was not given.
Solved by constructing the absolute path from the command line argument given.
Modified Paths:
--------------
trunk/blender/source/creator/creator.c
Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c 2007-12-28 19:38:47 UTC (rev 13036)
+++ trunk/blender/source/creator/creator.c 2007-12-28 21:16:00 UTC (rev 13037)
@@ -687,9 +687,37 @@
break;
}
}
- else {
+ else {
+
+ /* Make the path absolute because its needed for relative linked blends to be found */
+ 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 */
+
+ 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(argv[a], NULL);
+ BKE_read_file(filename, NULL);
sound_initialize_sounds();
/* happens for the UI on file reading too */
@@ -698,8 +726,8 @@
} else {
/* we are not running in background mode here, but start blender in UI mode with
a file - this should do everything a 'load file' does */
- BIF_read_file(argv[a]);
- }
+ BIF_read_file(filename);
+ }
}
}
More information about the Bf-blender-cvs
mailing list