[Bf-blender-cvs] [c725d86] asset-experiments: Filter completely 'dot-files', even when hidden in paths.

Bastien Montagne noreply at git.blender.org
Tue Dec 9 17:48:18 CET 2014


Commit: c725d868aff77596495fc566f45c9f591fa96c98
Author: Bastien Montagne
Date:   Tue Dec 9 17:44:29 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rBc725d868aff77596495fc566f45c9f591fa96c98

Filter completely 'dot-files', even when hidden in paths.

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

M	source/blender/editors/space_file/filelist.c

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

diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 6143c29..45115cf 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -472,6 +472,7 @@ static unsigned int groupname_to_filter_id(const char *group);
 
 static bool is_hidden_file(const char *filename, const bool hide_dot)
 {
+	char *sep = (char *)BLI_last_slash(filename);
 	bool is_hidden = false;
 
 	if (hide_dot) {
@@ -485,9 +486,25 @@ static bool is_hidden_file(const char *filename, const bool hide_dot)
 			}
 		}
 	}
-	if (((filename[0] == '.') && (filename[1] == 0))) {
+	if (!is_hidden && ((filename[0] == '.') && (filename[1] == 0))) {
 		is_hidden = true; /* ignore . */
 	}
+	/* filename might actually be a piece of path, in which case we have to check all its parts. */
+	if (!is_hidden && sep) {
+		char tmp_filename[FILE_MAX_LIBEXTRA];
+
+		BLI_strncpy(tmp_filename, filename, sizeof(tmp_filename));
+		sep = tmp_filename + (sep - filename);
+		while (sep) {
+			BLI_assert(sep[1] != '\0');
+			if (is_hidden_file(sep + 1, hide_dot)) {
+				is_hidden = true;
+				break;
+			}
+			*sep = '\0';
+			sep = (char *)BLI_last_slash(tmp_filename);
+		}
+	}
 	return is_hidden;
 }




More information about the Bf-blender-cvs mailing list