diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-09-30 08:08:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-09-30 08:08:00 +0400 |
commit | 5871b289cc39279e144acbe44e55ec4060a4ec11 (patch) | |
tree | 185aa283ac7bc8b49cd4e91ffdef3ca884534938 /source/blender/blenlib | |
parent | 16b425b9c044a23d047dc982a526db9cd07903b5 (diff) |
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.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/util.c | 20 |
1 files changed, 16 insertions, 4 deletions
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); |