Revision: 15133
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15133
Author:   campbellbarton
Date:     2008-06-05 15:02:00 +0200 (Thu, 05 Jun 2008)

Log Message:
-----------
* python sys.cleanpath() used strstr incorrectly, resulting in paths containing 
a slash, always returning a path that ends with a slash.
* python Blender.GetPaths() - absolute=0 wasnt working
* BLI_cleanup_file and BLI_cleanup_file were treating the // prefix as a 
duplicate path, now ignores //
* BLI_convertstringcode was removing the trailing slash from a path
(tested these path functions didnt mess up with some of the peach files and 
with pointcache)

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/util.c
    trunk/blender/source/blender/python/api2_2x/Blender.c
    trunk/blender/source/blender/python/api2_2x/Sys.c

Modified: trunk/blender/source/blender/blenlib/intern/util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/util.c  2008-06-05 12:31:16 UTC 
(rev 15132)
+++ trunk/blender/source/blender/blenlib/intern/util.c  2008-06-05 13:02:00 UTC 
(rev 15133)
@@ -865,11 +865,8 @@
 void BLI_cleanup_dir(const char *relabase, char *dir)
 {
        BLI_cleanup_file(relabase, dir);
-#ifdef WIN32
-       strcat(dir, "\\");
-#else
-       strcat(dir, "/");
-#endif
+       BLI_add_slash(dir);
+
 }
 
 void BLI_cleanup_file(const char *relabase, char *dir)
@@ -878,6 +875,13 @@
        char *start, *eind;
        if (relabase) {
                BLI_convertstringcode(dir, relabase);
+       } else {
+               if (dir[0]=='/' && dir[1]=='/') {
+                       if (dir[2]== '\0') {
+                               return; /* path is "//" - cant clean it */
+                       }
+                       dir = dir+2; /* skip the first // */
+               }
        }
 #ifdef WIN32
        if(dir[0]=='.') {       /* happens for example in FILE_MAIN */
@@ -1150,24 +1154,30 @@
        BLI_char_switch(tmp, '\\', '/');
        BLI_char_switch(base, '\\', '/');       
 
+       /* Paths starting with // will get the blend file as their base,
+        * this isnt standard in any os but is uesed in blender all over the 
place */
        if (tmp[0] == '/' && tmp[1] == '/') {
-               char *filepart= BLI_strdup(tmp+2); /* skip code */
                char *lslash= BLI_last_slash(base);
-
                if (lslash) {
                        int baselen= (int) (lslash-base) + 1;
-
+                       /* use path for for temp storage here, we copy back 
over it right away */
+                       BLI_strncpy(path, tmp+2, FILE_MAX);
+                       
                        memcpy(tmp, base, baselen);
-                       strcpy(tmp+baselen, filepart);
+                       strcpy(tmp+baselen, path);
+                       strcpy(path, tmp);
                } else {
-                       strcpy(tmp, filepart);
+                       strcpy(path, tmp+2);
                }
-               
-               MEM_freeN(filepart);
+       } else {
+               strcpy(path, tmp);
        }
        
-       BLI_cleanup_file(NULL, tmp);
-       strcpy(path, tmp);
+       if (path[strlen(path)-1]=='/') {
+               BLI_cleanup_dir(NULL, path);
+       } else {
+               BLI_cleanup_file(NULL, path);
+       }
        
 #ifdef WIN32
        /* skip first two chars, which in case of

Modified: trunk/blender/source/blender/python/api2_2x/Blender.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Blender.c       2008-06-05 
12:31:16 UTC (rev 15132)
+++ trunk/blender/source/blender/python/api2_2x/Blender.c       2008-06-05 
13:02:00 UTC (rev 15133)
@@ -952,7 +952,7 @@
                if (absolute) {
                        BLI_bpathIterator_getPathExpanded( &bpi, 
filepath_expanded );
                } else {
-                       BLI_bpathIterator_getPathExpanded( &bpi, 
filepath_expanded );
+                       BLI_bpathIterator_getPath( &bpi, filepath_expanded );
                }
                st = PyString_FromString(filepath_expanded);
                

Modified: trunk/blender/source/blender/python/api2_2x/Sys.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Sys.c   2008-06-05 12:31:16 UTC 
(rev 15132)
+++ trunk/blender/source/blender/python/api2_2x/Sys.c   2008-06-05 13:02:00 UTC 
(rev 15133)
@@ -406,11 +406,12 @@
 {
        char *path = PyString_AsString(value);
        char cleaned[FILE_MAXDIR + FILE_MAXFILE];
-       int trailing_slash = 0;
+       int trailing_slash = 0, last;
        if (!path)
                return EXPP_ReturnPyObjError( PyExc_TypeError,
                        "expected string argument" );
-       if (strstr(path, "/") || strstr(path, "\\")) {
+       last = strlen(path)-1;
+       if ((path[last]=='/') || (path[last]=='\\')) {
                trailing_slash = 1;
        }
        BLI_strncpy(cleaned, path, FILE_MAXDIR + FILE_MAXFILE);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to