[Bf-blender-cvs] [a0a1fc89387] master: Cleanup: BLI path extension API
Campbell Barton
noreply at git.blender.org
Sun Jun 17 16:15:53 CEST 2018
Commit: a0a1fc89387f0f1396b5e4320c2dd4a6fedd1c25
Author: Campbell Barton
Date: Sun Jun 17 16:13:24 2018 +0200
Branches: master
https://developer.blender.org/rBa0a1fc89387f0f1396b5e4320c2dd4a6fedd1c25
Cleanup: BLI path extension API
Use BLI_path_extension_* prefix.
===================================================================
M source/blender/blenkernel/intern/cachefile.c
M source/blender/blenkernel/intern/image.c
M source/blender/blenkernel/intern/writeavi.c
M source/blender/blenlib/BLI_path_util.h
M source/blender/blenlib/intern/path_util.c
M source/blender/blenloader/intern/readfile.c
M source/blender/collada/DocumentExporter.cpp
M source/blender/editors/interface/interface_icons.c
M source/blender/editors/io/io_alembic.c
M source/blender/editors/io/io_cache.c
M source/blender/editors/io/io_collada.c
M source/blender/editors/screen/screendump.c
M source/blender/editors/sound/sound_ops.c
M source/blender/editors/space_file/filelist.c
M source/blender/editors/space_image/image_ops.c
M source/blender/editors/space_sequencer/sequencer_edit.c
M source/blender/freestyle/intern/application/Controller.cpp
M source/blender/imbuf/intern/oiio/openimageio_api.cpp
M source/blender/imbuf/intern/readimage.c
M source/blender/imbuf/intern/util.c
M source/blender/python/intern/bpy_interface.c
M source/blender/render/intern/source/pipeline.c
M source/blender/render/intern/source/render_result.c
M source/blender/windowmanager/intern/wm_files.c
M source/creator/creator_signals.c
M source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 058394fc1b1..5f7759c7b55 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -198,7 +198,7 @@ bool BKE_cachefile_filepath_get(
char ext[32];
BLI_path_frame_strip(r_filepath, true, ext);
BLI_path_frame(r_filepath, frame, frame_len);
- BLI_ensure_extension(r_filepath, FILE_MAX, ext);
+ BLI_path_extension_ensure(r_filepath, FILE_MAX, ext);
/* TODO(kevin): store sequence range? */
return BLI_exists(r_filepath);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 95fb96c875f..76cf7317b19 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -574,7 +574,7 @@ static void image_init_color_management(Image *ima)
char BKE_image_alpha_mode_from_extension_ex(const char *filepath)
{
- if (BLI_testextensie_n(filepath, ".exr", ".cin", ".dpx", ".hdr", NULL)) {
+ if (BLI_path_extension_check_n(filepath, ".exr", ".cin", ".dpx", ".hdr", NULL)) {
return IMA_ALPHA_PREMUL;
}
else {
@@ -605,7 +605,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
ima = image_alloc(bmain, BLI_path_basename(filepath), IMA_SRC_FILE, IMA_TYPE_IMAGE);
STRNCPY(ima->name, filepath);
- if (BLI_testextensie_array(filepath, imb_ext_movie))
+ if (BLI_path_extension_check_array(filepath, imb_ext_movie))
ima->source = IMA_SRC_MOVIE;
image_init_color_management(ima);
@@ -1367,63 +1367,63 @@ static bool do_add_image_extension(char *string, const char imtype, const ImageF
(void)im_format; /* may be unused, depends on build options */
if (imtype == R_IMF_IMTYPE_IRIS) {
- if (!BLI_testextensie(string, extension_test = ".rgb"))
+ if (!BLI_path_extension_check(string, extension_test = ".rgb"))
extension = extension_test;
}
else if (imtype == R_IMF_IMTYPE_IRIZ) {
- if (!BLI_testextensie(string, extension_test = ".rgb"))
+ if (!BLI_path_extension_check(string, extension_test = ".rgb"))
extension = extension_test;
}
#ifdef WITH_HDR
else if (imtype == R_IMF_IMTYPE_RADHDR) {
- if (!BLI_testextensie(string, extension_test = ".hdr"))
+ if (!BLI_path_extension_check(string, extension_test = ".hdr"))
extension = extension_test;
}
#endif
else if (ELEM(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
- if (!BLI_testextensie(string, extension_test = ".png"))
+ if (!BLI_path_extension_check(string, extension_test = ".png"))
extension = extension_test;
}
#ifdef WITH_DDS
else if (imtype == R_IMF_IMTYPE_DDS) {
- if (!BLI_testextensie(string, extension_test = ".dds"))
+ if (!BLI_path_extension_check(string, extension_test = ".dds"))
extension = extension_test;
}
#endif
else if (ELEM(imtype, R_IMF_IMTYPE_TARGA, R_IMF_IMTYPE_RAWTGA)) {
- if (!BLI_testextensie(string, extension_test = ".tga"))
+ if (!BLI_path_extension_check(string, extension_test = ".tga"))
extension = extension_test;
}
else if (imtype == R_IMF_IMTYPE_BMP) {
- if (!BLI_testextensie(string, extension_test = ".bmp"))
+ if (!BLI_path_extension_check(string, extension_test = ".bmp"))
extension = extension_test;
}
#ifdef WITH_TIFF
else if (imtype == R_IMF_IMTYPE_TIFF) {
- if (!BLI_testextensie_n(string, extension_test = ".tif", ".tiff", NULL)) {
+ if (!BLI_path_extension_check_n(string, extension_test = ".tif", ".tiff", NULL)) {
extension = extension_test;
}
}
#endif
#ifdef WITH_OPENIMAGEIO
else if (imtype == R_IMF_IMTYPE_PSD) {
- if (!BLI_testextensie(string, extension_test = ".psd"))
+ if (!BLI_path_extension_check(string, extension_test = ".psd"))
extension = extension_test;
}
#endif
#ifdef WITH_OPENEXR
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
- if (!BLI_testextensie(string, extension_test = ".exr"))
+ if (!BLI_path_extension_check(string, extension_test = ".exr"))
extension = extension_test;
}
#endif
#ifdef WITH_CINEON
else if (imtype == R_IMF_IMTYPE_CINEON) {
- if (!BLI_testextensie(string, extension_test = ".cin"))
+ if (!BLI_path_extension_check(string, extension_test = ".cin"))
extension = extension_test;
}
else if (imtype == R_IMF_IMTYPE_DPX) {
- if (!BLI_testextensie(string, extension_test = ".dpx"))
+ if (!BLI_path_extension_check(string, extension_test = ".dpx"))
extension = extension_test;
}
#endif
@@ -1431,35 +1431,35 @@ static bool do_add_image_extension(char *string, const char imtype, const ImageF
else if (imtype == R_IMF_IMTYPE_JP2) {
if (im_format) {
if (im_format->jp2_codec == R_IMF_JP2_CODEC_JP2) {
- if (!BLI_testextensie(string, extension_test = ".jp2"))
+ if (!BLI_path_extension_check(string, extension_test = ".jp2"))
extension = extension_test;
}
else if (im_format->jp2_codec == R_IMF_JP2_CODEC_J2K) {
- if (!BLI_testextensie(string, extension_test = ".j2c"))
+ if (!BLI_path_extension_check(string, extension_test = ".j2c"))
extension = extension_test;
}
else
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
}
else {
- if (!BLI_testextensie(string, extension_test = ".jp2"))
+ if (!BLI_path_extension_check(string, extension_test = ".jp2"))
extension = extension_test;
}
}
#endif
else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc
- if (!(BLI_testextensie_n(string, extension_test = ".jpg", ".jpeg", NULL)))
+ if (!(BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", NULL)))
extension = extension_test;
}
if (extension) {
/* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
/* remove any other known image extension */
- if (BLI_testextensie_array(string, imb_ext_image)) {
- return BLI_replace_extension(string, FILE_MAX, extension);
+ if (BLI_path_extension_check_array(string, imb_ext_image)) {
+ return BLI_path_extension_replace(string, FILE_MAX, extension);
}
else {
- return BLI_ensure_extension(string, FILE_MAX, extension);
+ return BLI_path_extension_ensure(string, FILE_MAX, extension);
}
}
@@ -3043,7 +3043,7 @@ bool BKE_image_is_openexr(struct Image *ima)
{
#ifdef WITH_OPENEXR
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE)) {
- return BLI_testextensie(ima->name, ".exr");
+ return BLI_path_extension_check(ima->name, ".exr");
}
#else
UNUSED_VARS(ima);
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index 02940723520..17171dc1d2d 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -164,7 +164,7 @@ static void filepath_avi(char *string, RenderData *rd, bool preview, const char
BLI_make_existing_file(string);
if (rd->scemode & R_EXTENSION) {
- if (!BLI_testextensie(string, ".avi")) {
+ if (!BLI_path_extension_check(string, ".avi")) {
BLI_path_frame_range(string, sfra, efra, 4);
strcat(string, ".avi");
}
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index b59e7f99d59..5315b771260 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -81,12 +81,12 @@ bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen);
#endif
bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *name);
-bool BLI_testextensie(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-bool BLI_testextensie_n(const char *str, ...) ATTR_NONNULL(1) ATTR_SENTINEL(0);
-bool BLI_testextensie_array(const char *str, const char **ext_array) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-bool BLI_replace_extension(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
-bool BLI_ensure_extension(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
+bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+bool BLI_path_extension_check_n(const char *str, ...) ATTR_NONNULL(1) ATTR_SENTINEL(0);
+bool BLI_path_extension_check_array(const char *str, const char **ext_array) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+bool BLI_path_extension_check_glob(const char *str, const char *ext_fnmatch) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
+bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
bool BLI_ensure_filename(char *filepath, size_t maxlen, const char *filename) ATTR_NONNULL();
int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen);
void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 784e017961e..dcae1219c5b 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -703,7 +703,7 @@ bool BLI_parent_dir(char *path)
BLI_join_dirfile(tmp, sizeof(tmp), path, parent_dir);
BLI_cleanup_dir(NULL, tmp); /* does all the work of normalizing the path for us */
- if (!BLI_testextensie(tmp, parent_dir)) {
+ if (!BLI_path_extension_check(tmp, parent_dir)) {
strcpy(path, tmp); /* We assume pardir is always shorter... */
return true;
}
@@ -1353,7 +1353,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
BLI_path_native_slash(string);
}
-static bool testextensie_ex(const char *str, const size_t str_len,
+static bool path_extension_check_ex(const char *str, const size_t str_len,
const char *ext, const size_t ext_len)
{
BLI_assert(strlen(str) == str_len);
@@ -1364,12 +1364,12 @@ static bool testextensie_ex(const char *str, const size_t str_len,
}
/* does str end with ext. */
-bool BLI_testextensie(const char *str, const char *ext)
+bool BLI_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list