[Bf-blender-cvs] [9bd38750b39] master: Cleanup: replace BLI string copy & append with BLI_path_join(..)

Campbell Barton noreply at git.blender.org
Sun Oct 30 06:09:36 CET 2022


Commit: 9bd38750b39637f5b52ac64944af5b6113c30c03
Author: Campbell Barton
Date:   Sun Oct 30 15:56:28 2022 +1100
Branches: master
https://developer.blender.org/rB9bd38750b39637f5b52ac64944af5b6113c30c03

Cleanup: replace BLI string copy & append with BLI_path_join(..)

Copying and appending is unnecessarily verbose with each call having to
pass in the buffer size.

===================================================================

M	source/blender/editors/interface/interface_ops.cc
M	source/blender/imbuf/intern/indexer.c
M	source/blender/sequencer/intern/disk_cache.c
M	source/blender/sequencer/intern/proxy.c

===================================================================

diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc
index e089642963d..2d06dd2c465 100644
--- a/source/blender/editors/interface/interface_ops.cc
+++ b/source/blender/editors/interface/interface_ops.cc
@@ -1859,8 +1859,7 @@ static void edittranslation_find_po_file(const char *root,
 
   /* First, full lang code. */
   BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng);
-  BLI_path_join(path, maxlen, root, uilng);
-  BLI_path_append(path, maxlen, tstr);
+  BLI_path_join(path, maxlen, root, uilng, tstr);
   if (BLI_is_file(path)) {
     return;
   }
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index eaa72441fb6..63836690ee4 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -377,9 +377,9 @@ static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_l
 {
   if (!anim->index_dir[0]) {
     char filename[FILE_MAXFILE];
-    BLI_split_dirfile(anim->name, index_dir, filename, index_dir_len, sizeof(filename));
-    BLI_path_append(index_dir, index_dir_len, "BL_proxy");
-    BLI_path_append(index_dir, index_dir_len, filename);
+    char dirname[FILE_MAXDIR];
+    BLI_split_dirfile(anim->name, dirname, filename, index_dir_len, sizeof(filename));
+    BLI_path_join(index_dir, index_dir_len, dirname, "BL_proxy", filename);
   }
   else {
     BLI_strncpy(index_dir, anim->index_dir, index_dir_len);
diff --git a/source/blender/sequencer/intern/disk_cache.c b/source/blender/sequencer/intern/disk_cache.c
index 8c0ae4e055c..596a28201cc 100644
--- a/source/blender/sequencer/intern/disk_cache.c
+++ b/source/blender/sequencer/intern/disk_cache.c
@@ -291,8 +291,8 @@ static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path,
   /* Use suffix, so that the cache directory name does not conflict with the bmain's blend file. */
   const char *suffix = "_seq_cache";
   strncat(cache_dir, suffix, sizeof(cache_dir) - strlen(cache_dir) - 1);
-  BLI_strncpy(path, seq_disk_cache_base_dir(), path_len);
-  BLI_path_append(path, path_len, cache_dir);
+
+  BLI_path_join(path, path_len, seq_disk_cache_base_dir(), cache_dir);
 }
 
 static void seq_disk_cache_get_dir(
@@ -307,9 +307,8 @@ static void seq_disk_cache_get_dir(
   BLI_strncpy(seq_name, seq->name, sizeof(seq_name));
   BLI_filename_make_safe(scene_name);
   BLI_filename_make_safe(seq_name);
-  BLI_strncpy(path, project_dir, path_len);
-  BLI_path_append(path, path_len, scene_name);
-  BLI_path_append(path, path_len, seq_name);
+
+  BLI_path_join(path, path_len, project_dir, scene_name, seq_name);
 }
 
 static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache,
@@ -350,8 +349,7 @@ static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
   int version = 0;
 
   seq_disk_cache_get_project_dir(disk_cache, filepath, sizeof(filepath));
-  BLI_strncpy(path_version_file, filepath, sizeof(path_version_file));
-  BLI_path_append(path_version_file, sizeof(path_version_file), "cache_version");
+  BLI_path_join(path_version_file, sizeof(path_version_file), filepath, "cache_version");
 
   if (BLI_exists(filepath) && BLI_is_dir(filepath)) {
     FILE *file = BLI_fopen(path_version_file, "r");
diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c
index 9f08db2aa45..fc1df4dc3ac 100644
--- a/source/blender/sequencer/intern/proxy.c
+++ b/source/blender/sequencer/intern/proxy.c
@@ -585,8 +585,7 @@ void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
   char fname[FILE_MAXFILE];
 
   IMB_anim_get_fname(anim, fname, FILE_MAXFILE);
-  BLI_strncpy(dir, base_dir, sizeof(dir));
-  BLI_path_append(dir, sizeof(dir), fname);
+  BLI_path_join(dir, sizeof(dir), base_dir, fname);
   IMB_anim_set_index_dir(anim, dir);
 }



More information about the Bf-blender-cvs mailing list