Cleanup: rename 'filename' & 'str' to 'filepath' for whole file paths

This commit is contained in:
Campbell Barton 2023-05-27 15:10:59 +10:00
parent 823685db76
commit 848a886569
23 changed files with 168 additions and 167 deletions

View File

@ -258,7 +258,7 @@ void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports)
*
* \param search_directory: Directory to search in.
* \param filename_src: Search for this filename.
* \param r_filename_new: The path of the new found file will be copied here, caller must
* \param r_filepath_new: The path of the new found file will be copied here, caller must
* initialize as empty string.
* \param r_filesize: Size of the file, `FILESIZE_INVALID_DIRECTORY` if search directory could not
* be opened.
@ -268,7 +268,7 @@ void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports)
*/
static bool missing_files_find__recursive(const char *search_directory,
const char *filename_src,
char r_filename_new[FILE_MAX],
char r_filepath_new[FILE_MAX],
int64_t *r_filesize,
int *r_recurse_depth)
{
@ -307,7 +307,7 @@ static bool missing_files_find__recursive(const char *search_directory,
size = status.st_size;
if ((size > 0) && (size > *r_filesize)) { /* Find the biggest matching file. */
*r_filesize = size;
BLI_strncpy(r_filename_new, path, FILE_MAX);
BLI_strncpy(r_filepath_new, path, FILE_MAX);
found = true;
}
}
@ -316,7 +316,7 @@ static bool missing_files_find__recursive(const char *search_directory,
if (*r_recurse_depth <= MAX_DIR_RECURSE) {
(*r_recurse_depth)++;
found |= missing_files_find__recursive(
path, filename_src, r_filename_new, r_filesize, r_recurse_depth);
path, filename_src, r_filepath_new, r_filesize, r_recurse_depth);
(*r_recurse_depth)--;
}
}
@ -338,7 +338,7 @@ static bool missing_files_find_foreach_path_cb(BPathForeachPathData *bpath_data,
const char *path_src)
{
BPathFind_Data *data = (BPathFind_Data *)bpath_data->user_data;
char filename_new[FILE_MAX];
char filepath_new[FILE_MAX];
int64_t filesize = FILESIZE_INVALID_DIRECTORY;
int recurse_depth = 0;
@ -348,10 +348,10 @@ static bool missing_files_find_foreach_path_cb(BPathForeachPathData *bpath_data,
return false;
}
filename_new[0] = '\0';
filepath_new[0] = '\0';
is_found = missing_files_find__recursive(
data->searchdir, BLI_path_basename(path_src), filename_new, &filesize, &recurse_depth);
data->searchdir, BLI_path_basename(path_src), filepath_new, &filesize, &recurse_depth);
if (filesize == FILESIZE_INVALID_DIRECTORY) {
BKE_reportf(data->reports,
@ -371,7 +371,7 @@ static bool missing_files_find_foreach_path_cb(BPathForeachPathData *bpath_data,
bool was_relative = BLI_path_is_rel(path_dst);
BLI_strncpy(path_dst, filename_new, FILE_MAX);
BLI_strncpy(path_dst, filepath_new, FILE_MAX);
/* Keep the path relative if the previous one was relative. */
if (was_relative) {

View File

@ -601,14 +601,14 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip,
static void movieclip_open_anim_file(MovieClip *clip)
{
char str[FILE_MAX];
char filepath_abs[FILE_MAX];
if (!clip->anim) {
STRNCPY(str, clip->filepath);
BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&clip->id));
STRNCPY(filepath_abs, clip->filepath);
BLI_path_abs(filepath_abs, ID_BLEND_PATH_FROM_GLOBAL(&clip->id));
/* FIXME: make several stream accessible in image editor, too */
clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name);
clip->anim = openanim(filepath_abs, IB_rect, 0, clip->colorspace_settings.name);
if (clip->anim) {
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
@ -968,13 +968,13 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
{
MovieClip *clip;
int file;
char str[FILE_MAX];
char filepath_abs[FILE_MAX];
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
file = BLI_open(filepath_abs, O_BINARY | O_RDONLY, 0);
if (file == -1) {
return NULL;
}
@ -1003,17 +1003,17 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
{
MovieClip *clip;
char str[FILE_MAX], strtest[FILE_MAX];
char filepath_abs[FILE_MAX], filepath_test[FILE_MAX];
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
STRNCPY(strtest, clip->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id));
STRNCPY(filepath_test, clip->filepath);
BLI_path_abs(filepath_test, ID_BLEND_PATH(bmain, &clip->id));
if (BLI_path_cmp(strtest, str) == 0) {
if (BLI_path_cmp(filepath_test, filepath_abs) == 0) {
id_us_plus(&clip->id); /* officially should not, it doesn't link here! */
if (r_exists) {
*r_exists = true;

View File

@ -1309,15 +1309,15 @@ static int ptcache_path(PTCacheID *pid, char dirname[MAX_PTCACHE_PATH])
{
const char *blendfile_path = BKE_main_blendfile_path_from_global();
Library *lib = (pid->owner_id) ? pid->owner_id->lib : NULL;
const char *blendfilename = (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH) == 0) ?
lib->filepath_abs :
blendfile_path;
const char *blendfile_path_lib = (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH) == 0) ?
lib->filepath_abs :
blendfile_path;
if (pid->cache->flag & PTCACHE_EXTERNAL) {
BLI_strncpy(dirname, pid->cache->path, MAX_PTCACHE_PATH);
if (BLI_path_is_rel(dirname)) {
BLI_path_abs(dirname, blendfilename);
BLI_path_abs(dirname, blendfile_path_lib);
}
return BLI_path_slash_ensure(dirname, MAX_PTCACHE_PATH); /* new strlen() */
@ -1325,14 +1325,14 @@ static int ptcache_path(PTCacheID *pid, char dirname[MAX_PTCACHE_PATH])
if ((blendfile_path[0] != '\0') || lib) {
char file[MAX_PTCACHE_PATH]; /* we don't want the dir, only the file */
BLI_path_split_file_part(blendfilename, file, sizeof(file));
BLI_path_split_file_part(blendfile_path_lib, file, sizeof(file));
/* Remove the `.blend` extension. */
BLI_path_extension_strip(file);
/* Add blend file name to pointcache dir. */
BLI_snprintf(dirname, MAX_PTCACHE_PATH, "//" PTCACHE_PATH "%s", file);
BLI_path_abs(dirname, blendfilename);
BLI_path_abs(dirname, blendfile_path_lib);
return BLI_path_slash_ensure(dirname, MAX_PTCACHE_PATH); /* new strlen() */
}

View File

@ -256,10 +256,10 @@ bSound *BKE_sound_new_file(Main *bmain, const char *filepath)
{
bSound *sound;
const char *blendfile_path = BKE_main_blendfile_path(bmain);
char str[FILE_MAX];
char filepath_abs[FILE_MAX];
STRNCPY(str, filepath);
BLI_path_abs(str, blendfile_path);
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, blendfile_path);
sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0);
STRNCPY(sound->filepath, filepath);
@ -284,17 +284,17 @@ bSound *BKE_sound_new_file(Main *bmain, const char *filepath)
bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
{
bSound *sound;
char str[FILE_MAX], strtest[FILE_MAX];
char filepath_abs[FILE_MAX], filepath_test[FILE_MAX];
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
STRNCPY(strtest, sound->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &sound->id));
STRNCPY(filepath_test, sound->filepath);
BLI_path_abs(filepath_test, ID_BLEND_PATH(bmain, &sound->id));
if (BLI_path_cmp(strtest, str) == 0) {
if (BLI_path_cmp(filepath_test, filepath_abs) == 0) {
id_us_plus(&sound->id); /* officially should not, it doesn't link here! */
if (r_exists) {
*r_exists = true;
@ -1258,15 +1258,15 @@ bool BKE_sound_stream_info_get(struct Main *main,
SoundStreamInfo *sound_info)
{
const char *blendfile_path = BKE_main_blendfile_path(main);
char str[FILE_MAX];
char filepath_abs[FILE_MAX];
AUD_Sound *sound;
AUD_StreamInfo *stream_infos;
int stream_count;
STRNCPY(str, filepath);
BLI_path_abs(str, blendfile_path);
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, blendfile_path);
sound = AUD_Sound_file(str);
sound = AUD_Sound_file(filepath_abs);
if (!sound) {
return false;
}

View File

@ -366,17 +366,17 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists)
{
VFont *vfont;
char str[FILE_MAX], strtest[FILE_MAX];
char filepath_abs[FILE_MAX], filepath_test[FILE_MAX];
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) {
STRNCPY(strtest, vfont->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &vfont->id));
STRNCPY(filepath_test, vfont->filepath);
BLI_path_abs(filepath_test, ID_BLEND_PATH(bmain, &vfont->id));
if (BLI_path_cmp(strtest, str) == 0) {
if (BLI_path_cmp(filepath_test, filepath_abs) == 0) {
id_us_plus(&vfont->id); /* officially should not, it doesn't link here! */
if (r_exists) {
*r_exists = true;

View File

@ -1358,7 +1358,7 @@ static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext *o
/* Get the output filename-- similar to the other output formats */
static void ffmpeg_filepath_get(FFMpegContext *context,
char string[FILE_MAX],
char filepath[FILE_MAX],
const RenderData *rd,
bool preview,
const char *suffix)
@ -1369,7 +1369,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context,
const char **fe = exts;
int sfra, efra;
if (!string || !exts) {
if (!filepath || !exts) {
return;
}
@ -1382,10 +1382,10 @@ static void ffmpeg_filepath_get(FFMpegContext *context,
efra = rd->efra;
}
BLI_strncpy(string, rd->pic, FILE_MAX);
BLI_path_abs(string, BKE_main_blendfile_path_from_global());
BLI_strncpy(filepath, rd->pic, FILE_MAX);
BLI_path_abs(filepath, BKE_main_blendfile_path_from_global());
BLI_file_ensure_parent_dir_exists(string);
BLI_file_ensure_parent_dir_exists(filepath);
autosplit[0] = '\0';
@ -1397,33 +1397,33 @@ static void ffmpeg_filepath_get(FFMpegContext *context,
if (rd->scemode & R_EXTENSION) {
while (*fe) {
if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0) {
if (BLI_strcasecmp(filepath + strlen(filepath) - strlen(*fe), *fe) == 0) {
break;
}
fe++;
}
if (*fe == NULL) {
BLI_strncat(string, autosplit, FILE_MAX);
BLI_strncat(filepath, autosplit, FILE_MAX);
BLI_path_frame_range(string, FILE_MAX, sfra, efra, 4);
BLI_strncat(string, *exts, FILE_MAX);
BLI_path_frame_range(filepath, FILE_MAX, sfra, efra, 4);
BLI_strncat(filepath, *exts, FILE_MAX);
}
else {
*(string + strlen(string) - strlen(*fe)) = '\0';
BLI_strncat(string, autosplit, FILE_MAX);
BLI_strncat(string, *fe, FILE_MAX);
*(filepath + strlen(filepath) - strlen(*fe)) = '\0';
BLI_strncat(filepath, autosplit, FILE_MAX);
BLI_strncat(filepath, *fe, FILE_MAX);
}
}
else {
if (BLI_path_frame_check_chars(string)) {
BLI_path_frame_range(string, FILE_MAX, sfra, efra, 4);
if (BLI_path_frame_check_chars(filepath)) {
BLI_path_frame_range(filepath, FILE_MAX, sfra, efra, 4);
}
BLI_strncat(string, autosplit, FILE_MAX);
BLI_strncat(filepath, autosplit, FILE_MAX);
}
BLI_path_suffix(string, FILE_MAX, suffix, "");
BLI_path_suffix(filepath, FILE_MAX, suffix, "");
}
void BKE_ffmpeg_filepath_get(char *filepath,

View File

@ -631,10 +631,11 @@ static bool seq_sound_proxy_update_cb(Sequence *seq, void *user_data)
{
Main *bmain = (Main *)user_data;
if (seq->type == SEQ_TYPE_SOUND_HD) {
char str[FILE_MAX];
BLI_path_join(str, sizeof(str), seq->strip->dirpath, seq->strip->stripdata->filename);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
seq->sound = BKE_sound_new_file(bmain, str);
char filepath_abs[FILE_MAX];
BLI_path_join(
filepath_abs, sizeof(filepath_abs), seq->strip->dirpath, seq->strip->stripdata->filename);
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
seq->sound = BKE_sound_new_file(bmain, filepath_abs);
}
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)

View File

@ -88,12 +88,12 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
struct AlembicExportParams params = {
.frame_start = RNA_int_get(op->ptr, "start"),
@ -139,7 +139,7 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
}
const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
bool ok = ABC_export(scene, C, filename, &params, as_background_job);
bool ok = ABC_export(scene, C, filepath, &params, as_background_job);
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@ -493,37 +493,37 @@ static int cmp_frame(const void *a, const void *b)
return 0;
}
static int get_sequence_len(const char *filename, int *ofs)
static int get_sequence_len(const char *filepath, int *ofs)
{
int frame;
int numdigit;
if (!BLI_path_frame_get(filename, &frame, &numdigit)) {
if (!BLI_path_frame_get(filepath, &frame, &numdigit)) {
return 1;
}
char path[FILE_MAX];
BLI_path_split_dir_part(filename, path, FILE_MAX);
char dirpath[FILE_MAX];
BLI_path_split_dir_part(filepath, dirpath, FILE_MAX);
if (path[0] == '\0') {
/* The filename had no path, so just use the blend file path. */
BLI_path_split_dir_part(BKE_main_blendfile_path_from_global(), path, FILE_MAX);
if (dirpath[0] == '\0') {
/* The `filepath` had no directory component, so just use the blend files directory. */
BLI_path_split_dir_part(BKE_main_blendfile_path_from_global(), dirpath, sizeof(dirpath));
}
else {
BLI_path_abs(path, BKE_main_blendfile_path_from_global());
BLI_path_abs(dirpath, BKE_main_blendfile_path_from_global());
}
DIR *dir = opendir(path);
DIR *dir = opendir(dirpath);
if (dir == NULL) {
fprintf(stderr,
"Error opening directory '%s': %s\n",
path,
dirpath,
errno ? strerror(errno) : "unknown error");
return -1;
}
const char *ext = ".abc";
const char *basename = BLI_path_basename(filename);
const char *basename = BLI_path_basename(filepath);
const int len = strlen(basename) - (numdigit + strlen(ext));
ListBase frames;
@ -613,12 +613,12 @@ static int wm_alembic_import_invoke(bContext *C, wmOperator *op, const wmEvent *
static int wm_alembic_import_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
const float scale = RNA_float_get(op->ptr, "scale");
const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence");
@ -631,7 +631,7 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
int sequence_len = 1;
if (is_sequence) {
sequence_len = get_sequence_len(filename, &offset);
sequence_len = get_sequence_len(filepath, &offset);
if (sequence_len < 0) {
BKE_report(op->reports, RPT_ERROR, "Unable to determine ABC sequence length");
return OPERATOR_CANCELLED;
@ -653,7 +653,7 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
params.validate_meshes = validate_meshes;
params.always_add_cache_reader = always_add_cache_reader;
bool ok = ABC_import(C, filename, &params, as_background_job);
bool ok = ABC_import(C, filepath, &params, as_background_job);
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}

View File

@ -84,7 +84,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
int sample_animations;
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
@ -678,7 +678,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
static int wm_collada_import_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
char filepath[FILE_MAX];
int import_units;
int find_chains;
int auto_connect;
@ -690,7 +690,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
ImportSettings import_settings;
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
@ -705,9 +705,9 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
min_chain_length = RNA_int_get(op->ptr, "min_chain_length");
RNA_string_get(op->ptr, "filepath", filename);
RNA_string_get(op->ptr, "filepath", filepath);
import_settings.filepath = filename;
import_settings.filepath = filepath;
import_settings.import_units = import_units != 0;
import_settings.custom_normals = custom_normals != 0;
import_settings.auto_connect = auto_connect != 0;

View File

@ -106,7 +106,7 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
@ -117,8 +117,8 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
}
View3D *v3d = get_invoke_view3d(C);
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
const bool use_norm_thickness = RNA_boolean_get(op->ptr, "use_normalized_thickness");
@ -149,7 +149,7 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
/* Do export. */
WM_cursor_wait(true);
const bool done = gpencil_io_export(filename, &params);
const bool done = gpencil_io_export(filepath, &params);
WM_cursor_wait(false);
if (!done) {
@ -261,7 +261,7 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
@ -272,8 +272,8 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op)
}
View3D *v3d = get_invoke_view3d(C);
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
const bool use_norm_thickness = RNA_boolean_get(op->ptr, "use_normalized_thickness");
@ -302,7 +302,7 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op)
/* Do export. */
WM_cursor_wait(true);
const bool done = gpencil_io_export(filename, &params);
const bool done = gpencil_io_export(filepath, &params);
WM_cursor_wait(false);
if (!done) {

View File

@ -68,7 +68,7 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op)
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false) ||
!RNA_struct_find_property(op->ptr, "directory"))
{
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}

View File

@ -68,7 +68,7 @@ static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_obj_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
struct OBJExportParams export_params;
@ -414,7 +414,7 @@ static int wm_obj_import_exec(bContext *C, wmOperator *op)
OBJ_import(C, &import_params);
}
else {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}

View File

@ -61,7 +61,7 @@ static int wm_ply_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_ply_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
struct PLYExportParams export_params = {"\0"};
@ -259,7 +259,7 @@ static int wm_ply_import_execute(bContext *C, wmOperator *op)
PLY_import(C, &params, op);
}
else {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}

View File

@ -58,7 +58,7 @@ static int wm_stl_import_execute(bContext *C, wmOperator *op)
STL_import(C, &params);
}
else {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}

View File

@ -127,12 +127,12 @@ static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_usd_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata;
const bool as_background_job = (options != NULL && options->as_background_job);
@ -175,7 +175,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
STRNCPY(params.root_prim_path, root_prim_path);
bool ok = USD_export(C, filename, &params, as_background_job);
bool ok = USD_export(C, filepath, &params, as_background_job);
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@ -383,12 +383,12 @@ static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *even
static int wm_usd_import_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata;
const bool as_background_job = (options != NULL && options->as_background_job);
@ -496,7 +496,7 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
STRNCPY(params.import_textures_dir, import_textures_dir);
const bool ok = USD_import(C, filename, &params, as_background_job);
const bool ok = USD_import(C, filepath, &params, as_background_job);
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}

View File

@ -78,11 +78,11 @@ static int volume_import_exec(bContext *C, wmOperator *op)
ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, false);
LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
char filename[FILE_MAX];
BLI_path_split_file_part(range->filepath, filename, sizeof(filename));
BLI_path_extension_strip(filename);
char filepath[FILE_MAX];
BLI_path_split_file_part(range->filepath, filepath, sizeof(filepath));
BLI_path_extension_strip(filepath);
Object *object = object_volume_add(C, op, filename);
Object *object = object_volume_add(C, op, filepath);
Volume *volume = (Volume *)object->data;
STRNCPY(volume->filepath, range->filepath);
@ -94,7 +94,7 @@ static int volume_import_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports,
RPT_WARNING,
"Volume \"%s\" failed to load: %s",
filename,
filepath,
BKE_volume_grids_error_msg(volume));
BKE_id_delete(bmain, &object->id);
BKE_id_delete(bmain, &volume->id);
@ -104,7 +104,7 @@ static int volume_import_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports,
RPT_WARNING,
"Volume \"%s\" contains points, only voxel grids are supported",
filename);
filepath);
BKE_id_delete(bmain, &object->id);
BKE_id_delete(bmain, &volume->id);
continue;

View File

@ -3178,7 +3178,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
char filepath[FILE_MAX];
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}

View File

@ -428,7 +428,7 @@ static bool get_proxy_filepath(struct anim *anim,
return true;
}
static void get_tc_filename(struct anim *anim, IMB_Timecode_Type tc, char *filepath)
static void get_tc_filepath(struct anim *anim, IMB_Timecode_Type tc, char *filepath)
{
char index_dir[FILE_MAXDIR];
int i = IMB_timecode_to_array_index(tc);
@ -939,7 +939,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim,
if (tcs_in_use & tc_types[i]) {
char filepath[FILE_MAX];
get_tc_filename(anim, tc_types[i], filepath);
get_tc_filepath(anim, tc_types[i], filepath);
context->indexer[i] = IMB_index_builder_create(filepath);
if (!context->indexer[i]) {
@ -1428,17 +1428,17 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim,
for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) {
IMB_Proxy_Size proxy_size = proxy_sizes[i];
if (proxy_size & proxy_sizes_to_build) {
char filename[FILE_MAX];
if (get_proxy_filepath(anim, proxy_size, filename, false) == false) {
char filepath[FILE_MAX];
if (get_proxy_filepath(anim, proxy_size, filepath, false) == false) {
return nullptr;
}
void **filename_key_p;
if (!BLI_gset_ensure_p_ex(file_list, filename, &filename_key_p)) {
*filename_key_p = BLI_strdup(filename);
void **filepath_key_p;
if (!BLI_gset_ensure_p_ex(file_list, filepath, &filepath_key_p)) {
*filepath_key_p = BLI_strdup(filepath);
}
else {
proxy_sizes_to_build &= ~int(proxy_size);
printf("Proxy: %s already registered for generation, skipping\n", filename);
printf("Proxy: %s already registered for generation, skipping\n", filepath);
}
}
}
@ -1451,11 +1451,11 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim,
for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) {
IMB_Proxy_Size proxy_size = proxy_sizes[i];
if (proxy_size & built_proxies) {
char filename[FILE_MAX];
if (get_proxy_filepath(anim, proxy_size, filename, false) == false) {
char filepath[FILE_MAX];
if (get_proxy_filepath(anim, proxy_size, filepath, false) == false) {
return nullptr;
}
printf("Skipping proxy: %s\n", filename);
printf("Skipping proxy: %s\n", filepath);
}
}
}
@ -1615,7 +1615,7 @@ struct anim_index *IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc)
return nullptr;
}
get_tc_filename(anim, tc, filepath);
get_tc_filepath(anim, tc, filepath);
anim->curr_idx[i] = IMB_indexer_open(filepath);
@ -1642,9 +1642,9 @@ int IMB_anim_proxy_get_existing(struct anim *anim)
int i;
for (i = 0; i < num_proxy_sizes; i++) {
IMB_Proxy_Size proxy_size = proxy_sizes[i];
char filename[FILE_MAX];
get_proxy_filepath(anim, proxy_size, filename, false);
if (BLI_exists(filename)) {
char filepath[FILE_MAX];
get_proxy_filepath(anim, proxy_size, filepath, false);
if (BLI_exists(filepath)) {
existing |= int(proxy_size);
}
}

View File

@ -65,20 +65,20 @@ static MetaData create_abc_metadata(const Main *bmain, double scene_fps)
}
static OArchive *create_archive(std::ofstream *abc_ostream,
const std::string &filename,
const std::string &filepath,
MetaData &abc_metadata)
{
/* Use stream to support unicode character paths on Windows. */
#ifdef WIN32
char filename_cstr[FILE_MAX];
BLI_strncpy(filename_cstr, filename.c_str(), FILE_MAX);
char filepath_cstr[FILE_MAX];
BLI_strncpy(filepath_cstr, filepath.c_str(), FILE_MAX);
UTF16_ENCODE(filename_cstr);
std::wstring wstr(filename_cstr_16);
UTF16_ENCODE(filepath_cstr);
std::wstring wstr(filepath_cstr_16);
abc_ostream->open(wstr.c_str(), std::ios::out | std::ios::binary);
UTF16_UN_ENCODE(filename_cstr);
UTF16_UN_ENCODE(filepath_cstr);
#else
abc_ostream->open(filename, std::ios::out | std::ios::binary);
abc_ostream->open(filepath, std::ios::out | std::ios::binary);
#endif
ErrorHandler::Policy policy = ErrorHandler::kThrowPolicy;
@ -155,14 +155,14 @@ static void get_frames(double scene_fps,
ABCArchive::ABCArchive(const Main *bmain,
const Scene *scene,
AlembicExportParams params,
std::string filename)
std::string filepath)
: archive(nullptr)
{
double scene_fps = FPS;
MetaData abc_metadata = create_abc_metadata(bmain, scene_fps);
/* Create the Archive. */
archive = create_archive(&abc_ostream_, filename, abc_metadata);
archive = create_archive(&abc_ostream_, filepath, abc_metadata);
/* Create time samples for transforms and shapes. */
TimeSamplingPtr ts_xform;

View File

@ -35,7 +35,7 @@ class ABCArchive {
ABCArchive(const Main *bmain,
const Scene *scene,
AlembicExportParams params,
std::string filename);
std::string filepath);
~ABCArchive();
uint32_t time_sampling_index_transforms() const;

View File

@ -40,7 +40,7 @@ struct ExportJobData {
Depsgraph *depsgraph;
wmWindowManager *wm;
char filename[FILE_MAX];
char filepath[FILE_MAX];
AlembicExportParams params;
bool was_canceled;
@ -64,7 +64,7 @@ static void build_depsgraph(Depsgraph *depsgraph, const bool visible_objects_onl
static void report_job_duration(const ExportJobData *data)
{
blender::timeit::Nanoseconds duration = blender::timeit::Clock::now() - data->start_time;
std::cout << "Alembic export of '" << data->filename << "' took ";
std::cout << "Alembic export of '" << data->filepath << "' took ";
blender::timeit::print_duration(duration);
std::cout << '\n';
}
@ -103,11 +103,11 @@ static void export_startjob(void *customdata,
std::unique_ptr<ABCArchive> abc_archive;
try {
abc_archive = std::make_unique<ABCArchive>(
data->bmain, scene, data->params, std::string(data->filename));
data->bmain, scene, data->params, std::string(data->filepath));
}
catch (const std::exception &ex) {
std::stringstream error_message_stream;
error_message_stream << "Error writing to " << data->filename;
error_message_stream << "Error writing to " << data->filepath;
const std::string &error_message = error_message_stream.str();
/* The exception message can be very cryptic (just "iostream error" on Linux, for example),
@ -120,7 +120,7 @@ static void export_startjob(void *customdata,
catch (...) {
/* Unknown exception class, so we cannot include its message. */
std::stringstream error_message_stream;
error_message_stream << "Unknown error writing to " << data->filename;
error_message_stream << "Unknown error writing to " << data->filepath;
WM_report(RPT_ERROR, error_message_stream.str().c_str());
data->export_ok = false;
return;
@ -182,8 +182,8 @@ static void export_endjob(void *customdata)
DEG_graph_free(data->depsgraph);
if (data->was_canceled && BLI_exists(data->filename)) {
BLI_delete(data->filename, false, false);
if (data->was_canceled && BLI_exists(data->filepath)) {
BLI_delete(data->filepath, false, false);
}
G.is_rendering = false;
@ -207,7 +207,7 @@ bool ABC_export(Scene *scene,
job->bmain = CTX_data_main(C);
job->wm = CTX_wm_manager(C);
job->export_ok = false;
STRNCPY(job->filename, filepath);
STRNCPY(job->filepath, filepath);
job->depsgraph = DEG_graph_new(job->bmain, scene, view_layer, params->evaluation_mode);
job->params = *params;

View File

@ -104,22 +104,22 @@ ArchiveReader::ArchiveReader(const std::vector<ArchiveReader *> &readers) : m_re
ArchiveReader::ArchiveReader(struct Main *bmain, const char *filename)
{
char abs_filename[FILE_MAX];
STRNCPY(abs_filename, filename);
BLI_path_abs(abs_filename, BKE_main_blendfile_path(bmain));
char abs_filepath[FILE_MAX];
STRNCPY(abs_filepath, filename);
BLI_path_abs(abs_filepath, BKE_main_blendfile_path(bmain));
#ifdef WIN32
UTF16_ENCODE(abs_filename);
std::wstring wstr(abs_filename_16);
UTF16_ENCODE(abs_filepath);
std::wstring wstr(abs_filepath_16);
m_infile.open(wstr.c_str(), std::ios::in | std::ios::binary);
UTF16_UN_ENCODE(abs_filename);
UTF16_UN_ENCODE(abs_filepath);
#else
m_infile.open(abs_filename, std::ios::in | std::ios::binary);
m_infile.open(abs_filepath, std::ios::in | std::ios::binary);
#endif
m_streams.push_back(&m_infile);
m_archive = open_archive(abs_filename, m_streams);
m_archive = open_archive(abs_filepath, m_streams);
}
ArchiveReader::~ArchiveReader()

View File

@ -25,7 +25,7 @@ namespace blender::io::usd {
const StringRefNull usdz_export_test_filename = "usd/usdz_export_test.blend";
char temp_dir[FILE_MAX];
char temp_output_dir[FILE_MAX];
char output_filename[FILE_MAX];
char output_filepath[FILE_MAX];
class UsdUsdzExportTest : public BlendfileLoadingBaseTest {
protected:
@ -64,7 +64,7 @@ class UsdUsdzExportTest : public BlendfileLoadingBaseTest {
BLI_path_join(temp_output_dir, FILE_MAX, temp_base_dir, "usdz_test_output_dir");
BLI_dir_create_recursive(temp_output_dir);
BLI_path_join(output_filename, FILE_MAX, temp_output_dir, "output_новый.usdz");
BLI_path_join(output_filepath, FILE_MAX, temp_output_dir, "output_новый.usdz");
}
virtual void TearDown() override
@ -99,10 +99,10 @@ TEST_F(UsdUsdzExportTest, usdz_export)
USDExportParams params{};
bool result = USD_export(context, output_filename, &params, false);
ASSERT_TRUE(result) << "usd export to " << output_filename << " failed.";
bool result = USD_export(context, output_filepath, &params, false);
ASSERT_TRUE(result) << "usd export to " << output_filepath << " failed.";
pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(output_filename);
pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(output_filepath);
ASSERT_TRUE(bool(stage)) << "unable to open stage for the exported usdz file.";
std::string prim_name = pxr::TfMakeValidIdentifier("Cube");