From 26e1d63b67a2c67cfc2ff617e23a712d674032bc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 May 2023 15:38:15 +1000 Subject: [PATCH] Cleanup: rename fname to filepath or failname depending on use --- source/blender/blenkernel/intern/ocean.c | 14 +++++----- source/blender/blenlib/BLI_path_util.h | 6 ++-- source/blender/blenlib/intern/path_util.c | 34 +++++++++++------------ source/blender/sequencer/intern/proxy.c | 22 +++++++-------- source/blender/sequencer/intern/proxy.h | 2 +- source/blender/sequencer/intern/render.c | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index b26a7f3fd3a..d125a8c8a88 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -1124,28 +1124,28 @@ static void cache_filepath( char *filepath, const char *dirname, const char *relbase, int frame, int type) { char cachepath[FILE_MAX]; - const char *fname; + const char *filename; switch (type) { case CACHE_TYPE_FOAM: - fname = "foam_"; + filename = "foam_"; break; case CACHE_TYPE_NORMAL: - fname = "normal_"; + filename = "normal_"; break; case CACHE_TYPE_SPRAY: - fname = "spray_"; + filename = "spray_"; break; case CACHE_TYPE_SPRAY_INVERSE: - fname = "spray_inverse_"; + filename = "spray_inverse_"; break; case CACHE_TYPE_DISPLACE: default: - fname = "disp_"; + filename = "disp_"; break; } - BLI_path_join(cachepath, sizeof(cachepath), dirname, fname); + BLI_path_join(cachepath, sizeof(cachepath), dirname, filename); BKE_image_path_from_imtype( filepath, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true, ""); diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 31951e4d7a8..2403e30481c 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -95,7 +95,7 @@ const char *BLI_path_parent_dir_end(const char *path, size_t path_len) * leveraged by higher layers to support "virtual filenames" which contain * substitution markers delineated between the two characters. * - * \return true if \a fname was changed, false otherwise. + * \return true if \a filename was changed, false otherwise. * * For now, simply replaces reserved chars (as listed in * https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words ) @@ -114,8 +114,8 @@ const char *BLI_path_parent_dir_end(const char *path, size_t path_len) * \note On Windows, it also checks for forbidden names * (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx ). */ -bool BLI_path_make_safe_filename_ex(char *fname, bool allow_tokens) ATTR_NONNULL(1); -bool BLI_path_make_safe_filename(char *fname) ATTR_NONNULL(1); +bool BLI_path_make_safe_filename_ex(char *filename, bool allow_tokens) ATTR_NONNULL(1); +bool BLI_path_make_safe_filename(char *filename) ATTR_NONNULL(1); /** * Make given path OS-safe. diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 10f237c207b..14fa20573f1 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -408,7 +408,7 @@ int BLI_path_canonicalize_native(char *path, int path_maxncpy) return path_len; } -bool BLI_path_make_safe_filename_ex(char *fname, bool allow_tokens) +bool BLI_path_make_safe_filename_ex(char *filename, bool allow_tokens) { #define INVALID_CHARS \ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \ @@ -424,69 +424,69 @@ bool BLI_path_make_safe_filename_ex(char *fname, bool allow_tokens) char *fn; bool changed = false; - if (*fname == '\0') { + if (*filename == '\0') { return changed; } - for (fn = fname; *fn && (fn = strpbrk(fn, invalid)); fn++) { + for (fn = filename; *fn && (fn = strpbrk(fn, invalid)); fn++) { *fn = '_'; changed = true; } /* Forbid only dots. */ - for (fn = fname; *fn == '.'; fn++) { + for (fn = filename; *fn == '.'; fn++) { /* Pass. */ } if (*fn == '\0') { - *fname = '_'; + *filename = '_'; changed = true; } #ifdef WIN32 { - const size_t len = strlen(fname); + const size_t len = strlen(filename); const char *invalid_names[] = { "con", "prn", "aux", "null", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", NULL, }; - char *lower_fname = BLI_strdup(fname); + char *filename_lower = BLI_strdup(filename); const char **iname; /* Forbid trailing dot (trailing space has already been replaced above). */ - if (fname[len - 1] == '.') { - fname[len - 1] = '_'; + if (filename[len - 1] == '.') { + filename[len - 1] = '_'; changed = true; } /* Check for forbidden names - not we have to check all combination - * of upper and lower cases, hence the usage of lower_fname + * of upper and lower cases, hence the usage of filename_lower * (more efficient than using #BLI_strcasestr repeatedly). */ - BLI_str_tolower_ascii(lower_fname, len); + BLI_str_tolower_ascii(filename_lower, len); for (iname = invalid_names; *iname; iname++) { - if (strstr(lower_fname, *iname) == lower_fname) { + if (strstr(filename_lower, *iname) == filename_lower) { const size_t iname_len = strlen(*iname); /* Only invalid if the whole name is made of the invalid chunk, or it has an * (assumed extension) dot just after. This means it will also catch *valid* * names like `aux.foo.bar`, but should be good enough for us! */ - if ((iname_len == len) || (lower_fname[iname_len] == '.')) { - *fname = '_'; + if ((iname_len == len) || (filename_lower[iname_len] == '.')) { + *filename = '_'; changed = true; break; } } } - MEM_freeN(lower_fname); + MEM_freeN(filename_lower); } #endif return changed; } -bool BLI_path_make_safe_filename(char *fname) +bool BLI_path_make_safe_filename(char *filename) { - return BLI_path_make_safe_filename_ex(fname, false); + return BLI_path_make_safe_filename_ex(filename, false); } bool BLI_path_make_safe(char *path) diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index 27475ae62e0..09e9b506054 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -96,7 +96,7 @@ double SEQ_rendersize_to_scale_factor(int render_size) return 1.0; } -bool seq_proxy_get_custom_file_fname(Sequence *seq, char *filepath, const int view_id) +bool seq_proxy_get_custom_file_filepath(Sequence *seq, char *filepath, const int view_id) { /* Ideally this would be #PROXY_MAXFILE however BLI_path_abs clamps to #FILE_MAX. */ char filepath_temp[FILE_MAX]; @@ -124,12 +124,12 @@ bool seq_proxy_get_custom_file_fname(Sequence *seq, char *filepath, const int vi return true; } -static bool seq_proxy_get_fname(Scene *scene, - Sequence *seq, - int timeline_frame, - eSpaceSeq_Proxy_RenderSize render_size, - char *filepath, - const int view_id) +static bool seq_proxy_get_filepath(Scene *scene, + Sequence *seq, + int timeline_frame, + eSpaceSeq_Proxy_RenderSize render_size, + char *filepath, + const int view_id) { char dirpath[PROXY_MAXFILE]; char suffix[24] = {'\0'}; @@ -149,7 +149,7 @@ static bool seq_proxy_get_fname(Scene *scene, if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE && ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) { - if (seq_proxy_get_custom_file_fname(seq, filepath, view_id)) { + if (seq_proxy_get_custom_file_filepath(seq, filepath, view_id)) { return true; } } @@ -214,7 +214,7 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline int frameno = (int)SEQ_give_frame_index(context->scene, seq, timeline_frame) + seq->anim_startofs; if (proxy->anim == NULL) { - if (seq_proxy_get_fname( + if (seq_proxy_get_filepath( context->scene, seq, timeline_frame, psize, filepath, context->view_id) == 0) { return NULL; @@ -235,7 +235,7 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE); } - if (seq_proxy_get_fname( + if (seq_proxy_get_filepath( context->scene, seq, timeline_frame, psize, filepath, context->view_id) == 0) { return NULL; @@ -267,7 +267,7 @@ static void seq_proxy_build_frame(const SeqRenderData *context, ImBuf *ibuf_tmp, *ibuf; Scene *scene = context->scene; - if (!seq_proxy_get_fname( + if (!seq_proxy_get_filepath( scene, seq, timeline_frame, proxy_render_size, filepath, context->view_id)) { return; diff --git a/source/blender/sequencer/intern/proxy.h b/source/blender/sequencer/intern/proxy.h index 984ad0040c0..93b078c432c 100644 --- a/source/blender/sequencer/intern/proxy.h +++ b/source/blender/sequencer/intern/proxy.h @@ -20,7 +20,7 @@ struct anim; struct ImBuf *seq_proxy_fetch(const struct SeqRenderData *context, struct Sequence *seq, int timeline_frame); -bool seq_proxy_get_custom_file_fname(struct Sequence *seq, char *name, int view_id); +bool seq_proxy_get_custom_file_filepath(struct Sequence *seq, char *name, int view_id); void free_proxy_seq(Sequence *seq); void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir); diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index c0c6597cc9f..daba8cfcf80 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -1053,7 +1053,7 @@ static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *cont StripProxy *proxy = seq->strip->proxy; if (proxy->anim == NULL) { - if (seq_proxy_get_custom_file_fname(seq, filepath, context->view_id)) { + if (seq_proxy_get_custom_file_filepath(seq, filepath, context->view_id)) { proxy->anim = openanim(filepath, IB_rect, 0, seq->strip->colorspace_settings.name); } if (proxy->anim == NULL) {