diff options
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 10 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 131 |
2 files changed, 0 insertions, 141 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 5315b771260..ebdf116ba7a 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -60,16 +60,6 @@ bool BLI_path_name_at_index( const char *__restrict path, const int index, int *__restrict r_offset, int *__restrict r_len) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; -#if 0 -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); -#endif - const char *BLI_last_slash(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; int BLI_add_slash(char *string) ATTR_NONNULL(); void BLI_del_slash(char *string) ATTR_NONNULL(); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index dcae1219c5b..8add24c989d 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1785,137 +1785,6 @@ bool BLI_path_name_at_index(const char *path, const int index, int *r_offset, in } } -/* UNUSED */ -#if 0 -/** - * 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 successful - * ------------------------------------------------------------- - * Hint: 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 - * - * 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 into the destination - * directory. - * - * Example: - * src : //../foo/bar.png becomes - * dest: [dest_dir]/bar.png. - * - * 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 ? - */ - -/** - * - * \param abs Optional string to return new full path - * \param abs_len Size of *abs string - * \param rel Optional area to return new path relative to parent directory of .blend file - * (only meaningful if item is in a subdirectory thereof) - * \param rel_len Size of *rel area - * \param base_dir Path of .blend file - * \param src_dir Original path of item (any initial "//" will be expanded to - * parent directory of .blend file) - * \param dest_dir New directory into which item will be moved - * \return bli_rebase_state - * - * \note Not actually used anywhere! - */ -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]; /* original full path of item */ - char dir[FILE_MAX]; /* directory part of src_dir */ - char base[FILE_MAX]; /* basename part of src_dir */ - char blend_dir[FILE_MAX]; /* directory, where current .blend file resides */ - char dest_path[FILE_MAX]; - char rel_dir[FILE_MAX]; - int len; - - if (abs) - abs[0] = 0; - - if (rel) - rel[0] = 0; - - BLI_split_dir_part(base_dir, blend_dir, sizeof(blend_dir)); - - if (src_dir[0] == '\0') - return BLI_REBASE_NO_SRCDIR; - - BLI_strncpy(path, src_dir, sizeof(path)); - - /* expand "//" in filename and get absolute path */ - BLI_path_abs(path, base_dir); - - /* get the directory part */ - BLI_split_dirfile(path, dir, base, sizeof(dir), sizeof(base)); - - len = strlen(blend_dir); - - rel_dir[0] = 0; - - /* if image is "below" current .blend file directory */ - if (!BLI_path_ncmp(path, blend_dir, len)) { - - if (BLI_path_cmp(dir, blend_dir) == 0) { - /* image is directly in .blend file parent directory => put directly in dest_dir */ - BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base); - } - else { - /* "below" (in subdirectory of .blend file parent directory) => put in same relative directory structure in dest_dir */ - /* rel = image_path_dir - blend_dir */ - BLI_strncpy(rel_dir, dir + len, sizeof(rel_dir)); - /* subdirectories relative to blend_dir */ - BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, rel_dir); - /* same subdirectories relative to dest_dir */ - BLI_path_append(dest_path, sizeof(dest_path), base); - /* keeping original item basename */ - } - - } - /* image is out of current directory -- just put straight in dest_dir */ - else { - BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base); - } - - if (abs) - BLI_strncpy(abs, dest_path, abs_len); - - if (rel) { - strncat(rel, rel_dir, rel_len); - strncat(rel, base, rel_len); /* FIXME: could overflow rel area! */ - } - - /* 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 BLI_REBASE_IDENTITY; - } - - return BLI_REBASE_OK; -} -#endif - - /** * Returns pointer to the leftmost path separator in string. Not actually used anywhere. */ |