diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-04-29 01:29:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-04-29 01:29:15 +0400 |
commit | 96cec2e99bc4d09f368b3737b8e2161ff5345fa9 (patch) | |
tree | 495db3116fefeba54e20fefdda4f4fb89619fb04 /source/blender/blenlib | |
parent | 082b706e8d13c6c086b1632242adda4e4e2a4c19 (diff) |
if a blend file was opened with /./ in the path (for example "some/./path/to/./model.blend" ) the relative paths from created from that location would be incorrect. This results in linked library paths being loaded incorrectly.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/util.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index c79f1b56f1d..cdac1ba7061 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -858,6 +858,8 @@ int BLI_strcaseeq(char *a, char *b) { * take the dir name, make it absolute, and clean it up, replacing * excess file entry stuff (like /tmp/../tmp/../) * note that dir isn't protected for max string names... + * + * If relbase is NULL then its ignored */ void BLI_cleanup_dir(const char *relabase, char *dir) @@ -874,9 +876,9 @@ void BLI_cleanup_file(const char *relabase, char *dir) { short a; char *start, *eind; - - BLI_convertstringcode(dir, relabase, 0); - + if (relabase) { + BLI_convertstringcode(dir, relabase, 0); + } #ifdef WIN32 if(dir[0]=='.') { /* happens for example in FILE_MAIN */ get_default_root(dir); @@ -954,7 +956,7 @@ void BLI_makestringcode(const char *relfile, char *file) char * lslash; char temp[FILE_MAXDIR+FILE_MAXFILE]; char res[FILE_MAXDIR+FILE_MAXFILE]; - + /* if file is already relative, bail out */ if(file[0]=='/' && file[1]=='/') return; @@ -986,7 +988,11 @@ void BLI_makestringcode(const char *relfile, char *file) BLI_char_switch(temp, '\\', '/'); BLI_char_switch(file, '\\', '/'); - + + /* remove /./ which confuse the following slash counting... */ + BLI_cleanup_file(NULL, file); + BLI_cleanup_file(NULL, temp); + /* the last slash in the file indicates where the path part ends */ lslash = BLI_last_slash(temp); @@ -1065,6 +1071,8 @@ int BLI_convertstringcode(char *path, const char *basepath, int framenum) BLI_strncpy(base, basepath, FILE_MAX); + BLI_cleanup_file(NULL, base); + /* push slashes into unix mode - strings entering this part are potentially messed up: having both back- and forward slashes. Here we push into one conform direction, and at the end we @@ -1147,7 +1155,7 @@ int BLI_convertstringcode(char *path, const char *basepath, int framenum) */ BLI_char_switch(path+2, '/', '\\'); #endif - + return wasrelative; } |