Cleanup: rename fname to filepath or failname depending on use

This commit is contained in:
Campbell Barton
2023-05-27 15:38:15 +10:00
parent 12d91d4e60
commit 26e1d63b67
6 changed files with 40 additions and 40 deletions

View File

@@ -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, "");

View File

@@ -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.

View File

@@ -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)

View File

@@ -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;

View File

@@ -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);

View File

@@ -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) {