forked from bartvdbraak/blender
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.
This commit is contained in:
parent
16b425b9c0
commit
5871b289cc
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user