[Bf-blender-cvs] [52d3e71] asset-experiments: Move back path, image etc. to FileDirEntry.

Bastien Montagne noreply at git.blender.org
Tue Feb 24 16:24:03 CET 2015


Commit: 52d3e71302ff2b164685c7eb436217c9100b8194
Author: Bastien Montagne
Date:   Tue Feb 24 16:20:19 2015 +0100
Branches: asset-experiments
https://developer.blender.org/rB52d3e71302ff2b164685c7eb436217c9100b8194

Move back path, image etc. to FileDirEntry.

Also, reduce revision's uuid to 64bytes, should be more than enough!

Thing is, we can expect tens (if not hundreds) of thousands of revisions from a
big assets repository with history storage (vcs). So we want that struct
to be as small as possible.

Also, we do not expect to handle several variants/revisions of a same asset within
a same 'context' (there is always only one active variant & rev). So storing
path & co at entry level shall be enough. And helps make code simpler/nicer.

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

M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/makesdna/DNA_space_types.h

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

diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 82467ef..852570a 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -491,7 +491,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
 
 		file = filelist_file(files, i);
 
-		BLI_join_dirfile(path, sizeof(path), file->entry->root, file->entry->relpath);
+		BLI_join_dirfile(path, sizeof(path), file->root, file->relpath);
 		name = fileentry_uiname(file, dir);
 
 		UI_ThemeColor4(TH_TEXT);
@@ -505,7 +505,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
 				int shade = (params->active_file == i) || (file->selflag & FILE_SEL_HIGHLIGHTED) ? 20 : 0;
 
 				/* readonly files (".." and ".") must not be drawn as selected - set color back to normal */
-				if (FILENAME_IS_CURRPAR(file->entry->relpath)) {
+				if (FILENAME_IS_CURRPAR(file->relpath)) {
 					colorid = TH_BACK;
 				}
 				draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade);
@@ -514,7 +514,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
 		UI_draw_roundbox_corner_set(UI_CNR_NONE);
 
 		/* don't drag parent or refresh items */
-		do_drag = !(FILENAME_IS_CURRPAR(file->entry->relpath));
+		do_drag = !(FILENAME_IS_CURRPAR(file->relpath));
 
 		if (FILE_IMGDISPLAY == params->display) {
 			const int icon = filelist_geticon(files, i, false);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 764c54c..ddf3bd2 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -179,14 +179,14 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
 		params->active_file = selected_idx;
 
 		if (file->typeflag & FILE_TYPE_DIR) {
-			const bool is_parent_dir = FILENAME_IS_PARENT(file->entry->relpath);
+			const bool is_parent_dir = FILENAME_IS_PARENT(file->relpath);
 
 			if (do_diropen == false) {
 				params->file[0] = '\0';
 				retval = FILE_SELECT_DIR;
 			}
 			/* the path is too long and we are not going up! */
-			else if (!is_parent_dir && strlen(params->dir) + strlen(file->entry->relpath) >= FILE_MAX) {
+			else if (!is_parent_dir && strlen(params->dir) + strlen(file->relpath) >= FILE_MAX) {
 				// XXX error("Path too long, cannot enter this directory");
 			}
 			else {
@@ -202,7 +202,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
 				}
 				else {
 					BLI_cleanup_dir(G.main->name, params->dir);
-					strcat(params->dir, file->entry->relpath);
+					strcat(params->dir, file->relpath);
 					BLI_add_slash(params->dir);
 				}
 
@@ -211,8 +211,8 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
 			}
 		}
 		else {
-			if (file->entry->relpath) {
-				BLI_strncpy(params->file, file->entry->relpath, FILE_MAXFILE);
+			if (file->relpath) {
+				BLI_strncpy(params->file, file->relpath, FILE_MAXFILE);
 			}
 			retval = FILE_SELECT_FILE;
 		}
@@ -278,7 +278,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *
 			for (idx = sel.last; idx >= 0; idx--) {
 				struct FileDirEntry *file = filelist_file(sfile->files, idx);
 
-				if (FILENAME_IS_CURRPAR(file->entry->relpath)) {
+				if (FILENAME_IS_CURRPAR(file->relpath)) {
 					file->selflag &= ~FILE_SEL_HIGHLIGHTED;
 				}
 
@@ -371,7 +371,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 
 		if (idx >= 0) {
 			struct FileDirEntry *file = filelist_file(sfile->files, idx);
-			if (FILENAME_IS_CURRPAR(file->entry->relpath)) {
+			if (FILENAME_IS_CURRPAR(file->relpath)) {
 				/* skip - If a readonly file (".." or ".") is selected, skip deselect all! */
 			}
 			else {
@@ -875,7 +875,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
 				if (filelist_is_selected(sfile->files, i, CHECK_FILES)) {
 					FileDirEntry *file = filelist_file(sfile->files, i);
 					RNA_property_collection_add(op->ptr, prop, &itemptr);
-					RNA_string_set(&itemptr, "name", file->entry->relpath);
+					RNA_string_set(&itemptr, "name", file->relpath);
 					num_files++;
 				}
 			}
@@ -894,7 +894,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
 				if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) {
 					FileDirEntry *file = filelist_file(sfile->files, i);
 					RNA_property_collection_add(op->ptr, prop, &itemptr);
-					RNA_string_set(&itemptr, "name", file->entry->relpath);
+					RNA_string_set(&itemptr, "name", file->relpath);
 					num_dirs++;
 				}
 			}
@@ -1685,7 +1685,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
 		if ( (0 <= idx) && (idx < numfiles) ) {
 			FileDirEntry *file = filelist_file(sfile->files, idx);
 			filelist_select_file(sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
-			BLI_strncpy(sfile->params->renameedit, file->entry->relpath, FILE_MAXFILE);
+			BLI_strncpy(sfile->params->renameedit, file->relpath, FILE_MAXFILE);
 			sfile->params->renamefile[0] = '\0';
 		}
 		ED_area_tag_redraw(sa);
@@ -1705,7 +1705,7 @@ static int file_rename_poll(bContext *C)
 
 		if (idx >= 0) {
 			FileDirEntry *file = filelist_file(sfile->files, idx);
-			if (FILENAME_IS_CURRPAR(file->entry->relpath)) {
+			if (FILENAME_IS_CURRPAR(file->relpath)) {
 				poll = 0;
 			}
 		}
@@ -1775,7 +1775,7 @@ int file_delete_exec(bContext *C, wmOperator *UNUSED(op))
 	for (i = 0; i < numfiles; i++) {
 		if (filelist_is_selected(sfile->files, i, CHECK_FILES)) {
 			file = filelist_file(sfile->files, i);
-			BLI_make_file_string(G.main->name, str, sfile->params->dir, file->entry->relpath);
+			BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relpath);
 			BLI_delete(str, false, false);
 		}
 	}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 0378e6f..910d2cc 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -339,10 +339,10 @@ static int compare_direntry_generic(const FileDirEntry *entry1, const FileDirEnt
 #endif
 
 	/* make sure "." and ".." are always first */
-	if (FILENAME_IS_CURRENT(entry1->entry->relpath)) return -1;
-	if (FILENAME_IS_CURRENT(entry2->entry->relpath)) return 1;
-	if (FILENAME_IS_PARENT(entry1->entry->relpath)) return -1;
-	if (FILENAME_IS_PARENT(entry2->entry->relpath)) return 1;
+	if (FILENAME_IS_CURRENT(entry1->relpath)) return -1;
+	if (FILENAME_IS_CURRENT(entry2->relpath)) return 1;
+	if (FILENAME_IS_PARENT(entry1->relpath)) return -1;
+	if (FILENAME_IS_PARENT(entry2->relpath)) return 1;
 	
 	return 0;
 }
@@ -419,10 +419,10 @@ static int compare_extension(const void *a1, const void *a2)
 		return ret;
 	}
 
-	if (!(sufix1 = strstr(entry1->entry->relpath, ".blend.gz")))
-		sufix1 = strrchr(entry1->entry->relpath, '.');
-	if (!(sufix2 = strstr(entry2->entry->relpath, ".blend.gz")))
-		sufix2 = strrchr(entry2->entry->relpath, '.');
+	if (!(sufix1 = strstr(entry1->relpath, ".blend.gz")))
+		sufix1 = strrchr(entry1->relpath, '.');
+	if (!(sufix2 = strstr(entry2->relpath, ".blend.gz")))
+		sufix2 = strrchr(entry2->relpath, '.');
 	if (!sufix1) sufix1 = nil;
 	if (!sufix2) sufix2 = nil;
 
@@ -434,9 +434,9 @@ static int compare_extension(const void *a1, const void *a2)
 		char *group1, *group2, *name1, *name2;
 		int grp_comp;
 
-		BLI_join_dirfile(abspath, sizeof(abspath), entry1->entry->root, entry1->entry->relpath);
+		BLI_join_dirfile(abspath, sizeof(abspath), entry1->root, entry1->relpath);
 		BLO_library_path_explode(abspath, lib1, &group1, &name1);
-		BLI_join_dirfile(abspath, sizeof(abspath), entry2->entry->root, entry2->entry->relpath);
+		BLI_join_dirfile(abspath, sizeof(abspath), entry2->root, entry2->relpath);
 		BLO_library_path_explode(abspath, lib2, &group2, &name2);
 
 		BLI_assert(group1);
@@ -547,9 +547,9 @@ static bool is_hidden_file(const char *filename, FileListFilter *filter)
 
 static bool is_filtered_file(FileDirEntry *file, const char *UNUSED(root), FileListFilter *filter)
 {
-	bool is_filtered = !is_hidden_file(file->entry->relpath, filter);
+	bool is_filtered = !is_hidden_file(file->relpath, filter);
 
-	if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->entry->relpath)) {
+	if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->relpath)) {
 		if (file->typeflag & FILE_TYPE_DIR) {
 			if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
 				if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
@@ -568,7 +568,7 @@ static bool is_filtered_file(FileDirEntry *file, const char *UNUSED(root), FileL
 			}
 		}
 		if (is_filtered && (filter->filter_search[0] != '\0')) {
-			if (fnmatch(filter->filter_search, file->entry->relpath, FNM_CASEFOLD) != 0) {
+			if (fnmatch(filter->filter_search, file->relpath, FNM_CASEFOLD) != 0) {
 				is_filtered = false;
 			}
 		}
@@ -582,11 +582,11 @@ static bool is_filtered_lib(FileDirEntry *file, const char *root, FileListFilter
 	bool is_filtered;
 	char path[FILE_MAX_LIBEXTRA], dir[FILE_MAXDIR], *group, *name;
 
-	BLI_join_dirfile(path, sizeof(path), root, file->entry->relpath);
+	BLI_join_dirfile(path, sizeof(path), root, file->relpath);
 
 	if (BLO_library_path_explode(path, dir, &group, &name)) {
-		is_filtered = !is_hidden_file(file->entry->relpath, filter);
-		if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->entry->relpath)) {
+		is_filtered = !is_hidden_file(file->relpath, filter);
+		if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->relpath)) {
 			if (file->typeflag & FILE_TYPE_DIR) {
 				if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
 					if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
@@ -611,7 +611,7 @@ static bool is_filtered_lib(FileDirEntry *file, const char *root, FileListFilter
 				}
 			}
 			if (is_filtered && (filter->filter_search[0] != '\0')) {
-				if (fnmatch(filter->filter_search, file->entry->relpath, FNM_CASEFOLD) != 0) {
+				if (

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list