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

@ -57,6 +57,8 @@
# include <shlobj.h> # include <shlobj.h>
# include "BLI_winstuff.h" # include "BLI_winstuff.h"
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
#else
# include "unistd.h"
#endif /* WIN32 */ #endif /* WIN32 */
/* local */ /* 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 */ BLI_cleanup_dir(NULL, tmp); /* does all the work of normalizing the path for us */
if (!BLI_testextensie(tmp, parent_dir)) { if (!BLI_testextensie(tmp, parent_dir)) {
BLI_strncpy(path, tmp, sizeof(tmp)); strcpy(path, tmp); /* We assume pardir is always shorter... */
return true; return true;
} }
else { else {
@ -1109,33 +1111,18 @@ void BLI_char_switch(char *string, char from, char to)
*/ */
void BLI_make_exist(char *dir) void BLI_make_exist(char *dir)
{ {
int a; bool valid_path = true;
char par_path[PATH_MAX + 3];
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); /* If we could not find an existing dir, use default root... */
if (!valid_path || !dir[0]) {
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 {
#ifdef WIN32 #ifdef WIN32
get_default_root(dir); get_default_root(dir);
#else #else
strcpy(dir, "/"); strcpy(dir, "/");
#endif #endif
break;
}
} }
} }