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>2011-10-27 01:22:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-27 01:22:35 +0400
commita267f9ba4e7904c6e32e062aaccc282d974643bf (patch)
tree6ec0d31ecf6359652a69c1c497265d60e6f0b0a3 /source/blender/blenlib
parentba0ef7a592ace7d6baa5c5f1342706de4e70b2e8 (diff)
edits ontop of Alex's patch from r41292.
pass main rather than use G.main when naming from -> to relative paths.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_bpath.h6
-rw-r--r--source/blender/blenlib/intern/bpath.c27
2 files changed, 19 insertions, 14 deletions
diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h
index 5774d90912e..478fe0a4c59 100644
--- a/source/blender/blenlib/BLI_bpath.h
+++ b/source/blender/blenlib/BLI_bpath.h
@@ -54,10 +54,10 @@ void BLI_bpathIterator_setPath (struct BPathIterator *bpi, const char *path)
/* Function that does something with an ID's file path. Should return 1 if the
path has changed, and in that case, should write the result to pathOut. */
-typedef int (*bpath_visitor)(void *userdata, char *pathIn, char *pathOut);
+typedef int (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src);
/* Executes 'visit' for each path associated with 'id'. */
-void bpath_traverse_id(struct ID *id, bpath_visitor visit, void *userdata);
-int bpath_relocate_visitor(void *oldbasepath, char *pathIn, char *pathOut);
+void bpath_traverse_id(struct ID *id, BPathVisitor visit, void *userdata);
+int bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src);
/* high level funcs */
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 2884ea2743a..0d22981946e 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -953,14 +953,16 @@ void findMissingFiles(Main *bmain, const char *str)
}
/* Run a visitor on a string, replacing the contents of the string as needed. */
-static void rewrite_path(char *path, bpath_visitor visit, void *userdata) {
+static void rewrite_path(char *path, BPathVisitor visit, void *userdata)
+{
char pathOut[FILE_MAX];
if (visit(userdata, path, pathOut))
BLI_strncpy(path, pathOut, FILE_MAX);
}
/* Run visitor function 'visit' on all paths contained in 'id'. */
-void bpath_traverse_id(ID *id, bpath_visitor visit, void *userdata) {
+void bpath_traverse_id(ID *id, BPathVisitor visit, void *userdata)
+{
Image *ima;
switch(GS(id->name)) {
@@ -981,26 +983,29 @@ void bpath_traverse_id(ID *id, bpath_visitor visit, void *userdata) {
/* Rewrites a relative path to be relative to the main file - unless the path is
absolute, in which case it is not altered. */
-int bpath_relocate_visitor(void *oldbasepath_v, char *pathIn, char *pathOut) {
+int bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
+{
/* be sure there is low chance of the path being too short */
char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
- char *oldbasepath = oldbasepath_v;
+ const char *base_new= ((char **)pathbase_v)[0];
+ const char *base_old= ((char **)pathbase_v)[1];
- if (strncmp(oldbasepath, "//", 2) == 0) {
- printf("Error: old base path '%s' is not absolute.\n", oldbasepath);
+ if (strncmp(base_old, "//", 2) == 0) {
+ printf("%s: error, old base path '%s' is not absolute.\n",
+ __func__, base_old);
return 0;
}
/* Make referenced file absolute. This would be a side-effect of
BLI_cleanup_file, but we do it explicitely so we know if it changed. */
- BLI_strncpy(filepath, pathIn, FILE_MAX);
- if (BLI_path_abs(filepath, oldbasepath)) {
+ BLI_strncpy(filepath, path_src, FILE_MAX);
+ if (BLI_path_abs(filepath, base_old)) {
/* Path was relative and is now absolute. Remap.
* Important BLI_cleanup_dir runs before the path is made relative
* because it wont work for paths that start with "//../" */
- BLI_cleanup_file(G.main->name, filepath);
- BLI_path_rel(filepath, G.main->name);
- BLI_strncpy(pathOut, filepath, FILE_MAX);
+ BLI_cleanup_file(base_new, filepath);
+ BLI_path_rel(filepath, base_new);
+ BLI_strncpy(path_dst, filepath, FILE_MAX);
return 1;
}
else {