[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57678] trunk/blender/source/blender: fix [#35825] "Find missing files" seems to search for files which are not missing

Campbell Barton ideasman42 at gmail.com
Mon Jun 24 04:57:08 CEST 2013


Revision: 57678
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57678
Author:   campbellbarton
Date:     2013-06-24 02:57:06 +0000 (Mon, 24 Jun 2013)
Log Message:
-----------
fix [#35825] "Find missing files" seems to search for files which are not missing
Made finding paths for files that exist optional (and off by default), since its handy for relocating projects.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_bpath.h
    trunk/blender/source/blender/blenkernel/intern/bpath.c
    trunk/blender/source/blender/editors/space_info/info_ops.c

Modified: trunk/blender/source/blender/blenkernel/BKE_bpath.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_bpath.h	2013-06-24 02:30:09 UTC (rev 57677)
+++ trunk/blender/source/blender/blenkernel/BKE_bpath.h	2013-06-24 02:57:06 UTC (rev 57678)
@@ -65,7 +65,8 @@
 
 /* creates a text file with missing files if there are any */
 void BKE_bpath_missing_files_check(struct Main *bmain, struct ReportList *reports);
-void BKE_bpath_missing_files_find(struct Main *bmain, const char *searchpath, struct ReportList *reports);
+void BKE_bpath_missing_files_find(struct Main *bmain, const char *searchpath, struct ReportList *reports,
+                                  const bool find_all);
 void BKE_bpath_relative_convert(struct Main *bmain, const char *basedir, struct ReportList *reports);
 void BKE_bpath_absolute_convert(struct Main *bmain, const char *basedir, struct ReportList *reports);
 

Modified: trunk/blender/source/blender/blenkernel/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/bpath.c	2013-06-24 02:30:09 UTC (rev 57677)
+++ trunk/blender/source/blender/blenkernel/intern/bpath.c	2013-06-24 02:57:06 UTC (rev 57678)
@@ -263,8 +263,9 @@
 
 typedef struct BPathFind_Data {
 	const char *basedir;
-	char searchdir[FILE_MAX];
+	const char *searchdir;
 	ReportList *reports;
+	bool find_all;
 } BPathFind_Data;
 
 static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char *path_src)
@@ -276,6 +277,12 @@
 	int recur_depth = 0;
 	int found;
 
+	if (data->find_all == false) {
+		if (BLI_exists(path_src)) {
+			return false;
+		}
+	}
+
 	filename_new[0] = '\0';
 
 	found = findFileRecursive(filename_new,
@@ -300,14 +307,16 @@
 	}
 }
 
-void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports)
+void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports,
+                                  const bool find_all)
 {
 	struct BPathFind_Data data = {NULL};
 
 	data.reports = reports;
-	BLI_split_dir_part(searchpath, data.searchdir, sizeof(data.searchdir));
+	data.searchdir = searchpath;
+	data.find_all = find_all;
 
-	BKE_bpath_traverse_main(bmain, findMissingFiles_visit_cb, 0, (void *)&data);
+	BKE_bpath_traverse_main(bmain, findMissingFiles_visit_cb, BKE_BPATH_TRAVERSE_ABS, (void *)&data);
 }
 
 /* Run a visitor on a string, replacing the contents of the string as needed. */

Modified: trunk/blender/source/blender/editors/space_info/info_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_info/info_ops.c	2013-06-24 02:30:09 UTC (rev 57677)
+++ trunk/blender/source/blender/editors/space_info/info_ops.c	2013-06-24 02:57:06 UTC (rev 57678)
@@ -422,8 +422,10 @@
 static int find_missing_files_exec(bContext *C, wmOperator *op)
 {
 	Main *bmain = CTX_data_main(C);
-	const char *searchpath = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
-	BKE_bpath_missing_files_find(bmain, searchpath, op->reports);
+	const char *searchpath = RNA_string_get_alloc(op->ptr, "directory", NULL, 0);
+	const bool find_all = RNA_boolean_get(op->ptr, "find_all");
+
+	BKE_bpath_missing_files_find(bmain, searchpath, op->reports, find_all);
 	MEM_freeN((void *)searchpath);
 
 	return OPERATOR_FINISHED;
@@ -451,8 +453,10 @@
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
 	/* properties */
+	RNA_def_boolean(ot->srna, "find_all", false, "Find All", "Find all files in the search path (not just missing)");
+
 	WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE,
-	                               WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+	                               WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY);
 }
 
 /********************* report box operator *********************/




More information about the Bf-blender-cvs mailing list