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.

This commit is contained in:
Campbell Barton
2008-04-28 21:29:15 +00:00
parent 082b706e8d
commit 96cec2e99b

View File

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