Fix T44235: UNC Path Fails in open.

Here again, stat on '\\MYSERVER\foo\..' does not work...

Anyway, we can handle this in a much much simpler way using
BLI_access and BLI_parent_dir...
This commit is contained in:
Bastien Montagne 2015-04-08 21:57:49 +02:00
parent 114d1b23d2
commit aa24704749
Notes: blender-bot 2023-02-14 11:20:29 +01:00
Referenced by issue #44235, UNC Path Fails in open
1 changed files with 10 additions and 23 deletions

View File

@ -57,6 +57,8 @@
# include <shlobj.h>
# include "BLI_winstuff.h"
# include "MEM_guardedalloc.h"
#else
# include "unistd.h"
#endif /* WIN32 */
/* local */
@ -743,7 +745,7 @@ bool BLI_parent_dir(char *path)
BLI_cleanup_dir(NULL, tmp); /* does all the work of normalizing the path for us */
if (!BLI_testextensie(tmp, parent_dir)) {
BLI_strncpy(path, tmp, sizeof(tmp));
strcpy(path, tmp); /* We assume pardir is always shorter... */
return true;
}
else {
@ -1109,33 +1111,18 @@ void BLI_char_switch(char *string, char from, char to)
*/
void BLI_make_exist(char *dir)
{
int a;
char par_path[PATH_MAX + 3];
bool valid_path = true;
BLI_char_switch(dir, ALTSEP, SEP);
/* Loop as long as cur path is not a dir, and we can get a parent path. */
while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir)));
a = strlen(dir);
for (BLI_join_dirfile(par_path, sizeof(par_path), dir, FILENAME_PARENT);
!(BLI_is_dir(dir) && BLI_exists(par_path));
BLI_join_dirfile(par_path, sizeof(par_path), dir, FILENAME_PARENT))
{
a--;
while (dir[a] != SEP) {
a--;
if (a <= 0) break;
}
if (a >= 0) {
dir[a + 1] = '\0';
}
else {
/* If we could not find an existing dir, use default root... */
if (!valid_path || !dir[0]) {
#ifdef WIN32
get_default_root(dir);
get_default_root(dir);
#else
strcpy(dir, "/");
strcpy(dir, "/");
#endif
break;
}
}
}