From 5871b289cc39279e144acbe44e55ec4060a4ec11 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Sep 2008 04:08:00 +0000 Subject: 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. --- source/blender/blenlib/intern/util.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index d65fe8a476a..442a629b12d 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -1149,15 +1149,13 @@ int BLI_convertstringframe(char *path, int frame) 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 @@ int BLI_convertstringcode(char *path, const char *basepath) } #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); -- cgit v1.2.3