diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-11 03:30:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-11 03:30:51 +0300 |
commit | d6ca95b1a31799fc36905294410f1c284f7b14be (patch) | |
tree | c115b790de9dc3c624bc81cd3e826aa45e0cdf92 /source/blender/blenlib | |
parent | cda0460c89fae4edcbc277e2c308bbf00135f931 (diff) |
fix [#26451] Little problem when selecting relative output path
BLI_path_rel() no longer strips trailing slashes.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 40 |
2 files changed, 17 insertions, 26 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index b3220937e19..ed52bf30f62 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -132,8 +132,9 @@ void BLI_clean(char *path); * converts it to a regular full path. * Also removes garbage from directory paths, like /../ or double slashes etc */ -void BLI_cleanup_file(const char *relabase, char *dir); +void BLI_cleanup_file(const char *relabase, char *dir); /* removes trailing slash */ void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */ +void BLI_cleanup_path(const char *relabase, char *dir); /* doesn't touch trailing slash */ /* go back one directory */ int BLI_parent_dir(char *path); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 06fb656fa5b..2195607e6c7 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -296,14 +296,7 @@ void BLI_uniquename(ListBase *list, void *vlink, const char defname[], char deli * If relbase is NULL then its ignored */ -void BLI_cleanup_dir(const char *relabase, char *dir) -{ - BLI_cleanup_file(relabase, dir); - BLI_add_slash(dir); - -} - -void BLI_cleanup_file(const char *relabase, char *dir) +void BLI_cleanup_path(const char *relabase, char *dir) { short a; char *start, *eind; @@ -358,13 +351,6 @@ void BLI_cleanup_file(const char *relabase, char *dir) eind = start + strlen("\\\\") - 1; memmove( start, eind, strlen(eind)+1 ); } - - if((a = strlen(dir))){ /* remove the '\\' at the end */ - while(a>0 && dir[a-1] == '\\'){ - a--; - dir[a] = 0; - } - } #else if(dir[0]=='.') { /* happens, for example in FILE_MAIN */ dir[0]= '/'; @@ -402,17 +388,21 @@ void BLI_cleanup_file(const char *relabase, char *dir) eind = start + (2 - 1) /* strlen("//") - 1 */; memmove( start, eind, strlen(eind)+1 ); } - - if( (a = strlen(dir)) ){ /* remove all '/' at the end */ - while(dir[a-1] == '/'){ - a--; - dir[a] = 0; - if (a<=0) break; - } - } #endif } +void BLI_cleanup_dir(const char *relabase, char *dir) +{ + BLI_cleanup_path(relabase, dir); + BLI_add_slash(dir); + +} + +void BLI_cleanup_file(const char *relabase, char *dir) +{ + BLI_cleanup_path(relabase, dir); + BLI_del_slash(dir); +} void BLI_path_rel(char *file, const char *relfile) { @@ -453,8 +443,8 @@ void BLI_path_rel(char *file, const char *relfile) BLI_char_switch(file, '\\', '/'); /* remove /./ which confuse the following slash counting... */ - BLI_cleanup_file(NULL, file); - BLI_cleanup_file(NULL, temp); + BLI_cleanup_path(NULL, file); + BLI_cleanup_path(NULL, temp); /* the last slash in the file indicates where the path part ends */ lslash = BLI_last_slash(temp); |