[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34377] trunk/blender/source/blender: option for the path iterator to loop over packed files so their dir separator can be switched on file load .

Campbell Barton ideasman42 at gmail.com
Tue Jan 18 01:10:11 CET 2011


Revision: 34377
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34377
Author:   campbellbarton
Date:     2011-01-18 00:10:11 +0000 (Tue, 18 Jan 2011)
Log Message:
-----------
option for the path iterator to loop over packed files so their dir separator can be switched on file load.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/blender.c
    trunk/blender/source/blender/blenlib/BLI_bpath.h
    trunk/blender/source/blender/blenlib/intern/bpath.c
    trunk/blender/source/blender/python/intern/bpy.c

Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c	2011-01-17 23:47:11 UTC (rev 34376)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c	2011-01-18 00:10:11 UTC (rev 34377)
@@ -160,7 +160,7 @@
 	char filepath_expanded[1024];
 	Scene *scene;
 
-	for(BLI_bpathIterator_init(&bpi, main, main->name); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
+	for(BLI_bpathIterator_init(&bpi, main, main->name, BPATH_USE_PACKED); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
 		BLI_bpathIterator_getPath(bpi, filepath_expanded);
 
 		BLI_clean(filepath_expanded);

Modified: trunk/blender/source/blender/blenlib/BLI_bpath.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_bpath.h	2011-01-17 23:47:11 UTC (rev 34376)
+++ trunk/blender/source/blender/blenlib/BLI_bpath.h	2011-01-18 00:10:11 UTC (rev 34377)
@@ -36,7 +36,7 @@
 struct ReportList;
 struct Main;
 
-void			BLI_bpathIterator_init				(struct BPathIterator **bpi, struct Main *bmain, const char *basedir);
+void			BLI_bpathIterator_init				(struct BPathIterator **bpi, struct Main *bmain, const char *basedir, const int flag);
 void			BLI_bpathIterator_free				(struct BPathIterator *bpi);
 const char*		BLI_bpathIterator_getLib			(struct BPathIterator *bpi);
 const char*		BLI_bpathIterator_getName			(struct BPathIterator *bpi);
@@ -57,4 +57,6 @@
 void makeFilesAbsolute(struct Main *bmain, const char *basedir, struct ReportList *reports);
 void findMissingFiles(struct Main *bmain, const char *str);
 
+#define BPATH_USE_PACKED 1
+
 #endif // BLI_BPATH_H

Modified: trunk/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/bpath.c	2011-01-17 23:47:11 UTC (rev 34376)
+++ trunk/blender/source/blender/blenlib/intern/bpath.c	2011-01-18 00:10:11 UTC (rev 34377)
@@ -84,6 +84,7 @@
 	void*	data;
 	int		len;
 	int		type;
+	int		flag; /* iterator options */
 
 	void (*setpath_callback)(struct BPathIterator *, const char *);
 	void (*getpath_callback)(struct BPathIterator *, char *);
@@ -113,7 +114,8 @@
 	 BPATH_DONE
 };
 
-void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir) {
+void BLI_bpathIterator_init(struct BPathIterator **bpi_pt, Main *bmain, const char *basedir, const int flag)
+{
 	BPathIterator *bpi;
 
 	bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_init");
@@ -130,7 +132,9 @@
 	bpi->seqdata.seq= 0;
 	bpi->seqdata.seqar= NULL;
 	bpi->seqdata.scene= NULL;
-	
+
+	bpi->flag= flag;
+
 	bpi->base_path= basedir; /* normally bmain->name */
 	bpi->bmain= bmain;
 
@@ -196,7 +200,8 @@
 }
 
 /* gets the first or the next image that has a path - not a viewer node or generated image */
-static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) {
+static struct Image *ima_stepdata__internal(struct Image *ima, const int step_next, const int flag)
+{
 	if (ima==NULL)
 		return NULL;
 	
@@ -204,15 +209,19 @@
 		ima= ima->id.next;
 	
 	while (ima) {
-		if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
-			break;
+		if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+			if(ima->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
+				break;
+			}
+		}
 		/* image is not a image with a path, skip it */
 		ima= ima->id.next;
 	}	
 	return ima;
 }
 
-static struct Tex *tex_stepdata__internal(struct Tex *tex, int step_next) {
+static struct Tex *tex_stepdata__internal(struct Tex *tex, const int step_next, const int UNUSED(flag))
+{
 	if (tex==NULL)
 		return NULL;
 
@@ -228,7 +237,8 @@
 	return tex;
 }
 
-static struct Text *text_stepdata__internal(struct Text *text, int step_next) {
+static struct Text *text_stepdata__internal(struct Text *text, const int step_next, const int UNUSED(flag))
+{
 	if (text==NULL)
 		return NULL;
 
@@ -244,7 +254,8 @@
 	return text;
 }
 
-static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) {
+static struct VFont *vf_stepdata__internal(struct VFont *vf, const int step_next, const int flag)
+{
 	if (vf==NULL)
 		return NULL;
 	
@@ -252,8 +263,10 @@
 		vf= vf->id.next;
 	
 	while (vf) {
-		if (vf->packedfile==NULL && strcmp(vf->name, FO_BUILTIN_NAME)!=0) {
-			break;
+		if (strcmp(vf->name, FO_BUILTIN_NAME)!=0) {
+			if(vf->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
+				break;
+			}
 		}
 		
 		/* font with no path, skip it */
@@ -262,7 +275,8 @@
 	return vf;
 }
 
-static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) {
+static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next, const int flag)
+{
 	if (snd==NULL)
 		return NULL;
 	
@@ -270,10 +284,10 @@
 		snd= snd->id.next;
 	
 	while (snd) {
-		if (snd->packedfile==NULL) {
+		if(snd->packedfile==NULL || (flag & BPATH_USE_PACKED)) {
 			break;
 		}
-		
+
 		/* font with no path, skip it */
 		snd= snd->id.next;
 	}	
@@ -439,8 +453,8 @@
 		
 		if  ((bpi->type) == BPATH_IMAGE) {
 			/*if (bpi->data)	bpi->data= ((ID *)bpi->data)->next;*/
-			if (bpi->data)	bpi->data= ima_stepdata__internal( (Image *)bpi->data, 1 ); /* must skip images that have no path */
-			else 			bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0);
+			if (bpi->data)	bpi->data= ima_stepdata__internal((Image *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+			else 			bpi->data= ima_stepdata__internal(bpi->bmain->image.first, 0, bpi->flag);
 			
 			if (bpi->data) {
 				/* get the path info from this datatype */
@@ -461,8 +475,8 @@
 
 		if  ((bpi->type) == BPATH_TEXTURE) {
 			/*if (bpi->data)	bpi->data= ((ID *)bpi->data)->next;*/
-			if (bpi->data)	bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1 ); /* must skip images that have no path */
-			else 			bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0);
+			if (bpi->data)	bpi->data= tex_stepdata__internal( (Tex *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+			else 			bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0, bpi->flag);
 
 			if (bpi->data) {
 				/* get the path info from this datatype */
@@ -488,8 +502,8 @@
 
 		if  ((bpi->type) == BPATH_TEXT) {
 			/*if (bpi->data)	bpi->data= ((ID *)bpi->data)->next;*/
-			if (bpi->data)	bpi->data= text_stepdata__internal( (Text *)bpi->data, 1 ); /* must skip images that have no path */
-			else 			bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0);
+			if (bpi->data)	bpi->data= text_stepdata__internal((Text *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+			else 			bpi->data= text_stepdata__internal(bpi->bmain->text.first, 0, bpi->flag);
 
 			if (bpi->data) {
 				/* get the path info from this datatype */
@@ -509,8 +523,8 @@
 		}
 
 		else if  ((bpi->type) == BPATH_SOUND) {
-			if (bpi->data)	bpi->data= snd_stepdata__internal( (bSound *)bpi->data, 1 ); /* must skip images that have no path */
-			else 			bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0);
+			if (bpi->data)	bpi->data= snd_stepdata__internal((bSound *)bpi->data, 1, bpi->flag); /* must skip images that have no path */
+			else 			bpi->data= snd_stepdata__internal(bpi->bmain->sound.first, 0, bpi->flag);
 
 			if (bpi->data) {
 				/* get the path info from this datatype */
@@ -530,8 +544,8 @@
 			
 		} else if  ((bpi->type) == BPATH_FONT) {
 			
-			if (bpi->data)	bpi->data= vf_stepdata__internal( (VFont *)bpi->data, 1 );
-			else 			bpi->data= vf_stepdata__internal( bpi->bmain->vfont.first, 0 );
+			if (bpi->data)	bpi->data= vf_stepdata__internal((VFont *)bpi->data, 1, bpi->flag);
+			else 			bpi->data= vf_stepdata__internal(bpi->bmain->vfont.first, 0, bpi->flag);
 			
 			if (bpi->data) {
 				/* get the path info from this datatype */
@@ -657,7 +671,7 @@
 	/* be sure there is low chance of the path being too short */
 	char filepath_expanded[FILE_MAXDIR*2]; 
 	
-	BLI_bpathIterator_init(&bpi, bmain, bmain->name);
+	BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
 	while (!BLI_bpathIterator_isDone(bpi)) {
 		BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
 		
@@ -679,7 +693,7 @@
 	/* be sure there is low chance of the path being too short */
 	char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
 	
-	BLI_bpathIterator_init(&bpi, bmain, basedir);
+	BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
 	while (!BLI_bpathIterator_isDone(bpi)) {
 		BLI_bpathIterator_getPath(bpi, filepath);
 		libpath= BLI_bpathIterator_getLib(bpi);
@@ -730,7 +744,7 @@
 	/* be sure there is low chance of the path being too short */
 	char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
 	
-	BLI_bpathIterator_init(&bpi, bmain, basedir);
+	BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
 	while (!BLI_bpathIterator_isDone(bpi)) {
 		BLI_bpathIterator_getPath(bpi, filepath);
 		libpath= BLI_bpathIterator_getLib(bpi);
@@ -836,7 +850,7 @@
 	
 	BLI_split_dirfile(str, dirname, NULL);
 	
-	BLI_bpathIterator_init(&bpi, bmain, bmain->name);
+	BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0);
 	
 	while (!BLI_bpathIterator_isDone(bpi)) {
 		BLI_bpathIterator_getPath(bpi, filepath);

Modified: trunk/blender/source/blender/python/intern/bpy.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy.c	2011-01-17 23:47:11 UTC (rev 34376)
+++ trunk/blender/source/blender/python/intern/bpy.c	2011-01-18 00:10:11 UTC (rev 34377)
@@ -96,7 +96,7 @@
 
 	list= PyList_New(0);
 
-	for(BLI_bpathIterator_init(&bpi, G.main, NULL); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
+	for(BLI_bpathIterator_init(&bpi, G.main, NULL, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
 		/* build the list */
 		if (absolute) {
 			BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);




More information about the Bf-blender-cvs mailing list