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; }