| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Campbell barton | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | #include "DNA_ID.h" /* Library */
 | 
					
						
							|  |  |  | #include "DNA_vfont_types.h"
 | 
					
						
							|  |  |  | #include "DNA_image_types.h"
 | 
					
						
							|  |  |  | #include "DNA_sound_types.h"
 | 
					
						
							|  |  |  | #include "DNA_scene_types.h" /* to get the current frame */
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | #include "DNA_sequence_types.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | #include "DNA_text_types.h"
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | #include "BLI_blenlib.h"
 | 
					
						
							|  |  |  | #include "BLI_bpath.h"
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | #include "BKE_image.h" /* so we can check the image's type */
 | 
					
						
							|  |  |  | #include "BKE_main.h" /* so we can access G.main->*.first */
 | 
					
						
							|  |  |  | #include "BKE_sequence.h"
 | 
					
						
							|  |  |  | #include "BKE_text.h" /* for writing to a textblock */
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | #include "BKE_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | //XXX #include "BIF_screen.h" /* only for wait cursor */
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | /* for sequence */ | 
					
						
							| 
									
										
											  
											
												
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
  later added in trunk also, but reverted partially, specifically revision
  16683. I have left out this reversion in the 2.5 branch since I think it is
  needed there.
  http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
  for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
  -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
  differently. Since this is changed so much, and I don't think those fixes
  would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
  initialized when running with -P. The code that initializes the screen there
  I had to disable, that can't work in 2.5 anymore but left it commented as a
  reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
  still use changes that were done in trunk.
											
										 
											2008-11-12 21:16:53 +00:00
										 |  |  | //XXX #include "BSE_sequence.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-04 20:34:37 +00:00
										 |  |  | //XXX define below from BSE_sequence.h - otherwise potentially odd behaviour
 | 
					
						
							|  |  |  | #define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE)
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* path/file handeling stuff */ | 
					
						
							|  |  |  | #ifndef WIN32
 | 
					
						
							|  |  |  |   #include <dirent.h>
 | 
					
						
							| 
									
										
										
										
											2007-12-20 12:37:15 +00:00
										 |  |  |   #include <unistd.h>
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  |   #include "BLI_winstuff.h"
 | 
					
						
							| 
									
										
										
										
											2007-12-20 12:37:15 +00:00
										 |  |  |   #include <io.h>
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <sys/stat.h>
 | 
					
						
							|  |  |  | #include <sys/types.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <fcntl.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | #include <string.h>
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define FILE_MAX			240
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* TODO - BPATH_PLUGIN, BPATH_SEQ */ | 
					
						
							|  |  |  | enum BPathTypes { | 
					
						
							|  |  |  | 	BPATH_IMAGE = 0, | 
					
						
							|  |  |  | 	BPATH_SOUND, | 
					
						
							|  |  |  | 	BPATH_FONT, | 
					
						
							|  |  |  | 	BPATH_LIB, | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BPATH_SEQ, | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |  	BPATH_DONE | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BLI_bpathIterator_init( struct BPathIterator *bpi ) { | 
					
						
							|  |  |  | 	bpi->type = BPATH_IMAGE; | 
					
						
							|  |  |  | 	bpi->data = NULL; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	bpi->getpath_callback = NULL; | 
					
						
							|  |  |  | 	bpi->setpath_callback = NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* Sequencer spesific */ | 
					
						
							|  |  |  | 	bpi->seqdata.totseq = 0; | 
					
						
							|  |  |  | 	bpi->seqdata.seq = 0; | 
					
						
							|  |  |  | 	bpi->seqdata.seqar = NULL; | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 	bpi->seqdata.scene = NULL; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	BLI_bpathIterator_step(bpi); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | void BLI_bpathIterator_free( struct BPathIterator *bpi ) { | 
					
						
							|  |  |  | 	if (bpi->seqdata.seqar) | 
					
						
							|  |  |  | 		MEM_freeN((void *)bpi->seqdata.seqar); | 
					
						
							|  |  |  | 	bpi->seqdata.seqar = NULL; | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 	bpi->seqdata.scene = NULL; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void BLI_bpathIterator_getPath( struct BPathIterator *bpi, char *path) { | 
					
						
							|  |  |  | 	if (bpi->getpath_callback) { | 
					
						
							|  |  |  | 		bpi->getpath_callback( bpi, path ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		strcpy(path, bpi->path); /* warning, we assume 'path' are long enough */ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BLI_bpathIterator_setPath( struct BPathIterator *bpi, char *path) { | 
					
						
							|  |  |  | 	if (bpi->setpath_callback) { | 
					
						
							|  |  |  | 		bpi->setpath_callback( bpi, path ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		strcpy(bpi->path, path); /* warning, we assume 'path' are long enough */ | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_expanded) { | 
					
						
							|  |  |  | 	char *libpath; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BLI_bpathIterator_getPath(bpi, path_expanded); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	libpath = BLI_bpathIterator_getLib(bpi); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (libpath) { /* check the files location relative to its library path */ | 
					
						
							| 
									
										
										
										
											2008-05-04 09:41:15 +00:00
										 |  |  | 		BLI_convertstringcode(path_expanded, libpath); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	} else { /* local data, use the blend files path */ | 
					
						
							| 
									
										
										
										
											2008-05-04 09:41:15 +00:00
										 |  |  | 		BLI_convertstringcode(path_expanded, G.sce); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	return bpi->lib; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | char* BLI_bpathIterator_getName( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	return bpi->name; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | int	BLI_bpathIterator_getType( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	return bpi->type; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | int	BLI_bpathIterator_getPathMaxLen( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	return bpi->len; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* gets the first or the next image that has a path - not a viewer node or generated image */ | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) { | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	if (ima==NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (step_next) | 
					
						
							|  |  |  | 		ima = ima->id.next; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	while (ima) { | 
					
						
							|  |  |  | 		if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		/* image is not a image with a path, skip it */ | 
					
						
							|  |  |  | 		ima = ima->id.next; | 
					
						
							|  |  |  | 	}	 | 
					
						
							|  |  |  | 	return ima; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) { | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	if (vf==NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (step_next) | 
					
						
							|  |  |  | 		vf = vf->id.next; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	while (vf) { | 
					
						
							|  |  |  | 		if (vf->packedfile==NULL && BLI_streq(vf->name, "<builtin>")==0) { | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		/* font with no path, skip it */ | 
					
						
							|  |  |  | 		vf = vf->id.next; | 
					
						
							|  |  |  | 	}	 | 
					
						
							|  |  |  | 	return vf; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next) { | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	if (snd==NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (step_next) | 
					
						
							|  |  |  | 		snd = snd->id.next; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	while (snd) { | 
					
						
							|  |  |  | 		if (snd->packedfile==NULL) { | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		/* font with no path, skip it */ | 
					
						
							|  |  |  | 		snd = snd->id.next; | 
					
						
							|  |  |  | 	}	 | 
					
						
							|  |  |  | 	return snd; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int step_next) { | 
					
						
							|  |  |  | 	Sequence *seq; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 	/* Initializing */ | 
					
						
							|  |  |  | 	if (bpi->seqdata.scene==NULL) { | 
					
						
							|  |  |  | 		bpi->seqdata.scene= G.main->scene.first; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (step_next) { | 
					
						
							|  |  |  | 		bpi->seqdata.seq++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 	while (bpi->seqdata.scene) { | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if (bpi->seqdata.scene->ed) { | 
					
						
							|  |  |  | 			if (bpi->seqdata.seqar == NULL) { | 
					
						
							|  |  |  | 				/* allocate the sequencer array */ | 
					
						
							| 
									
										
										
										
											2008-12-15 05:21:44 +00:00
										 |  |  | 				seq_array(bpi->seqdata.scene->ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq);		 | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 				bpi->seqdata.seq = 0; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			if (bpi->seqdata.seq >= bpi->seqdata.totseq) { | 
					
						
							|  |  |  | 				seq = NULL; | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				seq = bpi->seqdata.seqar[bpi->seqdata.seq]; | 
					
						
							|  |  |  | 				while (!SEQ_HAS_PATH(seq)) { | 
					
						
							|  |  |  | 					bpi->seqdata.seq++; | 
					
						
							|  |  |  | 					if (bpi->seqdata.seq >= bpi->seqdata.totseq) { | 
					
						
							|  |  |  | 						seq = NULL; | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					seq = bpi->seqdata.seqar[bpi->seqdata.seq]; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 			if (seq) { | 
					
						
							|  |  |  | 				return seq; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				/* keep looking through the next scene, reallocate seq array */ | 
					
						
							| 
									
										
										
										
											2008-04-28 16:09:17 +00:00
										 |  |  | 				if (bpi->seqdata.seqar) { | 
					
						
							|  |  |  | 					MEM_freeN((void *)bpi->seqdata.seqar); | 
					
						
							|  |  |  | 					bpi->seqdata.seqar = NULL; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 				bpi->seqdata.scene = bpi->seqdata.scene->id.next; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			/* no seq data in this scene, next */ | 
					
						
							|  |  |  | 			bpi->seqdata.scene = bpi->seqdata.scene->id.next; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return NULL; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-29 17:08:11 +00:00
										 |  |  | static void seq_getpath(struct BPathIterator *bpi, char *path) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	Sequence *seq = (Sequence *)bpi->data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	path[0] = '\0'; /* incase we cant get the path */ | 
					
						
							|  |  |  | 	if (seq==NULL) return; | 
					
						
							|  |  |  | 	if (SEQ_HAS_PATH(seq)) { | 
					
						
							|  |  |  | 		if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) { | 
					
						
							|  |  |  | 			BLI_strncpy(path, seq->strip->dir, FILE_MAX); | 
					
						
							|  |  |  | 			BLI_add_slash(path); /* incase its missing */ | 
					
						
							|  |  |  | 			if (seq->strip->stripdata) { /* should always be true! */ | 
					
						
							|  |  |  | 				/* Using the first image is weak for image sequences */ | 
					
						
							|  |  |  | 				strcat(path, seq->strip->stripdata->name); | 
					
						
							|  |  |  | 			}  | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			/* simple case */ | 
					
						
							|  |  |  | 			BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-29 17:08:11 +00:00
										 |  |  | static void seq_setpath(struct BPathIterator *bpi, char *path) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	Sequence *seq = (Sequence *)bpi->data; | 
					
						
							|  |  |  | 	if (seq==NULL) return;  | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (SEQ_HAS_PATH(seq)) { | 
					
						
							|  |  |  | 		if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) { | 
					
						
							| 
									
										
										
										
											2008-04-26 13:08:57 +00:00
										 |  |  | 			BLI_split_dirfile_basic(path, seq->strip->dir, seq->strip->stripdata->name); | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			/* simple case */ | 
					
						
							|  |  |  | 			BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void bpi_type_step__internal( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	bpi->type++; /* advance to the next type */ | 
					
						
							|  |  |  | 	bpi->data = NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	switch (bpi->type) { | 
					
						
							|  |  |  | 	case BPATH_SEQ: | 
					
						
							|  |  |  | 		bpi->getpath_callback = seq_getpath; | 
					
						
							|  |  |  | 		bpi->setpath_callback = seq_setpath; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		bpi->getpath_callback = NULL; | 
					
						
							|  |  |  | 		bpi->setpath_callback = NULL; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | void BLI_bpathIterator_step( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	while (bpi->type != BPATH_DONE) { | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if  ((bpi->type) == BPATH_IMAGE) { | 
					
						
							|  |  |  | 			/*if (bpi->data)	bpi->data = ((ID *)bpi->data)->next;*/ | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			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(G.main->image.first, 0); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 			if (bpi->data) { | 
					
						
							|  |  |  | 				/* get the path info from this datatype */ | 
					
						
							|  |  |  | 				Image *ima = (Image *)bpi->data; | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				bpi->lib = ima->id.lib ? ima->id.lib->filename : NULL; | 
					
						
							|  |  |  | 				bpi->path = ima->name; | 
					
						
							|  |  |  | 				bpi->name = ima->id.name+2; | 
					
						
							|  |  |  | 				bpi->len = sizeof(ima->name); | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				/* we are done, advancing to the next item, this type worked fine */ | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 				bpi_type_step__internal(bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 		} else if  ((bpi->type) == BPATH_SOUND) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			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(G.main->sound.first, 0); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 			if (bpi->data) { | 
					
						
							|  |  |  | 				/* get the path info from this datatype */ | 
					
						
							|  |  |  | 				bSound *snd = (bSound *)bpi->data; | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				bpi->lib = snd->id.lib ? snd->id.lib->filename : NULL; | 
					
						
							|  |  |  | 				bpi->path = snd->sample->name; | 
					
						
							|  |  |  | 				bpi->name = snd->id.name+2; | 
					
						
							|  |  |  | 				bpi->len = sizeof(snd->sample->name); | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				/* we are done, advancing to the next item, this type worked fine */ | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 				bpi_type_step__internal(bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 		} else if  ((bpi->type) == BPATH_FONT) { | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			if (bpi->data)	bpi->data = vf_stepdata__internal( (VFont *)bpi->data, 1 ); | 
					
						
							|  |  |  | 			else 			bpi->data = vf_stepdata__internal( G.main->vfont.first, 0 ); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 			if (bpi->data) { | 
					
						
							|  |  |  | 				/* get the path info from this datatype */ | 
					
						
							|  |  |  | 				VFont *vf = (VFont *)bpi->data; | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				bpi->lib = vf->id.lib ? vf->id.lib->filename : NULL; | 
					
						
							|  |  |  | 				bpi->path = vf->name; | 
					
						
							|  |  |  | 				bpi->name = vf->id.name+2; | 
					
						
							|  |  |  | 				bpi->len = sizeof(vf->name); | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				/* we are done, advancing to the next item, this type worked fine */ | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 				bpi_type_step__internal(bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 		} else if  ((bpi->type) == BPATH_LIB) { | 
					
						
							|  |  |  | 			if (bpi->data)	bpi->data = ((ID *)bpi->data)->next; | 
					
						
							|  |  |  | 			else 			bpi->data = G.main->library.first; | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			if (bpi->data) { | 
					
						
							|  |  |  | 				/* get the path info from this datatype */ | 
					
						
							|  |  |  | 				Library *lib = (Library *)bpi->data; | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				bpi->lib = NULL; | 
					
						
							|  |  |  | 				bpi->path = lib->name; | 
					
						
							|  |  |  | 				bpi->name = NULL; | 
					
						
							|  |  |  | 				bpi->len = sizeof(lib->name); | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				/* we are done, advancing to the next item, this type worked fine */ | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 				bpi_type_step__internal(bpi); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else if  ((bpi->type) == BPATH_SEQ) { | 
					
						
							|  |  |  | 			if (bpi->data)	bpi->data = seq_stepdata__internal( bpi, 1 ); | 
					
						
							|  |  |  | 			else 			bpi->data = seq_stepdata__internal( bpi, 0 ); | 
					
						
							|  |  |  | 			if (bpi->data) { | 
					
						
							|  |  |  | 				Sequence *seq = (Sequence *)bpi->data; | 
					
						
							|  |  |  | 				bpi->lib = NULL; | 
					
						
							|  |  |  | 				bpi->name = seq->name+2; | 
					
						
							|  |  |  | 				bpi->len = sizeof(seq->strip->stripdata->name); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				bpi_type_step__internal(bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int BLI_bpathIterator_isDone( struct BPathIterator *bpi) { | 
					
						
							|  |  |  | 	return bpi->type==BPATH_DONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* include the path argument */ | 
					
						
							|  |  |  | static void bpathToText(Text *btxt, struct BPathIterator *bpi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *name; | 
					
						
							|  |  |  | 	char path_expanded[FILE_MAXDIR*2]; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	switch(BLI_bpathIterator_getType(bpi)) { | 
					
						
							|  |  |  | 	case BPATH_IMAGE: | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, "Image \"" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case BPATH_SOUND: | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, "Sound \"" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case BPATH_FONT: | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, "Font \"" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case BPATH_LIB: | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, "Library \"" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	case BPATH_SEQ: | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, "Sequence \"" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	default: | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, "Unknown \"" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	name = BLI_bpathIterator_getName(bpi); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (name) { | 
					
						
							|  |  |  | 		txt_insert_buf( btxt, name ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	txt_insert_buf( btxt, "\" " ); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BLI_bpathIterator_getPathExpanded(bpi, path_expanded); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	txt_insert_buf( btxt, path_expanded ); | 
					
						
							|  |  |  | 	txt_insert_buf( btxt, "\n" ); | 
					
						
							|  |  |  | 	txt_move_eof( btxt, 0 ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* high level function */ | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | void checkMissingFiles( char *txtname ) { | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	Text *btxt = NULL; | 
					
						
							|  |  |  | 	struct BPathIterator bpi; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* be sure there is low chance of the path being too short */ | 
					
						
							|  |  |  | 	char filepath_expanded[FILE_MAXDIR*2];  | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	BLI_bpathIterator_init(&bpi); | 
					
						
							|  |  |  | 	while (!BLI_bpathIterator_isDone(&bpi)) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		BLI_bpathIterator_getPathExpanded( &bpi, filepath_expanded ); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 		 | 
					
						
							|  |  |  | 		if (!BLI_exists(filepath_expanded)) { | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 			if (!btxt) { | 
					
						
							|  |  |  | 				btxt = add_empty_text( "missing_files.log" ); | 
					
						
							|  |  |  | 				if (txtname) { | 
					
						
							|  |  |  | 					BLI_strncpy(txtname, btxt->id.name+2, 24); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			bpathToText(btxt, &bpi); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		BLI_bpathIterator_step(&bpi); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BLI_bpathIterator_free(&bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* dont log any errors at the moment, should probably do this */ | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | void makeFilesRelative(char *txtname, int *tot, int *changed, int *failed, int *linked) { | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	struct BPathIterator bpi; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	char filepath[FILE_MAX], *libpath; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* be sure there is low chance of the path being too short */ | 
					
						
							|  |  |  | 	char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE]; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 	Text *btxt = NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	*tot = *changed = *failed = *linked = 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	BLI_bpathIterator_init(&bpi); | 
					
						
							|  |  |  | 	while (!BLI_bpathIterator_isDone(&bpi)) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		BLI_bpathIterator_getPath(&bpi, filepath); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 		libpath = BLI_bpathIterator_getLib(&bpi); | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:52:56 +00:00
										 |  |  | 		if(strncmp(filepath, "//", 2)) { | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 			if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */ | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 				(*linked)++; | 
					
						
							|  |  |  | 			} else { /* local data, use the blend files path */ | 
					
						
							|  |  |  | 				BLI_strncpy(filepath_relative, filepath, sizeof(filepath_relative)); | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 				/* Important BLI_cleanup_dir runs before the path is made relative
 | 
					
						
							|  |  |  | 				 * because it wont work for paths that start with "//../" */  | 
					
						
							|  |  |  | 				BLI_cleanup_file(G.sce, filepath_relative); /* fix any /foo/../foo/ */ | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 				BLI_makestringcode(G.sce, filepath_relative); | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 				/* be safe and check the length */ | 
					
						
							|  |  |  | 				if (BLI_bpathIterator_getPathMaxLen(&bpi) <= strlen(filepath_relative)) { | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 					if (!btxt) { | 
					
						
							|  |  |  | 						btxt = add_empty_text( "missing_no_rel.log" ); | 
					
						
							|  |  |  | 						if (txtname) { | 
					
						
							|  |  |  | 							BLI_strncpy(txtname, btxt->id.name+2, 24); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					bpathToText(btxt, &bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 					(*failed)++; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					if(strncmp(filepath_relative, "//", 2)==0) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 						BLI_bpathIterator_setPath(&bpi, filepath_relative); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 						(*changed)++; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:52:56 +00:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 						if (!btxt) { | 
					
						
							|  |  |  | 							btxt = add_empty_text( "missing_no_rel.log" ); | 
					
						
							|  |  |  | 							if (txtname) { | 
					
						
							|  |  |  | 								BLI_strncpy(txtname, btxt->id.name+2, 24); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						bpathToText(btxt, &bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:52:56 +00:00
										 |  |  | 						(*failed)++; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 		BLI_bpathIterator_step(&bpi); | 
					
						
							|  |  |  | 		(*tot)++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BLI_bpathIterator_free(&bpi); | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* dont log any errors at the moment, should probably do this -
 | 
					
						
							|  |  |  |  * Verry similar to makeFilesRelative - keep in sync! */ | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | void makeFilesAbsolute(char *txtname, int *tot, int *changed, int *failed, int *linked) { | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 	struct BPathIterator bpi; | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	char filepath[FILE_MAX], *libpath; | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* be sure there is low chance of the path being too short */ | 
					
						
							|  |  |  | 	char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE]; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 	Text *btxt = NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 	*tot = *changed = *failed = *linked = 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	BLI_bpathIterator_init(&bpi); | 
					
						
							|  |  |  | 	while (!BLI_bpathIterator_isDone(&bpi)) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		BLI_bpathIterator_getPath(&bpi, filepath); | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 		libpath = BLI_bpathIterator_getLib(&bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 		if(strncmp(filepath, "//", 2)==0) { | 
					
						
							|  |  |  | 			if (libpath) { /* cant make absolute if we are library - TODO, LOG THIS */ | 
					
						
							|  |  |  | 				(*linked)++; | 
					
						
							|  |  |  | 			} else { /* get the expanded path and check it is relative or too long */ | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 				BLI_bpathIterator_getPathExpanded( &bpi, filepath_absolute ); | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 				BLI_cleanup_file(G.sce, filepath_absolute); /* fix any /foo/../foo/ */ | 
					
						
							|  |  |  | 				/* to be safe, check the length */ | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 				if (BLI_bpathIterator_getPathMaxLen(&bpi) <= strlen(filepath_absolute)) { | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 					if (!btxt) { | 
					
						
							|  |  |  | 						btxt = add_empty_text( "missing_no_abs.log" ); | 
					
						
							|  |  |  | 						if (txtname) { | 
					
						
							|  |  |  | 							BLI_strncpy(txtname, btxt->id.name+2, 24); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					bpathToText(btxt, &bpi); | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 					(*failed)++; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					if(strncmp(filepath_absolute, "//", 2)) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 						BLI_bpathIterator_setPath(&bpi, filepath_absolute); | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 						(*changed)++; | 
					
						
							|  |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2007-12-31 12:03:26 +00:00
										 |  |  | 						if (!btxt) { | 
					
						
							|  |  |  | 							btxt = add_empty_text( "missing_no_abs.log" ); | 
					
						
							|  |  |  | 							if (txtname) { | 
					
						
							|  |  |  | 								BLI_strncpy(txtname, btxt->id.name+2, 24); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						bpathToText(btxt, &bpi); | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 						(*failed)++; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 		BLI_bpathIterator_step(&bpi); | 
					
						
							|  |  |  | 		(*tot)++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BLI_bpathIterator_free(&bpi); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-24 17:07:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | /* find this file recursively, use the biggest file so thumbnails dont get used by mistake
 | 
					
						
							|  |  |  |  - dir: subdir to search | 
					
						
							|  |  |  |  - filename: set this filename | 
					
						
							|  |  |  |  - filesize: filesize for the file | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | #define MAX_RECUR 16
 | 
					
						
							|  |  |  | static int findFileRecursive(char *filename_new, const char *dirname, const char *filename, int *filesize, int *recur_depth) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* file searching stuff */ | 
					
						
							|  |  |  | 	DIR *dir; | 
					
						
							|  |  |  | 	struct dirent *de; | 
					
						
							|  |  |  | 	struct stat status; | 
					
						
							|  |  |  | 	char path[FILE_MAX]; | 
					
						
							|  |  |  | 	int size; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	dir = opendir(dirname); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (dir==0) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (*filesize == -1) | 
					
						
							|  |  |  | 		*filesize = 0; /* dir opened fine */ | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	while ((de = readdir(dir)) != NULL) { | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if (strncmp(".", de->d_name, 2)==0 || strncmp("..", de->d_name, 3)==0) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		BLI_join_dirfile(path, dirname, de->d_name); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if (stat(path, &status) != 0) | 
					
						
							|  |  |  | 			continue; /* cant stat, dont bother with this file, could print debug info here */ | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if (S_ISREG(status.st_mode)) { /* is file */ | 
					
						
							|  |  |  | 			if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */ | 
					
						
							|  |  |  | 				/* open the file to read its size */ | 
					
						
							| 
									
										
										
										
											2008-01-21 22:10:20 +00:00
										 |  |  | 				size = BLI_filepathsize(path); | 
					
						
							|  |  |  | 				if ((size > 0) && (size > *filesize)) { /* find the biggest file */ | 
					
						
							|  |  |  | 					*filesize = size; | 
					
						
							|  |  |  | 					BLI_strncpy(filename_new, path, FILE_MAX); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else if (S_ISDIR(status.st_mode)) { /* is subdir */ | 
					
						
							|  |  |  | 			if (*recur_depth <= MAX_RECUR) { | 
					
						
							|  |  |  | 				(*recur_depth)++; | 
					
						
							|  |  |  | 				findFileRecursive(filename_new, path, filename, filesize, recur_depth); | 
					
						
							|  |  |  | 				(*recur_depth)--; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	closedir(dir); | 
					
						
							|  |  |  | 	return 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* high level function - call from fileselector */ | 
					
						
							|  |  |  | void findMissingFiles(char *str) { | 
					
						
							|  |  |  | 	struct BPathIterator bpi; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* be sure there is low chance of the path being too short */ | 
					
						
							|  |  |  | 	char filepath_expanded[FILE_MAXDIR*2];  | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	char filepath[FILE_MAX], *libpath; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	int filesize, recur_depth; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2008-04-27 20:43:25 +00:00
										 |  |  | 	char dirname[FILE_MAX], filename[FILE_MAX], filename_new[FILE_MAX]; | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
											  
											
												
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
  later added in trunk also, but reverted partially, specifically revision
  16683. I have left out this reversion in the 2.5 branch since I think it is
  needed there.
  http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
  for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
  -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
  differently. Since this is changed so much, and I don't think those fixes
  would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
  initialized when running with -P. The code that initializes the screen there
  I had to disable, that can't work in 2.5 anymore but left it commented as a
  reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
  still use changes that were done in trunk.
											
										 
											2008-11-12 21:16:53 +00:00
										 |  |  | 	//XXX waitcursor( 1 );
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2008-04-26 13:08:57 +00:00
										 |  |  | 	BLI_split_dirfile_basic(str, dirname, NULL); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	BLI_bpathIterator_init(&bpi); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	while (!BLI_bpathIterator_isDone(&bpi)) { | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		BLI_bpathIterator_getPath(&bpi, filepath); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 		libpath = BLI_bpathIterator_getLib(&bpi); | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		/* Check if esc was pressed because searching files can be slow */ | 
					
						
							| 
									
										
											  
											
												
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
  later added in trunk also, but reverted partially, specifically revision
  16683. I have left out this reversion in the 2.5 branch since I think it is
  needed there.
  http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
  for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
  -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
  differently. Since this is changed so much, and I don't think those fixes
  would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
  initialized when running with -P. The code that initializes the screen there
  I had to disable, that can't work in 2.5 anymore but left it commented as a
  reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
  still use changes that were done in trunk.
											
										 
											2008-11-12 21:16:53 +00:00
										 |  |  | 		/*XXX if (blender_test_break()) {
 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
											  
											
												
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
  later added in trunk also, but reverted partially, specifically revision
  16683. I have left out this reversion in the 2.5 branch since I think it is
  needed there.
  http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
  for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
  -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
  differently. Since this is changed so much, and I don't think those fixes
  would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
  initialized when running with -P. The code that initializes the screen there
  I had to disable, that can't work in 2.5 anymore but left it commented as a
  reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
  still use changes that were done in trunk.
											
										 
											2008-11-12 21:16:53 +00:00
										 |  |  | 		}*/ | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 		if (libpath==NULL) { | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 			BLI_bpathIterator_getPathExpanded( &bpi, filepath_expanded ); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 			if (!BLI_exists(filepath_expanded)) { | 
					
						
							|  |  |  | 				/* can the dir be opened? */ | 
					
						
							|  |  |  | 				filesize = -1; | 
					
						
							|  |  |  | 				recur_depth = 0; | 
					
						
							| 
									
										
										
										
											2008-04-26 13:08:57 +00:00
										 |  |  | 				BLI_split_dirfile_basic(filepath, NULL, filename); /* the file to find */ | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 				 | 
					
						
							|  |  |  | 				findFileRecursive(filename_new, dirname, filename, &filesize, &recur_depth); | 
					
						
							|  |  |  | 				if (filesize == -1) { /* could not open dir */ | 
					
						
							|  |  |  | 					printf("Could not open dir \"%s\"\n", dirname); | 
					
						
							|  |  |  | 					return; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				if (filesize > 0) { | 
					
						
							|  |  |  | 					 | 
					
						
							|  |  |  | 					if (BLI_bpathIterator_getPathMaxLen( &bpi ) < strlen(filename_new)) {  | 
					
						
							|  |  |  | 						printf("cannot set path \"%s\" too long!", filename_new); | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						/* copy the found path into the old one */ | 
					
						
							|  |  |  | 						if (G.relbase_valid) | 
					
						
							|  |  |  | 							BLI_makestringcode(G.sce, filename_new); | 
					
						
							|  |  |  | 						 | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 						BLI_bpathIterator_setPath( &bpi, filename_new ); | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		BLI_bpathIterator_step(&bpi); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-04-25 16:09:16 +00:00
										 |  |  | 	BLI_bpathIterator_free(&bpi); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
											  
											
												
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
  later added in trunk also, but reverted partially, specifically revision
  16683. I have left out this reversion in the 2.5 branch since I think it is
  needed there.
  http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
  for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
  -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
  differently. Since this is changed so much, and I don't think those fixes
  would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
  initialized when running with -P. The code that initializes the screen there
  I had to disable, that can't work in 2.5 anymore but left it commented as a
  reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
  still use changes that were done in trunk.
											
										 
											2008-11-12 21:16:53 +00:00
										 |  |  | 	//XXX waitcursor( 0 );
 | 
					
						
							| 
									
										
										
										
											2007-12-20 10:27:13 +00:00
										 |  |  | } |