[Bf-blender-cvs] [a08c5e1] master: Partial fix for T43113: Filebrowser: Empty folders do not contain go back arrow.

Bastien Montagne noreply at git.blender.org
Sun Jan 4 17:57:50 CET 2015


Commit: a08c5e1183731cdafd85ecf51c587cabf39da19b
Author: Bastien Montagne
Date:   Sun Jan 4 17:54:12 2015 +0100
Branches: master
https://developer.blender.org/rBa08c5e1183731cdafd85ecf51c587cabf39da19b

Partial fix for T43113: Filebrowser: Empty folders do not contain go back arrow.

Do not allow going into un-readable directories at all.
Note we might want to reflect that 'state' in UI for users too, but that will be
for later.

Also, not quite sure this fix the windows case, will have to start my VM... :/

===================================================================

M	source/blender/blenlib/intern/path_util.c
M	source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 8b57018..3fff222 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1087,18 +1087,22 @@ void BLI_char_switch(char *string, char from, char to)
 }
 
 /**
- * Strips off nonexistent subdirectories from the end of *dir, leaving the path of
- * the lowest-level directory that does exist.
+ * Strips off nonexistent (or non-accessible) subdirectories from the end of *dir, leaving the path of
+ * the lowest-level directory that does exist and we can read.
  */
 void BLI_make_exist(char *dir)
 {
 	int a;
+	char par_path[PATH_MAX + 3];
 
 	BLI_char_switch(dir, ALTSEP, SEP);
 
 	a = strlen(dir);
 
-	while (!BLI_is_dir(dir)) {
+	for (BLI_join_dirfile(par_path, sizeof(par_path), dir, "..");
+	     !(BLI_is_dir(dir) && BLI_exists(par_path));
+	     BLI_join_dirfile(par_path, sizeof(par_path), dir, ".."))
+	{
 		a--;
 		while (dir[a] != SEP) {
 			a--;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 2e6dc7b..f35a207 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -973,9 +973,14 @@ static void filelist_read_dir(struct FileList *filelist)
 	filelist->fidx = NULL;
 	filelist->filelist = NULL;
 
+	BLI_make_exist(filelist->dir);
 	BLI_cleanup_dir(G.main->name, filelist->dir);
 	filelist->numfiles = BLI_filelist_dir_contents(filelist->dir, &(filelist->filelist));
 
+	/* We shall *never* get an empty list here, since we now the dir exists and is readable
+	 * (ensured by BLI_make_exist()). So we expect at the very least the parent '..' entry. */
+	BLI_assert(filelist->numfiles != 0);
+
 	filelist_setfiletypes(filelist);
 }
 
@@ -994,7 +999,6 @@ static void filelist_read_library(struct FileList *filelist)
 		int num;
 		struct direntry *file;
 
-		BLI_make_exist(filelist->dir);
 		filelist_read_dir(filelist);
 		file = filelist->filelist;
 		for (num = 0; num < filelist->numfiles; num++, file++) {




More information about the Bf-blender-cvs mailing list