Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-12-29 00:16:00 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-12-29 00:16:00 +0300
commit81cdf2428405f7390c4f3e0973ab4ea567e3cf7a (patch)
tree73a793f5d2a0ef32782926da4b6e24da13caf6f1 /source/creator
parent6a5ce69a162f3b48f0c4a94e820360fa524e8639 (diff)
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.
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 6a780553607..e5abe425468 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -687,9 +687,50 @@ int main(int argc, char **argv)
break;
}
}
- else {
+ 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_strncpy(filename, argv[a], sizeof(filename));
+ filelen = strlen(filename);
+
+ /* 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 */
+
+ 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 (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 +739,8 @@ int main(int argc, char **argv)
} 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);
+ }
}
}