[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48197] trunk/blender/source/blender/ blenlib: fixed function name: BLI_rebase_path, reworked description, added enum bli_rebase_state for defined return values
Gaia Clary
gaia.clary at machinimatrix.org
Fri Jun 22 17:38:55 CEST 2012
Revision: 48197
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48197
Author: gaiaclary
Date: 2012-06-22 15:38:49 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
fixed function name: BLI_rebase_path, reworked description, added enum bli_rebase_state for defined return values
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_path_util.h
trunk/blender/source/blender/blenlib/intern/path_util.c
Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h 2012-06-22 15:08:33 UTC (rev 48196)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h 2012-06-22 15:38:49 UTC (rev 48197)
@@ -89,7 +89,16 @@
void BLI_split_file_part(const char *string, char *file, const size_t filelen);
void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file);
char *BLI_path_basename(char *path);
-int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir);
+
+typedef enum bli_rebase_state {
+ BLI_REBASE_NO_SRCDIR = 0,
+ BLI_REBASE_OK = 1,
+ BLI_REBASE_IDENTITY = 2
+} bli_rebase_state;
+
+int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir);
+#define BKE_rebase_path BLI_rebase_path /* remove after a 2012 */
+
char *BLI_last_slash(const char *string);
int BLI_add_slash(char *string);
void BLI_del_slash(char *string);
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2012-06-22 15:08:33 UTC (rev 48196)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2012-06-22 15:38:49 UTC (rev 48197)
@@ -1547,31 +1547,40 @@
/**
* Produce image export path.
+ *
+ * Returns:
+ * 0 if image filename is empty or if destination path
+ * matches image path (i.e. both are the same file).
+ * 2 if source is identical to destination.
+ * 1 if rebase was successfull
+ * -------------------------------------------------------------
+ * Hint: Trailing slash in dest_dir is optional.
*
- * Fails returning 0 if image filename is empty or if destination path
- * matches image path (i.e. both are the same file).
- *
- * Trailing slash in dest_dir is optional.
- *
* Logic:
*
- * - if an image is "below" current .blend file directory, rebuild the
- * same dir structure in dest_dir
+ * - if an image is "below" current .blend file directory:
+ * rebuild the same dir structure in dest_dir
*
- * For example //textures/foo/bar.png becomes
- * [dest_dir]/textures/foo/bar.png.
+ * Example:
+ * src : //textures/foo/bar.png
+ * dest: [dest_dir]/textures/foo/bar.png.
*
* - if an image is not "below" current .blend file directory,
- * disregard it's path and copy it in the same directory where 3D file
- * goes.
+ * disregard it's path and copy it into the destination
+ * directory.
*
- * For example //../foo/bar.png becomes [dest_dir]/bar.png.
+ * Example:
+ * src : //../foo/bar.png becomes
+ * dest: [dest_dir]/bar.png.
*
- * This logic will help ensure that all image paths are relative and
+ * This logic ensures that all image paths are relative and
* that a user gets his images in one place. It'll also provide
* consistent behavior across exporters.
+ * IMPORTANT NOTE: If base_dir contains an empty string, then
+ * this function returns wrong results!
+ * XXX: test on empty base_dir and return an error ?
*/
-int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir)
+int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir)
{
char path[FILE_MAX];
char dir[FILE_MAX];
@@ -1590,7 +1599,7 @@
BLI_split_dir_part(base_dir, blend_dir, sizeof(blend_dir));
if (src_dir[0] == '\0')
- return 0;
+ return BLI_REBASE_NO_SRCDIR;
BLI_strncpy(path, src_dir, sizeof(path));
@@ -1637,10 +1646,10 @@
/* return 2 if src=dest */
if (BLI_path_cmp(path, dest_path) == 0) {
// if (G.debug & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path);
- return 2;
+ return BLI_REBASE_IDENTITY;
}
- return 1;
+ return BLI_REBASE_OK;
}
char *BLI_first_slash(char *string)
More information about the Bf-blender-cvs
mailing list