[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35462] trunk/blender/source/blender/ blenlib: fix [#26451] Little problem when selecting relative output path
Campbell Barton
ideasman42 at gmail.com
Fri Mar 11 01:30:52 CET 2011
Revision: 35462
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35462
Author: campbellbarton
Date: 2011-03-11 00:30:51 +0000 (Fri, 11 Mar 2011)
Log Message:
-----------
fix [#26451] Little problem when selecting relative output path
BLI_path_rel() no longer strips trailing slashes.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_path_util.h
trunk/blender/source/blender/blenlib/intern/path_util.c
Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h 2011-03-11 00:18:10 UTC (rev 35461)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h 2011-03-11 00:30:51 UTC (rev 35462)
@@ -132,8 +132,9 @@
* 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);
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2011-03-11 00:18:10 UTC (rev 35461)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2011-03-11 00:30:51 UTC (rev 35462)
@@ -296,15 +296,8 @@
* If relbase is NULL then its ignored
*/
-void BLI_cleanup_dir(const char *relabase, char *dir)
+void BLI_cleanup_path(const char *relabase, char *dir)
{
- BLI_cleanup_file(relabase, dir);
- BLI_add_slash(dir);
-
-}
-
-void BLI_cleanup_file(const char *relabase, char *dir)
-{
short a;
char *start, *eind;
if (relabase) {
@@ -358,13 +351,6 @@
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,18 +388,22 @@
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)
{
char * lslash;
@@ -453,8 +443,8 @@
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);
More information about the Bf-blender-cvs
mailing list