Revision: 16837
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16837
Author:   campbellbarton
Date:     2008-09-30 06:08:00 +0200 (Tue, 30 Sep 2008)

Log Message:
-----------
modify BLI_convertstringcode so windows paths are converted from C:\foo.jpg to 
/c/foo.jpg
since there is C:\ prefix cant exist on a unix system this wont break any files.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/util.c

Modified: trunk/blender/source/blender/blenlib/intern/util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/util.c  2008-09-29 23:46:01 UTC 
(rev 16836)
+++ trunk/blender/source/blender/blenlib/intern/util.c  2008-09-30 04:08:00 UTC 
(rev 16837)
@@ -1149,15 +1149,13 @@
 
 int BLI_convertstringcode(char *path, const char *basepath)
 {
-       int wasrelative;
+       int wasrelative = (strncmp(path, "//", 2)==0);
        char tmp[FILE_MAX];
        char base[FILE_MAX];
+#ifdef WIN32
        char vol[3] = {'\0', '\0', '\0'};
 
        BLI_strncpy(vol, path, 3);
-       wasrelative= (vol[0]=='/' && vol[1]=='/');
-       
-#ifdef WIN32
        /* we are checking here if we have an absolute path that is not in the 
current
           blend file as a lib main - we are basically checking for the case 
that a 
           UNIX root '/' is passed.
@@ -1176,6 +1174,20 @@
        }
 #else
        BLI_strncpy(tmp, path, FILE_MAX);
+       
+       /* Check for loading a windows path on a posix system
+        * in this case, there is no use in trying C:/ since it 
+        * will never exist on a unix os.
+        * 
+        * Add a / prefix and lowercase the driveletter, remove the :
+        * C:\foo.JPG -> /c/foo.JPG */
+       
+       if (tmp[1] == ':' && isalpha(tmp[0]) && (tmp[2]=='\\' || tmp[2]=='/') ) 
{
+               tmp[1] = tolower(tmp[0]); /* replace ':' with driveletter */
+               tmp[0] = '/'; 
+               /* '\' the slash will be converted later */
+       }
+       
 #endif
 
        BLI_strncpy(base, basepath, FILE_MAX);


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

Reply via email to