Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-04-08 22:57:49 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-04-08 22:59:05 +0300
commitaa24704749861e8f1691347ced0f28522cb0e61e (patch)
tree7ee90d372834749030d3719e0ff174678dd17cb1 /source/blender/blenlib/intern/path_util.c
parent114d1b23d298a9a5ddb6201046ec8b9e74661b7e (diff)
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...
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r--source/blender/blenlib/intern/path_util.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 72739018399..58b01f7e140 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -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];
-
- BLI_char_switch(dir, ALTSEP, SEP);
+ bool valid_path = true;
- a = strlen(dir);
+ /* 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)));
- 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;
- }
}
}