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>2010-01-08 20:50:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-08 20:50:55 +0300
commit1f1245a92a21b4744495549b951caf59fea06765 (patch)
tree941b6c2cdf7923b445b032996dc7f80591cc6f26 /source/blender/blenloader
parent5dffae2346208d7b8185afb99d7ba0465214a515 (diff)
Remap Relative paths save option.
If you have a blend file and want to save in a new directory enabling this will save with the paths corrected relative to the new directory.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/writefile.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 061ed71d77e..13033c8fcba 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -145,6 +145,7 @@ Any case: direct data is ALWAYS after the lib block
#include "MEM_guardedalloc.h" // MEM_freeN
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
+#include "BLI_bpath.h"
#include "BKE_action.h"
#include "BKE_blender.h"
@@ -2458,9 +2459,28 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
return 0;
}
+ if(write_flags & G_FILE_RELATIVE_REMAP) {
+ char dir1[FILE_MAXDIR+FILE_MAXFILE];
+ char dir2[FILE_MAXDIR+FILE_MAXFILE];
+ BLI_split_dirfile_basic(dir, dir1, NULL);
+ BLI_split_dirfile_basic(mainvar->name, dir2, NULL);
+
+ /* just incase there is some subtle difference */
+ BLI_cleanup_dir(dir1);
+ BLI_cleanup_dir(dir2);
+
+ if(strcmp(dir1, dir2)==0)
+ write_flags &= ~G_FILE_RELATIVE_REMAP;
+ else
+ makeFilesAbsolute(G.sce, reports);
+ }
+
BLI_make_file_string(G.sce, userfilename, BLI_gethome(), ".B25.blend");
write_user_block= BLI_streq(dir, userfilename);
+ if(write_flags & G_FILE_RELATIVE_REMAP)
+ makeFilesRelative(dir, NULL); /* note, making relative to something OTHER then G.sce */
+
err= write_file_handle(mainvar, file, NULL,NULL, write_user_block, write_flags);
close(file);