Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-12 03:10:54 +0300
committerCampbell Barton <campbell@blender.org>2022-09-12 04:02:25 +0300
commitf884a34cae6323327b181ebaa217758cc938fd29 (patch)
tree85f8749718461d6292c5c9b25c2ef6408d3850f8
parentcf9c0a4b506e85a4158ec68413c60e8af1de4a0a (diff)
Cleanup: replace BLI_snprintf with BLI_path_join
Also use a larger buffer to account for the unlikely case of the buffer not being big enough for the appended directories.
-rw-r--r--source/blender/blenkernel/intern/appdir.c10
-rw-r--r--source/blender/blenkernel/intern/image_save.cc4
-rw-r--r--source/blender/blenkernel/intern/packedFile.c36
-rw-r--r--source/blender/editors/util/ed_util.c2
4 files changed, 30 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 24e4305d916..96ac81fdb63 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -371,14 +371,16 @@ static bool get_path_local_ex(char *targetpath,
relfolder[0] = '\0';
}
- /* Try `{g_app.program_dirname}/2.xx/{folder_name}` the default directory
+ /* Try `{g_app.program_dirname}/3.xx/{folder_name}` the default directory
* for a portable distribution. See `WITH_INSTALL_PORTABLE` build-option. */
const char *path_base = g_app.program_dirname;
#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
/* Due new code-sign situation in OSX > 10.9.5
- * we must move the blender_version dir with contents to Resources. */
- char osx_resourses[FILE_MAX];
- BLI_snprintf(osx_resourses, sizeof(osx_resourses), "%s../Resources", g_app.program_dirname);
+ * we must move the blender_version dir with contents to Resources.
+ * Add 4 + 9 for the temporary `/../` path & `Resources`. */
+ char osx_resourses[FILE_MAX + 4 + 9];
+ BLI_path_join(
+ osx_resourses, sizeof(osx_resourses), g_app.program_dirname, "..", "Resources", NULL);
/* Remove the '/../' added above. */
BLI_path_normalize(NULL, osx_resourses);
path_base = osx_resourses;
diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc
index e65a94d5301..6f62ee123cb 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -175,12 +175,12 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
}
else {
- BLI_snprintf(opts->filepath, sizeof(opts->filepath), "//%s", DATA_("untitled"));
+ BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", DATA_("untitled"), nullptr);
BLI_path_abs(opts->filepath, BKE_main_blendfile_path(bmain));
}
}
else {
- BLI_snprintf(opts->filepath, sizeof(opts->filepath), "//%s", ima->id.name + 2);
+ BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", ima->id.name + 2, nullptr);
BLI_path_make_safe(opts->filepath);
BLI_path_abs(opts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain));
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 7c96c463339..901b42ac0b2 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -526,21 +526,27 @@ static void unpack_generate_paths(const char *name,
BLI_strncpy(tempdir, "//", sizeof(tempdir));
}
- switch (id_type) {
- case ID_VF:
- BLI_snprintf(r_relpath, relpathlen, "//fonts/%s", tempname);
- break;
- case ID_SO:
- BLI_snprintf(r_relpath, relpathlen, "//sounds/%s", tempname);
- break;
- case ID_IM:
- BLI_snprintf(r_relpath, relpathlen, "//textures/%s", tempname);
- break;
- case ID_VO:
- BLI_snprintf(r_relpath, relpathlen, "//volumes/%s", tempname);
- break;
- default:
- break;
+ {
+ const char *dir_name = NULL;
+ switch (id_type) {
+ case ID_VF:
+ dir_name = "fonts";
+ break;
+ case ID_SO:
+ dir_name = "sounds";
+ break;
+ case ID_IM:
+ dir_name = "textures";
+ break;
+ case ID_VO:
+ dir_name = "volumes";
+ break;
+ default:
+ break;
+ }
+ if (dir_name) {
+ BLI_path_join(r_relpath, relpathlen, "//", dir_name, tempname, NULL);
+ }
}
{
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 2f268d4ae23..e70851aedd6 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -377,7 +377,7 @@ void unpack_menu(bContext *C,
char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX];
BLI_split_file_part(abs_name, fi, sizeof(fi));
- BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
+ BLI_path_join(local_name, sizeof(local_name), "//", folder, fi, NULL);
if (!STREQ(abs_name, local_name)) {
switch (BKE_packedfile_compare_to_file(blendfile_path, local_name, pf)) {
case PF_CMP_NOFILE: