diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-10-30 06:03:40 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-10-30 06:03:40 +0400 |
commit | 65668dc5eb45ae6e90675aecc9dd6132dc7f0b5e (patch) | |
tree | 355f3b4dd6f28dc0debf249d1c85a6474784dcfe /source/blender/blenlib | |
parent | 16702c172939a399ddd0e61fc14a8b0944c4249b (diff) | |
parent | 15bd96efeb77cf33215613a53059f01db7242b31 (diff) |
Merged changes in the trunk up to revision 41368.
Conflicts resolved:
source/blender/blenkernel/intern/library.c
source/blender/blenlib/intern/bpath.c
source/blender/render/intern/source/convertblender.c
Diffstat (limited to 'source/blender/blenlib')
91 files changed, 457 insertions, 1028 deletions
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h index 4cdb35dd675..3b8b60be1b9 100644 --- a/source/blender/blenlib/BLI_args.h +++ b/source/blender/blenlib/BLI_args.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index 356709d5ccd..515c2444e80 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index cfe5d7f2084..89ba4b2675e 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -35,22 +34,23 @@ #ifndef BLI_BPATH_H #define BLI_BPATH_H -struct BPathIterator; -struct ReportList; +struct ID; +struct ListBase; struct Main; +struct ReportList; -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); -int BLI_bpathIterator_getType (struct BPathIterator *bpi); -unsigned int BLI_bpathIterator_getPathMaxLen (struct BPathIterator *bpi); -const char* BLI_bpathIterator_getBasePath (struct BPathIterator *bpi); -void BLI_bpathIterator_step (struct BPathIterator *bpi); -int BLI_bpathIterator_isDone (struct BPathIterator *bpi); -void BLI_bpathIterator_getPath (struct BPathIterator *bpi, char *path); -void BLI_bpathIterator_getPathExpanded (struct BPathIterator *bpi, char *path_expanded); -void BLI_bpathIterator_setPath (struct BPathIterator *bpi, const char *path); +/* Function that does something with an ID's file path. Should return 1 if the + path has changed, and in that case, should write the result to pathOut. */ +typedef int (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src); +/* Executes 'visit' for each path associated with 'id'. */ +void bpath_traverse_id(struct Main *bmain, struct ID *id, BPathVisitor visit_cb, const int flag, void *userdata); +void bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVisitor visit_cb, const int flag, void *userdata); +void bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata); +int bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src); + +#define BPATH_TRAVERSE_ABS (1<<0) /* convert paths to absolute */ +#define BPATH_TRAVERSE_SKIP_LIBRARY (1<<2) /* skip library paths */ +#define BPATH_TRAVERSE_SKIP_PACKED (1<<3) /* skip packed data */ /* high level funcs */ @@ -58,8 +58,6 @@ void BLI_bpathIterator_setPath (struct BPathIterator *bpi, const char *path) void checkMissingFiles(struct Main *bmain, struct ReportList *reports); void makeFilesRelative(struct Main *bmain, const char *basedir, struct ReportList *reports); void makeFilesAbsolute(struct Main *bmain, const char *basedir, struct ReportList *reports); -void findMissingFiles(struct Main *bmain, const char *str); - -#define BPATH_USE_PACKED 1 +void findMissingFiles(struct Main *bmain, const char *searchpath, struct ReportList *reports); #endif // BLI_BPATH_H diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index b490317fdac..5322ce04a2e 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_cpu.h b/source/blender/blenlib/BLI_cpu.h index addcf1273b3..de04a2a6cc6 100644 --- a/source/blender/blenlib/BLI_cpu.h +++ b/source/blender/blenlib/BLI_cpu.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h index 24c819ada55..cde2058b200 100644 --- a/source/blender/blenlib/BLI_dlrbTree.h +++ b/source/blender/blenlib/BLI_dlrbTree.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_dynlib.h b/source/blender/blenlib/BLI_dynlib.h index f269bedd639..d7c8706a7b8 100644 --- a/source/blender/blenlib/BLI_dynlib.h +++ b/source/blender/blenlib/BLI_dynlib.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h index 2cbc19f56f0..e27a315a023 100644 --- a/source/blender/blenlib/BLI_dynstr.h +++ b/source/blender/blenlib/BLI_dynstr.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h index 23ffdbae59b..283b52e06b9 100644 --- a/source/blender/blenlib/BLI_edgehash.h +++ b/source/blender/blenlib/BLI_edgehash.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h index 6e0dcb43889..ffe1d7e2b6e 100644 --- a/source/blender/blenlib/BLI_editVert.h +++ b/source/blender/blenlib/BLI_editVert.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index ebe231e2973..712429716a6 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h index 58dcf1a5441..443ba654cb6 100644 --- a/source/blender/blenlib/BLI_fileops_types.h +++ b/source/blender/blenlib/BLI_fileops_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index e4ef834822f..976519c281a 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h index 572c54b7b7e..425ecb79899 100644 --- a/source/blender/blenlib/BLI_gsqueue.h +++ b/source/blender/blenlib/BLI_gsqueue.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h index 3038d026df9..0124c997d91 100644 --- a/source/blender/blenlib/BLI_heap.h +++ b/source/blender/blenlib/BLI_heap.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_jitter.h b/source/blender/blenlib/BLI_jitter.h index e0fea9306ff..f432a51de9f 100644 --- a/source/blender/blenlib/BLI_jitter.h +++ b/source/blender/blenlib/BLI_jitter.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index d0943408dc5..4daa27a5c72 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h index c607dae386f..9ffc64e8812 100644 --- a/source/blender/blenlib/BLI_kdtree.h +++ b/source/blender/blenlib/BLI_kdtree.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h index 95850c44ea1..6886dff0da3 100644 --- a/source/blender/blenlib/BLI_linklist.h +++ b/source/blender/blenlib/BLI_linklist.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index 90556ea4b05..88ee79d7b97 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -25,7 +23,7 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** -*/ + */ #ifndef BLI_LISTBASE_H #define BLI_LISTBASE_H diff --git a/source/blender/blenlib/BLI_math.h b/source/blender/blenlib/BLI_math.h index 890a5ee4018..1fe700492be 100644 --- a/source/blender/blenlib/BLI_math.h +++ b/source/blender/blenlib/BLI_math.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index b5bab6f15be..204ec9b5159 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index a6a1238a064..0e33ee2be3f 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 506e271071c..713466f13f8 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h index 4309e6122df..83aeb6cb735 100644 --- a/source/blender/blenlib/BLI_math_inline.h +++ b/source/blender/blenlib/BLI_math_inline.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index d6a8f0fb925..008d2ad49ce 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index d7ca03243df..aef1c4bb46c 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index a807a395b78..e259071a27a 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -94,6 +92,8 @@ MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], floa MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]); MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f); +MINLINE void negate_v2(float r[2]); +MINLINE void negate_v2_v2(float r[2], const float a[2]); MINLINE void negate_v3(float r[3]); MINLINE void negate_v3_v3(float r[3], const float a[3]); MINLINE void negate_v4(float r[4]); diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index f6e919d8d65..ceb7b17f7ef 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -1,5 +1,4 @@ /* - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index 56df71b5582..2a81966986f 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -1,5 +1,4 @@ /* - * $Id$ * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h index bd88529b3dc..de2efb18216 100644 --- a/source/blender/blenlib/BLI_noise.h +++ b/source/blender/blenlib/BLI_noise.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -26,7 +24,7 @@ * * ***** END GPL LICENSE BLOCK ***** * -*/ + */ #ifndef BLI_NOISE_H #define BLI_NOISE_H diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 82794e08fa0..dd4bc868ab0 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index 89dcf9bf02d..c25243a9d36 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index eb6e71acded..7ce0031bcf9 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 021ab636d5b..25b7f193105 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -26,7 +24,7 @@ * * ***** END GPL LICENSE BLOCK ***** * -*/ + */ #ifndef BLI_RECT_H #define BLI_RECT_H diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index 3cc6ebcc7da..8af98b2d348 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 958f240e3a8..46389a9259e 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -134,7 +132,6 @@ int BLI_strcasecmp(const char *s1, const char *s2); int BLI_strncasecmp(const char *s1, const char *s2, size_t len); int BLI_natstrcmp(const char *s1, const char *s2); size_t BLI_strnlen(const char *str, size_t maxlen); - void BLI_timestr(double _time, char *str); /* time var is global */ void BLI_ascii_strtolower(char *str, int len); diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index bcb641d79d8..69b5612b118 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 5bf5423d312..00d8131d813 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -1,6 +1,5 @@ /* * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index c1eed40de74..a6b4f2c9b92 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -25,7 +23,7 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** -*/ + */ #ifndef BLI_UTILDEFINES_H #define BLI_UTILDEFINES_H diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h index 54e2090aa50..d4a34a9e290 100644 --- a/source/blender/blenlib/BLI_uvproject.h +++ b/source/blender/blenlib/BLI_uvproject.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index 7a03c1c37fa..ef6608e2c25 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index e0c819c2dba..0eb2f86b668 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 3aab617d532..405b7fad1ee 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -1,4 +1,3 @@ -# $Id$ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h index 36ea43bef2d..0a777a80b2a 100644 --- a/source/blender/blenlib/PIL_time.h +++ b/source/blender/blenlib/PIL_time.h @@ -1,6 +1,5 @@ /* * Platform independent time functions. - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c index 00903aa42cd..04d5d57c239 100644 --- a/source/blender/blenlib/intern/BLI_args.c +++ b/source/blender/blenlib/intern/BLI_args.c @@ -1,7 +1,6 @@ /* * A general argument parsing module * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c index e877e985d94..5cdadce7c01 100644 --- a/source/blender/blenlib/intern/BLI_dynstr.c +++ b/source/blender/blenlib/intern/BLI_dynstr.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index e34abaf15f9..080dc77fc06 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index a0b71dbde0e..52365371421 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 8e68d42456f..d1734151b4a 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index c885e8c8a9c..3543b847f19 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index 2de1689713e..a9b8cbb6467 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c index 6ce5621e30d..308fc6a61e6 100644 --- a/source/blender/blenlib/intern/BLI_memarena.c +++ b/source/blender/blenlib/intern/BLI_memarena.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 84e6151abaa..b4dc5b73a65 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 590425a8f06..72743e38d4c 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 8c7e097d239..30bf69ba3b4 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 624b726e27e..1d7dfbde934 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -21,7 +20,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): Campbell barton + * Contributor(s): Campbell barton, Alex Fraser * * ***** END GPL LICENSE BLOCK ***** */ @@ -30,6 +29,12 @@ * \ingroup bli */ +/* TODO, + * currently there are some cases we dont support. + * - passing output paths to the visitor?, like render out. + * - passing sequence strips with many images. + * - passing directory paths - visitors dont know which path is a dir or a file. + * */ #include <sys/stat.h> @@ -47,972 +52,545 @@ #include "MEM_guardedalloc.h" -#include "DNA_mesh_types.h" -#include "DNA_scene_types.h" /* to get the current frame */ +#include "DNA_brush_types.h" #include "DNA_image_types.h" -#include "DNA_texture_types.h" -#include "DNA_text_types.h" -#include "DNA_sound_types.h" +#include "DNA_mesh_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_fluidsim.h" +#include "DNA_object_force.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" #include "DNA_sequence_types.h" +#include "DNA_sound_types.h" +#include "DNA_text_types.h" +#include "DNA_texture_types.h" #include "DNA_vfont_types.h" -#include "DNA_windowmanager_types.h" +#include "DNA_scene_types.h" +#include "DNA_smoke_types.h" #include "DNA_freestyle_types.h" #include "BLI_blenlib.h" #include "BLI_bpath.h" #include "BLI_utildefines.h" -#include "BKE_global.h" -#include "BKE_image.h" /* so we can check the image's type */ -#include "BKE_sequencer.h" +#include "BKE_library.h" #include "BKE_main.h" -#include "BKE_utildefines.h" #include "BKE_report.h" +#include "BKE_sequencer.h" +#include "BKE_utildefines.h" +#include "BKE_image.h" /* so we can check the image's type */ -typedef struct BPathIteratorSeqData -{ - int totseq; - int seq; - struct Sequence **seqar; /* Sequence */ - struct Scene *scene; /* Current scene */ -} BPathIteratorSeqData; - -typedef struct BPathIteratorFrsModuleData { - struct Scene *scene; /* Current scene */ - struct SceneRenderLayer *layer; /* Scene render layer */ - struct FreestyleModuleConfig *module; -} BPathIteratorFrsModuleData; - -typedef struct BPathIterator +static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src) { - char* _path; /* never access directly, use BLI_bpathIterator_getPath */ - const char* _lib; - const char* _name; - void* data; - int len; - int type; - int flag; /* iterator options */ - - void (*setpath_callback)(struct BPathIterator *, const char *); - void (*getpath_callback)(struct BPathIterator *, char *); - - const char* base_path; /* base path, the directory the blend file is in - normally bmain->name */ - - Main *bmain; - - /* only for seq data */ - struct BPathIteratorSeqData seqdata; - /* only for Freestyle module data */ - struct BPathIteratorFrsModuleData frsmoduledata; -} BPathIterator; - -#define FILE_MAX 240 - - -/* TODO - BPATH_PLUGIN, BPATH_SEQ */ -enum BPathTypes { - BPATH_IMAGE= 0, - BPATH_TEXTURE, - BPATH_TEXT, - BPATH_SOUND, - BPATH_FONT, - BPATH_LIB, - BPATH_SEQ, - BPATH_CDATA, - BPATH_FRS_MODULE, - - BPATH_DONE -}; - -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"); - *bpi_pt= bpi; - - bpi->type= BPATH_IMAGE; - bpi->data= NULL; - - bpi->getpath_callback= NULL; - bpi->setpath_callback= NULL; - - /* Sequencer specific */ - bpi->seqdata.totseq= 0; - bpi->seqdata.seq= 0; - bpi->seqdata.seqar= NULL; - bpi->seqdata.scene= NULL; - - bpi->flag= flag; - - /* Freestyle module specific */ - bpi->frsmoduledata.scene= NULL; - bpi->frsmoduledata.layer= NULL; - bpi->frsmoduledata.module= NULL; - - bpi->base_path= basedir; /* normally bmain->name */ - bpi->bmain= bmain; - - BLI_bpathIterator_step(bpi); -} + ReportList *reports= (ReportList *)userdata; -#if 0 -static void BLI_bpathIterator_alloc(struct BPathIterator **bpi) -{ - *bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc"); + if (!BLI_exists(path_src)) { + BKE_reportf(reports, RPT_WARNING, "Path Not Found \"%s\"", path_src); + } + + return FALSE; } -#endif -void BLI_bpathIterator_free(struct BPathIterator *bpi) +/* high level function */ +void checkMissingFiles(Main *bmain, ReportList *reports) { - if (bpi->seqdata.seqar) - MEM_freeN((void *)bpi->seqdata.seqar); - bpi->seqdata.seqar= NULL; - bpi->seqdata.scene= NULL; - bpi->frsmoduledata.scene= NULL; - bpi->frsmoduledata.layer= NULL; - bpi->frsmoduledata.module= NULL; - - MEM_freeN(bpi); + bpath_traverse_main(bmain, checkMissingFiles_visit_cb, BPATH_TRAVERSE_ABS, reports); } -void BLI_bpathIterator_getPath(struct BPathIterator *bpi, char *path) +typedef struct BPathRemap_Data { - if (bpi->getpath_callback) { - bpi->getpath_callback( bpi, path ); - } - else { - strcpy(path, bpi->_path); /* warning, we assume 'path' are long enough */ - } -} + const char *basedir; + ReportList *reports; -void BLI_bpathIterator_setPath(struct BPathIterator *bpi, const char *path) + int count_tot; + int count_changed; + int count_failed; +} BPathRemap_Data; + +static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char *path_src) { - if (bpi->setpath_callback) { - bpi->setpath_callback( bpi, path ); + BPathRemap_Data *data= (BPathRemap_Data *)userdata; + + data->count_tot++; + + if(strncmp(path_src, "//", 2)==0) { + return FALSE; /* already relative */ } else { - strcpy(bpi->_path, path); /* warning, we assume 'path' are long enough */ + strcpy(path_dst, path_src); + BLI_path_rel(path_dst, data->basedir); + if (strncmp(path_dst, "//", 2)==0) { + data->count_changed++; + } + else { + BKE_reportf(data->reports, RPT_WARNING, "Path cant be made relative \"%s\"", path_src); + data->count_failed++; + } + return TRUE; } } -void BLI_bpathIterator_getPathExpanded(struct BPathIterator *bpi, char *path_expanded) -{ - const char *libpath; - - BLI_bpathIterator_getPath(bpi, path_expanded); - libpath= BLI_bpathIterator_getLib(bpi); - - if (libpath) { /* check the files location relative to its library path */ - BLI_path_abs(path_expanded, libpath); - } - else { /* local data, use the blend files path */ - BLI_path_abs(path_expanded, bpi->base_path); - } - BLI_cleanup_file(NULL, path_expanded); -} -const char* BLI_bpathIterator_getLib(struct BPathIterator *bpi) -{ - return bpi->_lib; -} -const char* BLI_bpathIterator_getName(struct BPathIterator *bpi) -{ - return bpi->_name; -} -int BLI_bpathIterator_getType(struct BPathIterator *bpi) -{ - return bpi->type; -} -unsigned int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi) -{ - return bpi->len; -} -const char* BLI_bpathIterator_getBasePath(struct BPathIterator *bpi) +void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) { - return bpi->base_path; -} + BPathRemap_Data data= {0}; -/* 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, const int step_next, const int flag) -{ - if (ima==NULL) - return NULL; - - if (step_next) - ima= ima->id.next; - - while (ima) { - 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; -} + if(basedir[0] == '\0') { + printf("%s: basedir='', this is a bug\n", __func__); + return; + } -static struct Tex *tex_stepdata__internal(struct Tex *tex, const int step_next, const int UNUSED(flag)) -{ - if (tex==NULL) - return NULL; - - if (step_next) - tex= tex->id.next; - - while (tex) { - if (tex->type == TEX_VOXELDATA && TEX_VD_IS_SOURCE_PATH(tex->vd->file_format)) - break; - /* image is not a image with a path, skip it */ - tex= tex->id.next; - } - return tex; -} + data.basedir= basedir; + data.reports= reports; -static struct Text *text_stepdata__internal(struct Text *text, const int step_next, const int UNUSED(flag)) -{ - if (text==NULL) - return NULL; - - if (step_next) - text= text->id.next; - - while (text) { - if (text->name) - break; - /* image is not a image with a path, skip it */ - text= text->id.next; - } - return text; -} + bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data); -static struct VFont *vf_stepdata__internal(struct VFont *vf, const int step_next, const int flag) -{ - if (vf==NULL) - return NULL; - - if (step_next) - vf= vf->id.next; - - while (vf) { - if (strcmp(vf->name, FO_BUILTIN_NAME)!=0) { - if(vf->packedfile==NULL || (flag & BPATH_USE_PACKED)) { - break; - } - } - - /* font with no path, skip it */ - vf= vf->id.next; - } - return vf; + BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO, + "Total files %d|Changed %d|Failed %d", + data.count_tot, data.count_changed, data.count_failed); } -static struct bSound *snd_stepdata__internal(struct bSound *snd, int step_next, const int flag) +static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char *path_src) { - if (snd==NULL) - return NULL; - - if (step_next) - snd= snd->id.next; - - while (snd) { - if(snd->packedfile==NULL || (flag & BPATH_USE_PACKED)) { - break; - } + BPathRemap_Data *data= (BPathRemap_Data *)userdata; - /* font with no path, skip it */ - snd= snd->id.next; - } - return snd; -} + data->count_tot++; -static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int step_next) -{ - Editing *ed; - Sequence *seq; - - /* Initializing */ - if (bpi->seqdata.scene==NULL) { - bpi->seqdata.scene= bpi->bmain->scene.first; - } - - if (step_next) { - bpi->seqdata.seq++; + if(strncmp(path_src, "//", 2)!=0) { + return FALSE; /* already absolute */ } - - while (bpi->seqdata.scene) { - ed= seq_give_editing(bpi->seqdata.scene, 0); - if (ed) { - if (bpi->seqdata.seqar == NULL) { - /* allocate the sequencer array */ - seq_array(ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0); - bpi->seqdata.seq= 0; - } - - if (bpi->seqdata.seq >= bpi->seqdata.totseq) { - seq= NULL; - } - else { - seq= bpi->seqdata.seqar[bpi->seqdata.seq]; - while (!SEQ_HAS_PATH(seq) && seq->plugin==NULL) { - bpi->seqdata.seq++; - if (bpi->seqdata.seq >= bpi->seqdata.totseq) { - seq= NULL; - break; - } - seq= bpi->seqdata.seqar[bpi->seqdata.seq]; - } - } - if (seq) { - return seq; - } - else { - /* keep looking through the next scene, reallocate seq array */ - if (bpi->seqdata.seqar) { - MEM_freeN((void *)bpi->seqdata.seqar); - bpi->seqdata.seqar= NULL; - } - bpi->seqdata.scene= bpi->seqdata.scene->id.next; - } + else { + strcpy(path_dst, path_src); + BLI_path_abs(path_dst, data->basedir); + if (strncmp(path_dst, "//", 2)!=0) { + data->count_changed++; } else { - /* no seq data in this scene, next */ - bpi->seqdata.scene= bpi->seqdata.scene->id.next; + BKE_reportf(data->reports, RPT_WARNING, "Path cant be made absolute \"%s\"", path_src); + data->count_failed++; } + return TRUE; } - - return NULL; } -static struct FreestyleModuleConfig *frs_module_stepdata__internal(struct BPathIterator *bpi, int step_next) +/* similar to makeFilesRelative - keep in sync! */ +void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) { - struct FreestyleModuleConfig *module; + BPathRemap_Data data= {0}; - /* Initializing */ - if (bpi->frsmoduledata.scene==NULL) { - bpi->frsmoduledata.scene= G.main->scene.first; - bpi->frsmoduledata.layer= (bpi->frsmoduledata.scene) ? bpi->frsmoduledata.scene->r.layers.first : NULL; - bpi->frsmoduledata.module= (bpi->frsmoduledata.layer) ? bpi->frsmoduledata.layer->freestyleConfig.modules.first : NULL; + if(basedir[0] == '\0') { + printf("%s: basedir='', this is a bug\n", __func__); + return; } - while (bpi->frsmoduledata.scene) { - while (bpi->frsmoduledata.layer) { - while (bpi->frsmoduledata.module) { - module= bpi->frsmoduledata.module; - bpi->frsmoduledata.module= module->next; - return module; - } - bpi->frsmoduledata.layer= bpi->frsmoduledata.layer->next; - bpi->frsmoduledata.module= (bpi->frsmoduledata.layer) ? bpi->frsmoduledata.layer->freestyleConfig.modules.first : NULL; - } - bpi->frsmoduledata.scene= bpi->frsmoduledata.scene->id.next; - bpi->frsmoduledata.layer= (bpi->frsmoduledata.scene) ? bpi->frsmoduledata.scene->r.layers.first : NULL; - bpi->frsmoduledata.module= (bpi->frsmoduledata.layer) ? bpi->frsmoduledata.layer->freestyleConfig.modules.first : NULL; - } + data.basedir= basedir; + data.reports= reports; - return NULL; + bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data); + + BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO, + "Total files %d|Changed %d|Failed %d", + data.count_tot, data.count_changed, data.count_failed); } -static void seq_getpath(struct BPathIterator *bpi, char *path) + +/* 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) { - Sequence *seq= (Sequence *)bpi->data; - - - path[0]= '\0'; /* incase we cant get the path */ - if (seq==NULL) return; - if (SEQ_HAS_PATH(seq)) { - if (ELEM3(seq->type, SEQ_IMAGE, SEQ_MOVIE, SEQ_SOUND)) { - 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); - } + /* file searching stuff */ + DIR *dir; + struct dirent *de; + struct stat status; + char path[FILE_MAX]; + int size; + + dir= opendir(dirname); + + if (dir==NULL) + return 0; + + if (*filesize == -1) + *filesize= 0; /* dir opened fine */ + + while ((de= readdir(dir)) != NULL) { + + if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) + continue; + + BLI_join_dirfile(path, sizeof(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 */ + size= status.st_size; + if ((size > 0) && (size > *filesize)) { /* find the biggest file */ + *filesize= size; + BLI_strncpy(filename_new, path, FILE_MAX); + } + } } - else { - /* simple case */ - BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); + 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)--; + } } } - else if (seq->plugin) { - BLI_strncpy(seq->plugin->name, path, sizeof(seq->plugin->name)); - } + closedir(dir); + return 1; } -static void seq_setpath(struct BPathIterator *bpi, const char *path) +typedef struct BPathFind_Data { - Sequence *seq= (Sequence *)bpi->data; - if (seq==NULL) return; - - if (SEQ_HAS_PATH(seq)) { - if (ELEM3(seq->type, SEQ_IMAGE, SEQ_MOVIE, SEQ_SOUND)) { - BLI_split_dirfile(path, seq->strip->dir, seq->strip->stripdata->name, sizeof(seq->strip->dir), sizeof(seq->strip->stripdata->name)); - } - else { - /* simple case */ - BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); - } + const char *basedir; + char searchdir[FILE_MAX]; + ReportList *reports; +} BPathFind_Data; + +static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char *path_src) +{ + BPathFind_Data *data= (BPathFind_Data *)userdata; + char filename_new[FILE_MAX]; + + int filesize= -1; + int recur_depth= 0; + + findFileRecursive(filename_new, + data->searchdir, BLI_path_basename((char *)path_src), + &filesize, &recur_depth); + + if (filesize == -1) { /* could not open dir */ + BKE_reportf(data->reports, RPT_WARNING, + "Could not find \"%s\" in \"%s\"", + BLI_path_basename((char *)path_src), data->searchdir); + return FALSE; } - else if (seq->plugin) { - BLI_strncpy(seq->plugin->name, path, sizeof(seq->plugin->name)); + else { + strcpy(path_dst, filename_new); + return TRUE; } } -static void text_getpath(struct BPathIterator *bpi, char *path) +void findMissingFiles(Main *bmain, const char *searchpath, ReportList *reports) { - Text *text= (Text *)bpi->data; - path[0]= '\0'; /* incase we cant get the path */ - if(text->name) { - strcpy(path, text->name); - } + struct BPathFind_Data data= {0}; + + data.reports= reports; + BLI_split_dir_part(searchpath, data.searchdir, sizeof(data.searchdir)); + + bpath_traverse_main(bmain, findMissingFiles_visit_cb, 0, (void *)&data); } -static void text_setpath(struct BPathIterator *bpi, const char *path) +/* Run a visitor on a string, replacing the contents of the string as needed. */ +static int rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *absbase, void *userdata) { - Text *text= (Text *)bpi->data; - if (text==NULL) return; + char path_src_buf[FILE_MAX]; + const char *path_src; + char path_dst[FILE_MAX]; - if(text->name) { - MEM_freeN(text->name); + if (absbase) { + BLI_strncpy(path_src_buf, path, sizeof(path_src_buf)); + BLI_path_abs(path_src_buf, absbase); + path_src= path_src_buf; + } + else { + path_src= path; } - text->name= BLI_strdup(path); + if (visit_cb(userdata, path_dst, path_src)) { + BLI_strncpy(path, path_dst, FILE_MAX); + return TRUE; + } + else { + return FALSE; + } } -static struct Mesh *cdata_stepdata__internal(struct Mesh *me, int step_next) +static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR], char path_file[FILE_MAXFILE], BPathVisitor visit_cb, const char *absbase, void *userdata) { - if (me==NULL) - return NULL; - - if (step_next) - me= me->id.next; - - while (me) { - if (me->fdata.external) { - break; - } - - me= me->id.next; - } - return me; + char path_src[FILE_MAX]; + char path_dst[FILE_MAX]; + + BLI_join_dirfile(path_src, sizeof(path_src), path_dir, path_file); + + if (absbase) { + BLI_path_abs(path_src, absbase); + } + + if (visit_cb(userdata, path_dst, (const char *)path_src)) { + BLI_split_dirfile(path_dst, path_dir, path_file, FILE_MAXDIR, FILE_MAXFILE); + return TRUE; + } + else { + return FALSE; + } } -static void bpi_type_step__internal(struct BPathIterator *bpi) +static int rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *absbase, void *userdata) { - 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; - case BPATH_TEXT: /* path is malloc'd */ - bpi->getpath_callback= text_getpath; - bpi->setpath_callback= text_setpath; - break; - default: - bpi->getpath_callback= NULL; - bpi->setpath_callback= NULL; - break; + char path_src_buf[FILE_MAX]; + const char *path_src; + char path_dst[FILE_MAX]; + + if (absbase) { + BLI_strncpy(path_src_buf, *path, sizeof(path_src_buf)); + BLI_path_abs(path_src_buf, absbase); + path_src= path_src_buf; + } + else { + path_src= *path; + } + + if (visit_cb(userdata, path_dst, path_src)) { + MEM_freeN((*path)); + (*path)= BLI_strdup(path_dst); + return TRUE; + } + else { + return FALSE; } } -void BLI_bpathIterator_step(struct BPathIterator *bpi) +/* Run visitor function 'visit' on all paths contained in 'id'. */ +void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data) { - while (bpi->type != BPATH_DONE) { - - 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, 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 */ - Image *ima= (Image *)bpi->data; - - bpi->_lib= ima->id.lib ? ima->id.lib->filepath : 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; + Image *ima; + const char *absbase= (flag & BPATH_TRAVERSE_ABS) ? (id->lib ? id->lib->filepath : bmain->name) : NULL; + + if ((flag & BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) { + return; + } + switch(GS(id->name)) { + case ID_IM: + ima= (Image *)id; + if (ima->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) { + if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data); } - else { - bpi_type_step__internal(bpi); + } + break; + case ID_BR: + { + Brush *brush= (Brush *)id; + if (brush->icon_filepath[0]) { + rewrite_path_fixed(brush->icon_filepath, visit_cb, absbase, bpath_user_data); } } + break; + case ID_OB: - 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, bpi->flag); /* must skip images that have no path */ - else bpi->data= tex_stepdata__internal(bpi->bmain->tex.first, 0, bpi->flag); +#define BPATH_TRAVERSE_POINTCACHE(ptcaches) \ + { \ + PointCache *cache; \ + for(cache= (ptcaches).first; cache; cache= cache->next) { \ + if(cache->flag & PTCACHE_DISK_CACHE) { \ + rewrite_path_fixed(cache->path, \ + visit_cb, \ + absbase, \ + bpath_user_data); \ + } \ + } \ + } \ - if (bpi->data) { - /* get the path info from this datatype */ - Tex *tex= (Tex *)bpi->data; - if(tex->type == TEX_VOXELDATA) { - bpi->_lib= tex->id.lib ? tex->id.lib->filepath : NULL; - bpi->_path= tex->vd->source_path; - bpi->_name= tex->id.name+2; - bpi->len= sizeof(tex->vd->source_path); - } - else { - assert(!"Texture has no path, incorrect step 'tex_stepdata__internal'"); - } + { + Object *ob= (Object *)id; + ModifierData *md; + ParticleSystem *psys; - /* we are done, advancing to the next item, this type worked fine */ - break; + /* do via modifiers instead */ +#if 0 + if (ob->fluidsimSettings) { + rewrite_path_fixed(ob->fluidsimSettings->surfdataPath, visit_cb, absbase, bpath_user_data); } - else { - bpi_type_step__internal(bpi); - } - } - - 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, 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 */ - Text *text= (Text *)bpi->data; - - bpi->_lib= text->id.lib ? text->id.lib->filepath : NULL; - bpi->_path= NULL; /* bpi->path= text->name; */ /* get/set functions override. */ - bpi->_name= text->id.name+2; - bpi->len= FILE_MAX; /* malloc'd but limit anyway since large paths may mess up other areas */ +#endif - /* we are done, advancing to the next item, this type worked fine */ - break; + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Fluidsim) { + FluidsimModifierData *fluidmd= (FluidsimModifierData *)md; + if (fluidmd->fss) { + rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data); + } + } + else if (md->type == eModifierType_Smoke) { + SmokeModifierData *smd= (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { + BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]); + } + } + else if (md->type==eModifierType_Cloth) { + ClothModifierData *clmd= (ClothModifierData*) md; + BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches); + } + } + if (ob->soft) { + BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches); } - else { - bpi_type_step__internal(bpi); + + for (psys= ob->particlesystem.first; psys; psys= psys->next) { + BPATH_TRAVERSE_POINTCACHE(psys->ptcaches); } } - else if ((bpi->type) == BPATH_SOUND) { - 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 */ - bSound *snd= (bSound *)bpi->data; - bpi->_lib= snd->id.lib ? snd->id.lib->filepath : NULL; - bpi->_path= snd->name; - bpi->_name= snd->id.name+2; - bpi->len= sizeof(snd->name); +#undef BPATH_TRAVERSE_POINTCACHE - /* we are done, advancing to the next item, this type worked fine */ - break; - } - else { - bpi_type_step__internal(bpi); + break; + case ID_SO: + { + bSound *sound= (bSound *)id; + if (sound->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) { + rewrite_path_fixed(sound->name, visit_cb, absbase, bpath_user_data); } } - else if ((bpi->type) == BPATH_FONT) { - - 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 */ - VFont *vf= (VFont *)bpi->data; - - bpi->_lib= vf->id.lib ? vf->id.lib->filepath : 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 { - bpi_type_step__internal(bpi); - } - + break; + case ID_TXT: + if (((Text*)id)->name) { + rewrite_path_alloc(&((Text *)id)->name, visit_cb, absbase, bpath_user_data); } - else if ((bpi->type) == BPATH_LIB) { - if (bpi->data) bpi->data= ((ID *)bpi->data)->next; - else bpi->data= bpi->bmain->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 { - bpi_type_step__internal(bpi); + break; + case ID_VF: + { + VFont *vf= (VFont *)id; + if (vf->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) { + if (strcmp(vf->name, FO_BUILTIN_NAME) != 0) { + rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data); + } } } - 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= seq->plugin ? sizeof(seq->plugin->name) : sizeof(seq->strip->dir) + sizeof(seq->strip->stripdata->name); - break; + break; + case ID_TE: + { + Tex *tex = (Tex *)id; + if (tex->plugin) { + /* FIXME: rewrite_path assumes path length of FILE_MAX, but + tex->plugin->name is 160. ... is this field even a path? */ + //rewrite_path(tex->plugin->name, visit_cb, bpath_user_data); } - else { - bpi_type_step__internal(bpi); + if (tex->type == TEX_VOXELDATA && TEX_VD_IS_SOURCE_PATH(tex->vd->file_format)) { + rewrite_path_fixed(tex->vd->source_path, visit_cb, absbase, bpath_user_data); } } - else if ((bpi->type) == BPATH_CDATA) { - if (bpi->data) bpi->data= cdata_stepdata__internal( bpi->data, 1 ); - else bpi->data= cdata_stepdata__internal( bpi->bmain->mesh.first, 0 ); - - if (bpi->data) { - Mesh *me= (Mesh *)bpi->data; - bpi->_lib= me->id.lib ? me->id.lib->filepath : NULL; - bpi->_path= me->fdata.external->filename; - bpi->_name= me->id.name+2; - bpi->len= sizeof(me->fdata.external->filename); - break; - } - else { - bpi_type_step__internal(bpi); + break; + + case ID_SCE: + { + Scene *scene= (Scene *)id; + SceneRenderLayer *srl= scene->r.layers.first; + if (scene->ed) { + Sequence *seq; + + SEQ_BEGIN(scene->ed, seq) { + if (SEQ_HAS_PATH(seq)) { + if (ELEM(seq->type, SEQ_MOVIE, SEQ_SOUND)) { + rewrite_path_fixed_dirfile(seq->strip->dir, seq->strip->stripdata->name, visit_cb, absbase, bpath_user_data); + } + else if (seq->type == SEQ_IMAGE) { + /* might want an option not to loop over all strips */ + StripElem *se= seq->strip->stripdata; + int len= MEM_allocN_len(se) / sizeof(*se); + int i; + + for(i= 0; i < len; i++, se++) { + rewrite_path_fixed_dirfile(seq->strip->dir, se->name, visit_cb, absbase, bpath_user_data); + } + } + else { + /* simple case */ + rewrite_path_fixed(seq->strip->dir, visit_cb, absbase, bpath_user_data); + } + } + else if (seq->plugin) { + rewrite_path_fixed(seq->plugin->name, visit_cb, absbase, bpath_user_data); + } + + } + SEQ_END } - } else if ((bpi->type) == BPATH_FRS_MODULE) { - if (bpi->data) bpi->data= frs_module_stepdata__internal( bpi, 1 ); - else bpi->data= frs_module_stepdata__internal( bpi, 0 ); - - if (bpi->data) { - FreestyleModuleConfig *module= (FreestyleModuleConfig *)bpi->data; - bpi->_lib= NULL; - bpi->_path= module->module_path; - bpi->_name= NULL; - bpi->len= sizeof(module->module_path); - break; - } else { - bpi_type_step__internal(bpi); + for(; srl; srl= srl->next) { + FreestyleModuleConfig* module= srl->freestyleConfig.modules.first; + for (; module; module= module->next) { + rewrite_path_fixed(module->module_path, visit_cb, absbase, bpath_user_data); + } } } - } -} - -int BLI_bpathIterator_isDone( struct BPathIterator *bpi) -{ - return bpi->type==BPATH_DONE; -} - -/* include the path argument */ -static void bpath_as_report(struct BPathIterator *bpi, const char *message, ReportList *reports) -{ - const char *prefix; - const char *name; - char path_expanded[FILE_MAXDIR*2]; - - if(reports==NULL) - return; - - switch(BLI_bpathIterator_getType(bpi)) { - case BPATH_IMAGE: - prefix= "Image"; - break; - case BPATH_TEXTURE: - prefix= "Texture"; - break; - case BPATH_TEXT: - prefix= "Text"; - break; - case BPATH_SOUND: - prefix= "Sound"; break; - case BPATH_FONT: - prefix= "Font"; - break; - case BPATH_LIB: - prefix= "Library"; - break; - case BPATH_SEQ: - prefix= "Sequence"; - break; - case BPATH_CDATA: - prefix= "Mesh Data"; + case ID_ME: + { + Mesh *me= (Mesh *)id; + if (me->fdata.external) { + rewrite_path_fixed(me->fdata.external->filename, visit_cb, absbase, bpath_user_data); + } + } break; - case BPATH_FRS_MODULE: - prefix= "Freestyle Module"; + case ID_LI: + { + Library *lib= (Library *)id; + if(rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) { + BKE_library_filepath_set(lib, lib->name); + } + } break; default: - prefix= "Unknown"; + /* Nothing to do for other IDs that don't contain file paths. */ break; } - - name= BLI_bpathIterator_getName(bpi); - BLI_bpathIterator_getPathExpanded(bpi, path_expanded); - - if(reports) { - if (name) BKE_reportf(reports, RPT_WARNING, "%s \"%s\", \"%s\": %s", prefix, name, path_expanded, message); - else BKE_reportf(reports, RPT_WARNING, "%s \"%s\": %s", prefix, path_expanded, message); - } - } -/* high level function */ -void checkMissingFiles(Main *bmain, ReportList *reports) +void bpath_traverse_id_list(Main *bmain, ListBase *lb, BPathVisitor visit_cb, const int flag, void *bpath_user_data) { - 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, bmain, bmain->name, 0); - while (!BLI_bpathIterator_isDone(bpi)) { - BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); - - if (!BLI_exists(filepath_expanded)) - bpath_as_report(bpi, "file not found", reports); - - BLI_bpathIterator_step(bpi); + ID *id; + for(id= lb->first; id; id= id->next) { + bpath_traverse_id(bmain, id, visit_cb, flag, bpath_user_data); } - BLI_bpathIterator_free(bpi); } -/* dont log any errors at the moment, should probably do this */ -void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) +void bpath_traverse_main(Main *bmain, BPathVisitor visit_cb, const int flag, void *bpath_user_data) { - int tot= 0, changed= 0, failed= 0, linked= 0; - struct BPathIterator *bpi; - char filepath[FILE_MAX]; - const char *libpath; - - /* be sure there is low chance of the path being too short */ - char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - - if(basedir[0] == '\0') { - printf("makeFilesRelative: basedir='', this is a bug\n"); - return; - } - - BLI_bpathIterator_init(&bpi, bmain, basedir, 0); - while (!BLI_bpathIterator_isDone(bpi)) { - BLI_bpathIterator_getPath(bpi, filepath); - libpath= BLI_bpathIterator_getLib(bpi); - - if(strncmp(filepath, "//", 2)) { - if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */ - linked++; - } - else { /* local data, use the blend files path */ - BLI_strncpy(filepath_relative, filepath, sizeof(filepath_relative)); - /* Important BLI_cleanup_dir runs before the path is made relative - * because it wont work for paths that start with "//../" */ - BLI_cleanup_file(bpi->base_path, filepath_relative); /* fix any /foo/../foo/ */ - BLI_path_rel(filepath_relative, bpi->base_path); - /* be safe and check the length */ - if (BLI_bpathIterator_getPathMaxLen(bpi) <= strlen(filepath_relative)) { - bpath_as_report(bpi, "couldn't make path relative (too long)", reports); - failed++; - } - else { - if(strncmp(filepath_relative, "//", 2)==0) { - BLI_bpathIterator_setPath(bpi, filepath_relative); - changed++; - } - else { - bpath_as_report(bpi, "couldn't make path relative", reports); - failed++; - } - } - } - } - BLI_bpathIterator_step(bpi); - tot++; - } - BLI_bpathIterator_free(bpi); - - if(reports) - BKE_reportf(reports, failed ? RPT_ERROR : RPT_INFO, "Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked); + ListBase *lbarray[MAX_LIBARRAY]; + int a= set_listbasepointers(bmain, lbarray); + while(a--) bpath_traverse_id_list(bmain, lbarray[a], visit_cb, flag, bpath_user_data); } -/* dont log any errors at the moment, should probably do this - - * Verry similar to makeFilesRelative - keep in sync! */ -void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) +/* Rewrites a relative path to be relative to the main file - unless the path is + absolute, in which case it is not altered. */ +int bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src) { - int tot= 0, changed= 0, failed= 0, linked= 0; - - struct BPathIterator *bpi; - char filepath[FILE_MAX]; - const char *libpath; - /* be sure there is low chance of the path being too short */ - char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - - if(basedir[0] == '\0') { - printf("makeFilesAbsolute: basedir='', this is a bug\n"); - return; + char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE]; + const char *base_new= ((char **)pathbase_v)[0]; + const char *base_old= ((char **)pathbase_v)[1]; + + if (strncmp(base_old, "//", 2) == 0) { + printf("%s: error, old base path '%s' is not absolute.\n", + __func__, base_old); + return FALSE; } - BLI_bpathIterator_init(&bpi, bmain, basedir, 0); - while (!BLI_bpathIterator_isDone(bpi)) { - BLI_bpathIterator_getPath(bpi, filepath); - libpath= BLI_bpathIterator_getLib(bpi); - - 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 */ - BLI_bpathIterator_getPathExpanded(bpi, filepath_absolute); - BLI_cleanup_file(bpi->base_path, filepath_absolute); /* fix any /foo/../foo/ */ - /* to be safe, check the length */ - if (BLI_bpathIterator_getPathMaxLen(bpi) <= strlen(filepath_absolute)) { - bpath_as_report(bpi, "couldn't make absolute (too long)", reports); - failed++; - } - else { - if(strncmp(filepath_absolute, "//", 2)) { - BLI_bpathIterator_setPath(bpi, filepath_absolute); - changed++; - } - else { - bpath_as_report(bpi, "couldn't make absolute", reports); - failed++; - } - } - } - } - BLI_bpathIterator_step(bpi); - tot++; + /* Make referenced file absolute. This would be a side-effect of + BLI_cleanup_file, but we do it explicitely so we know if it changed. */ + BLI_strncpy(filepath, path_src, FILE_MAX); + if (BLI_path_abs(filepath, base_old)) { + /* Path was relative and is now absolute. Remap. + * Important BLI_cleanup_dir runs before the path is made relative + * because it wont work for paths that start with "//../" */ + BLI_cleanup_file(base_new, filepath); + BLI_path_rel(filepath, base_new); + BLI_strncpy(path_dst, filepath, FILE_MAX); + return TRUE; } - BLI_bpathIterator_free(bpi); - - if(reports) - BKE_reportf(reports, failed ? RPT_ERROR : RPT_INFO, "Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked); -} - - -/* 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==NULL) - return 0; - - if (*filesize == -1) - *filesize= 0; /* dir opened fine */ - - while ((de= readdir(dir)) != NULL) { - - if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) - continue; - - BLI_join_dirfile(path, sizeof(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 */ - size= status.st_size; - if ((size > 0) && (size > *filesize)) { /* find the biggest file */ - *filesize= size; - BLI_strncpy(filename_new, path, FILE_MAX); - } - } - } - 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(Main *bmain, const char *str) -{ - struct BPathIterator *bpi; - - /* be sure there is low chance of the path being too short */ - char filepath_expanded[FILE_MAXDIR*2]; - char filepath[FILE_MAX]; - const char *libpath; - int filesize, recur_depth; - - char dirname[FILE_MAX], filename_new[FILE_MAX]; - - //XXX waitcursor( 1 ); - - BLI_split_dir_part(str, dirname, sizeof(dirname)); - - BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0); - - while (!BLI_bpathIterator_isDone(bpi)) { - BLI_bpathIterator_getPath(bpi, filepath); - libpath= BLI_bpathIterator_getLib(bpi); - - /* Check if esc was pressed because searching files can be slow */ - /*XXX if (blender_test_break()) { - break; - }*/ - - if (libpath==NULL) { - - BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); - - if (!BLI_exists(filepath_expanded)) { - /* can the dir be opened? */ - filesize= -1; - recur_depth= 0; - - findFileRecursive(filename_new, dirname, BLI_path_basename(filepath), &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_path_rel(filename_new, bpi->base_path); - - BLI_bpathIterator_setPath(bpi, filename_new); - } - } - } - } - BLI_bpathIterator_step(bpi); + else { + /* Path was not relative to begin with. */ + return FALSE; } - BLI_bpathIterator_free(bpi); - - //XXX waitcursor( 0 ); } diff --git a/source/blender/blenlib/intern/callbacks.c b/source/blender/blenlib/intern/callbacks.c index d28f794440f..7e063bc1a18 100644 --- a/source/blender/blenlib/intern/callbacks.c +++ b/source/blender/blenlib/intern/callbacks.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/cpu.c b/source/blender/blenlib/intern/cpu.c index 860a0cae2d1..0a805293a05 100644 --- a/source/blender/blenlib/intern/cpu.c +++ b/source/blender/blenlib/intern/cpu.c @@ -1,6 +1,5 @@ /* * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/dynamiclist.h b/source/blender/blenlib/intern/dynamiclist.h index 7b496a5fed5..83b5aac963c 100644 --- a/source/blender/blenlib/intern/dynamiclist.h +++ b/source/blender/blenlib/intern/dynamiclist.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c index ae6589b6538..0bfa5e79eb8 100644 --- a/source/blender/blenlib/intern/dynlib.c +++ b/source/blender/blenlib/intern/dynlib.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index 5108d1bbbe1..65c5dffa33c 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index fef102d8267..95b6a970b49 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 7e5d03423e5..8f6100f1122 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 8b9cddcc1d1..6dd278ed777 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c index e6f27c78bf1..c0fa81475c0 100644 --- a/source/blender/blenlib/intern/gsqueue.c +++ b/source/blender/blenlib/intern/gsqueue.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/jitter.c b/source/blender/blenlib/intern/jitter.c index f0e81d6b5e9..ab33187ec4d 100644 --- a/source/blender/blenlib/intern/jitter.c +++ b/source/blender/blenlib/intern/jitter.c @@ -1,7 +1,6 @@ /* * Jitter offset table * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 05f71e0c01f..52fd857d6e4 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -3,7 +3,6 @@ * various string, file, list operations. * * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c index 3e18517f3e5..67c2a989582 100644 --- a/source/blender/blenlib/intern/math_base.c +++ b/source/blender/blenlib/intern/math_base.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 2a2b1100fd9..ae3cba7e94f 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 93143eb7db3..2ef29c1ce94 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 8f025880a86..b79ae9f0042 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 41dce131c17..832ef5d15b6 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 20c503de2c3..241ab62e175 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index ef286e1d102..0ca8b72c1e3 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -55,7 +53,7 @@ void unit_qt(float q[4]) q[1]= q[2]= q[3]= 0.0f; } -void copy_qt_qt(float *q1, const float *q2) +void copy_qt_qt(float q1[4], const float q2[4]) { q1[0]= q2[0]; q1[1]= q2[1]; diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 7dbceff46e4..01c3e112cd8 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 13623d9a93a..c460b69679b 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -310,6 +308,18 @@ MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3]) r[2] = v1[2] * v2[2]; } +MINLINE void negate_v2(float r[3]) +{ + r[0]= -r[0]; + r[1]= -r[1]; +} + +MINLINE void negate_v2_v2(float r[2], const float a[2]) +{ + r[0]= -a[0]; + r[1]= -a[1]; +} + MINLINE void negate_v3(float r[3]) { r[0]= -r[0]; diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 9efe8dc9739..e1a08de0dd8 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -1,6 +1,5 @@ /* * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index d28c1e29820..bc24415fd3f 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 57008af1812..9471f096682 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 9bd540e46ea..b1b7ebed18e 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 31ae8adc2d4..3b9fd2e07f6 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -4,7 +4,6 @@ * * april 95 * - * $Id$ * * A minimalist lib for functions doing stuff with rectangle structs. * diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index b159106f748..4bd17fcf0b9 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index b3caeb71822..86095e6b909 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index db5d4dc99eb..3a66425a5de 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index b4c58d3bab4..f8cdc3ec873 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -321,6 +319,8 @@ int BLI_str_utf8_size(const char *p) UTF8_COMPUTE (c, mask, len); + (void)mask; /* quiet warning */ + return len; } diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 097ad2bcd74..c049ab85546 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -1,6 +1,5 @@ /* * - * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c index 5bc7ca3609c..d86d68f6195 100644 --- a/source/blender/blenlib/intern/time.c +++ b/source/blender/blenlib/intern/time.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index be7682a63d4..30625e7b34e 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 6d912be71d3..f6c8c634c8d 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 21ad0ff7253..d3e989c28ae 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or |