[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28208] branches/render25/source/blender/ blenlib: Render Branch: three utility functions:

Brecht Van Lommel brecht at blender.org
Thu Apr 15 17:36:51 CEST 2010


Revision: 28208
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28208
Author:   blendix
Date:     2010-04-15 17:36:51 +0200 (Thu, 15 Apr 2010)

Log Message:
-----------
Render Branch: three utility functions:

* mul_v4_fl
* BLI_replace_extension: replace extension in a filename
* BLI_file_newer: test if one file is newer than the other

Modified Paths:
--------------
    branches/render25/source/blender/blenlib/BLI_math_vector.h
    branches/render25/source/blender/blenlib/BLI_path_util.h
    branches/render25/source/blender/blenlib/BLI_storage.h
    branches/render25/source/blender/blenlib/intern/math_vector_inline.c
    branches/render25/source/blender/blenlib/intern/path_util.c
    branches/render25/source/blender/blenlib/intern/storage.c

Modified: branches/render25/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_math_vector.h	2010-04-15 13:51:02 UTC (rev 28207)
+++ branches/render25/source/blender/blenlib/BLI_math_vector.h	2010-04-15 15:36:51 UTC (rev 28208)
@@ -71,6 +71,7 @@
 MINLINE void mul_v2_v2(float r[2], const float a[2]);
 MINLINE void mul_v3_v3(float r[3], const float a[3]);
 MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void mul_v4_fl(float r[4], float f);
 
 MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);

Modified: branches/render25/source/blender/blenlib/BLI_path_util.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_path_util.h	2010-04-15 13:51:02 UTC (rev 28207)
+++ branches/render25/source/blender/blenlib/BLI_path_util.h	2010-04-15 15:36:51 UTC (rev 28208)
@@ -33,11 +33,6 @@
 #ifndef BLI_UTIL_H
 #define BLI_UTIL_H
 
-/* XXX doesn't seem to be used, marded for removal
-#define mallocstructN(x,y,name) (x*)MEM_mallocN((y)* sizeof(x),name)
-#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
-*/
-
 struct ListBase;
 struct direntry;
 
@@ -61,6 +56,7 @@
 int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir);
 void BLI_getlastdir(const char* dir, char *last, int maxlen);
 int BLI_testextensie(const char *str, const char *ext);
+int BLI_replace_extension(char *path, int maxlen, const char *ext);
 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
 void BLI_newname(char * name, int add);
 int BLI_stringdec(char *string, char *head, char *start, unsigned short *numlen);

Modified: branches/render25/source/blender/blenlib/BLI_storage.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_storage.h	2010-04-15 13:51:02 UTC (rev 28207)
+++ branches/render25/source/blender/blenlib/BLI_storage.h	2010-04-15 15:36:51 UTC (rev 28208)
@@ -76,5 +76,8 @@
 	 */
 void BLI_free_file_lines(struct LinkNode *lines);
 
+	/* Compare which of two files was last modified */
+int		BLI_file_newer(const char *file1, const char *file2);
+
 #endif /* BLI_STORAGE_H */
 

Modified: branches/render25/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/math_vector_inline.c	2010-04-15 13:51:02 UTC (rev 28207)
+++ branches/render25/source/blender/blenlib/intern/math_vector_inline.c	2010-04-15 15:36:51 UTC (rev 28208)
@@ -188,6 +188,14 @@
 	r[2] *= a[2];
 }
 
+MINLINE void mul_v4_fl(float r[4], float f)
+{
+	r[0]*= f;
+	r[1]*= f;
+	r[2]*= f;
+	r[3]*= f;
+}
+
 MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
 {
 	r[0] += a[0]*f;

Modified: branches/render25/source/blender/blenlib/intern/path_util.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/path_util.c	2010-04-15 13:51:02 UTC (rev 28207)
+++ branches/render25/source/blender/blenlib/intern/path_util.c	2010-04-15 15:36:51 UTC (rev 28208)
@@ -1113,6 +1113,24 @@
 	return (retval);
 }
 
+int BLI_replace_extension(char *path, int maxlen, const char *ext)
+{
+	int a;
+
+	for(a=strlen(path)-1; a>=0; a--)
+		if(path[a] == '.' || path[a] == '/' || path[a] == '\\')
+			break;
+	
+	if(path[a] != '.')
+		a= strlen(path);
+
+	if(a + strlen(ext) >= maxlen)
+		return 0;
+
+	strcpy(path+a, ext);
+	return 1;
+}
+
 /*
  * This is a simple version of BLI_split_dirfile that has the following advantages...
  * 

Modified: branches/render25/source/blender/blenlib/intern/storage.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/storage.c	2010-04-15 13:51:02 UTC (rev 28207)
+++ branches/render25/source/blender/blenlib/intern/storage.c	2010-04-15 15:36:51 UTC (rev 28208)
@@ -500,3 +500,14 @@
 {
 	BLI_linklist_free(lines, (void(*)(void*)) MEM_freeN);
 }
+
+int BLI_file_newer(const char *file1, const char *file2)
+{
+	struct stat st1, st2;
+
+	if(stat(file1, &st1)) return 0;
+	if(stat(file2, &st2)) return 0;
+
+	return (st1.st_mtime > st2.st_mtime);
+}
+





More information about the Bf-blender-cvs mailing list