[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12955] trunk/blender: BLI_makestringcode dosnt need the first value to be a copy of G. sce since its a "const char"

Campbell Barton ideasman42 at gmail.com
Thu Dec 20 11:38:01 CET 2007


Revision: 12955
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12955
Author:   campbellbarton
Date:     2007-12-20 11:38:01 +0100 (Thu, 20 Dec 2007)

Log Message:
-----------
BLI_makestringcode dosnt need the first value to be a copy of G.sce since its a "const char"

Removed own script release/scripts/image_find_paths.py since last commit replaced its functionality.

Modified Paths:
--------------
    trunk/blender/source/blender/src/editseq.c

Removed Paths:
-------------
    trunk/blender/release/scripts/image_find_paths.py

Deleted: trunk/blender/release/scripts/image_find_paths.py
===================================================================
--- trunk/blender/release/scripts/image_find_paths.py	2007-12-20 10:27:13 UTC (rev 12954)
+++ trunk/blender/release/scripts/image_find_paths.py	2007-12-20 10:38:01 UTC (rev 12955)
@@ -1,167 +0,0 @@
-#!BPY
-
-"""
-Name: 'Fix Broken Paths'
-Blender: 242
-Group: 'Image'
-Tooltip: 'Search for new image paths to make relative links to'
-"""
-
-__author__ = "Campbell Barton AKA Ideasman"
-__url__ = ["blenderartist.org"]
-
-__bpydoc__ = """\
-Find image target paths
-
-This script searches for images whos
-file paths do not point to an existing image file,
-all image paths are made relative where possible.
-usefull when moving projects between computers, when absolute paths links are broken.
-"""
-
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# Script copyright (C) Campbell J Barton
-#
-# 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
-# of the License, or (at your option) any later version.
-#
-# 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.
-#
-# ***** END GPL LICENCE BLOCK *****
-# --------------------------------------------------------------------------
-
-
-from Blender import *
-
-try:
-	import os
-except:
-	Draw.PupMenu('You need a full python install to use this script')
-	os= None
-
-
-#==============================================#
-# Strips the slashes from the back of a string #
-#==============================================#
-def stripPath(path):
-	return path.split('/')[-1].split('\\')[-1]
-
-# finds the file starting at the root.
-def findImage(findRoot, imagePath):
-	newImageFile = None
-	
-	imageFile = imagePath.split('/')[-1].split('\\')[-1]
-	
-	# ROOT, DIRS, FILES
-	pathWalk = os.walk(findRoot)
-	pathList = [True]
-	
-	matchList = [] # Store a list of (match, size), choose the biggest.
-	while True:
-		try:
-			pathList  = pathWalk.next()
-		except:
-			break
-		
-		for file in pathList[2]:
-			# FOUND A MATCH
-			if file.lower() == imageFile.lower():
-				name = pathList[0] + sys.sep + file
-				try:
-					size = os.path.getsize(name)
-				except:
-					size = 0
-					
-				if size:
-					print '   found:', name 
-					matchList.append( (name, size) )
-		
-	if matchList == []:
-		print 'no match for:', imageFile
-		return None
-	else:
-		# Sort by file size
-		matchList.sort(lambda A, B: cmp(B[1], A[1]) )
-		
-		print 'using:', matchList[0][0]
-		# First item is the largest
-		return matchList[0][0] # 0 - first, 0 - pathname
-		
-
-# Makes the pathe relative to the blend file path.
-def makeRelative(path, blendBasePath):
-	if path.startswith(blendBasePath):
-		path = path.replace(blendBasePath, '//')
-		path = path.replace('//\\', '//')
-	return path
-
-def find_images(findRoot):
-	print findRoot
-	
-	# findRoot = Draw.PupStrInput ('find in: ', '', 100)
-	
-	if findRoot == '':
-		Draw.PupMenu('No Directory Selected')
-		return
-	
-	# Account for //
-	findRoot = sys.expandpath(findRoot)
-	
-	# Strip filename
-	while findRoot[-1] != '/' and findRoot[-1] != '\\':
-		findRoot = findRoot[:-1]
-	
-	
-	if not findRoot.endswith(sys.sep):
-		findRoot += sys.sep
-	
-	
-	if findRoot != '/' and not sys.exists(findRoot[:-1]):
-		Draw.PupMenu('Directory Dosent Exist')
-	
-	blendBasePath = sys.expandpath('//')
-	
-	
-	Window.WaitCursor(1)
-	# ============ DIR DONE\
-	images = Image.Get()
-	len_images = float(len(images))
-	for idx, i in enumerate(images):
-
-		progress = idx / len_images
-		Window.DrawProgressBar(progress, 'searching for images')
-		
-		# If files not there?
-		if not sys.exists(sys.expandpath(i.filename )):	
-			newImageFile = findImage(findRoot, i.filename)
-			if newImageFile != None:
-				newImageFile= makeRelative(newImageFile, blendBasePath)
-				print 'newpath relink:', newImageFile
-				i.filename = newImageFile
-				i.reload()
-		else:
-			# Exists
-			newImageFile= makeRelative(i.filename, blendBasePath)
-			if newImageFile!=i.filename:
-				print 'newpath relative:', newImageFile
-				i.filename = newImageFile
-			
-	
-	Window.RedrawAll()
-	Window.DrawProgressBar(1.0, '')
-	Window.WaitCursor(0)
-
-if __name__ == '__main__' and os:
-	Window.FileSelector(find_images, 'SEARCH ROOT DIR', sys.expandpath('//'))
-
-

Modified: trunk/blender/source/blender/src/editseq.c
===================================================================
--- trunk/blender/source/blender/src/editseq.c	2007-12-20 10:27:13 UTC (rev 12954)
+++ trunk/blender/source/blender/src/editseq.c	2007-12-20 10:38:01 UTC (rev 12955)
@@ -955,7 +955,7 @@
 	Strip *strip;
 	StripElem *se;
 	int totsel, a;
-	char name[160], rel[160];
+	char name[160];
 
 	/* are there selected files? */
 	totsel= 0;
@@ -987,8 +987,7 @@
 	
 	if(sfile->flag & FILE_STRINGCODE) {
 		strcpy(name, sfile->dir);
-		strcpy(rel, G.sce);
-		BLI_makestringcode(rel, name);
+		BLI_makestringcode(G.sce, name);
 	} else {
 		strcpy(name, sfile->dir);
 	}
@@ -1028,7 +1027,7 @@
 	Strip *strip;
 	StripElem *se;
 	int totframe;
-	char name[160], rel[160];
+	char name[160];
 	char str[FILE_MAXDIR+FILE_MAXFILE];
 
 	totframe= 0;
@@ -1060,8 +1059,7 @@
 	
 	if(sfile->flag & FILE_STRINGCODE) {
 		strcpy(name, sfile->dir);
-		strcpy(rel, G.sce);
-		BLI_makestringcode(rel, name);
+		BLI_makestringcode(G.sce, name);
 	} else {
 		strcpy(name, sfile->dir);
 	}
@@ -1123,7 +1121,7 @@
 	Strip *strip;
 	StripElem *se;
 	double totframe;
-	char name[160], rel[160];
+	char name[160];
 	char str[256];
 
 	totframe= 0.0;
@@ -1157,8 +1155,7 @@
 	
 	if(sfile->flag & FILE_STRINGCODE) {
 		strcpy(name, sfile->dir);
-		strcpy(rel, G.sce);
-		BLI_makestringcode(rel, name);
+		BLI_makestringcode(G.sce, name);
 	} else {
 		strcpy(name, sfile->dir);
 	}
@@ -1187,7 +1184,7 @@
 	Strip *strip;
 	StripElem *se;
 	int totframe;
-	char name[160], rel[160];
+	char name[160];
 	char str[FILE_MAXDIR+FILE_MAXFILE];
 
 	totframe= 0;
@@ -1218,8 +1215,7 @@
 	
 	if(sfile->flag & FILE_STRINGCODE) {
 		strcpy(name, sfile->dir);
-		strcpy(rel, G.sce);
-		BLI_makestringcode(rel, name);
+		BLI_makestringcode(G.sce, name);
 	} else {
 		strcpy(name, sfile->dir);
 	}





More information about the Bf-blender-cvs mailing list