Cleanup: use "filepath" instead of "filename" for full paths

Reserve "filename" when only the name component is used.
This commit is contained in:
Campbell Barton 2022-03-24 16:33:32 +11:00
parent 5058c4b144
commit 4682a0882f
36 changed files with 196 additions and 191 deletions

View File

@ -44,7 +44,7 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
void BLF_unload(const char *name) ATTR_NONNULL();
void BLF_unload_id(int fontid);
char *BLF_display_name_from_file(const char *filename);
char *BLF_display_name_from_file(const char *filepath);
/**
* Check if font supports a particular glyph.
@ -279,7 +279,7 @@ void BLF_dir_free(char **dirs, int count) ATTR_NONNULL();
*
* \note called from a thread, so it bypasses the normal BLF_* api (which isn't thread-safe).
*/
void BLF_thumb_preview(const char *filename,
void BLF_thumb_preview(const char *filepath,
const char **draw_str,
const char **i18n_draw_str,
unsigned char draw_str_lines,

View File

@ -158,14 +158,14 @@ int BLF_load_unique(const char *name)
return -1;
}
char *filename = blf_dir_search(name);
if (!filename) {
char *filepath = blf_dir_search(name);
if (!filepath) {
printf("Can't find font: %s\n", name);
return -1;
}
FontBLF *font = blf_font_new(name, filename);
MEM_freeN(filename);
FontBLF *font = blf_font_new(name, filepath);
MEM_freeN(filepath);
if (!font) {
printf("Can't load font: %s\n", name);
@ -869,9 +869,9 @@ void BLF_draw_buffer(int fontid, const char *str, const size_t str_len)
BLF_draw_buffer_ex(fontid, str, str_len, NULL);
}
char *BLF_display_name_from_file(const char *filename)
char *BLF_display_name_from_file(const char *filepath)
{
FontBLF *font = blf_font_new("font_name", filename);
FontBLF *font = blf_font_new("font_name", filepath);
if (!font) {
return NULL;
}

View File

@ -132,12 +132,12 @@ char *blf_dir_search(const char *file)
return s;
}
char *blf_dir_metrics_search(const char *filename)
char *blf_dir_metrics_search(const char *filepath)
{
char *mfile;
char *s;
mfile = BLI_strdup(filename);
mfile = BLI_strdup(filepath);
s = strrchr(mfile, '.');
if (s) {
if (BLI_strnlen(s, 4) < 4) {

View File

@ -1213,14 +1213,14 @@ static void blf_font_fill(FontBLF *font)
font->glyph_cache_mutex = &blf_glyph_cache_mutex;
}
FontBLF *blf_font_new(const char *name, const char *filename)
FontBLF *blf_font_new(const char *name, const char *filepath)
{
FontBLF *font;
FT_Error err;
char *mfile;
font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new");
err = FT_New_Face(ft_lib, filename, 0, &font->face);
err = FT_New_Face(ft_lib, filepath, 0, &font->face);
if (err) {
if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) {
printf("Format of this font file is not supported\n");
@ -1246,17 +1246,17 @@ FontBLF *blf_font_new(const char *name, const char *filename)
return NULL;
}
mfile = blf_dir_metrics_search(filename);
mfile = blf_dir_metrics_search(filepath);
if (mfile) {
err = FT_Attach_File(font->face, mfile);
if (err) {
fprintf(stderr, "FT_Attach_File failed to load '%s' with error %d\n", filename, (int)err);
fprintf(stderr, "FT_Attach_File failed to load '%s' with error %d\n", filepath, (int)err);
}
MEM_freeN(mfile);
}
font->name = BLI_strdup(name);
font->filename = BLI_strdup(filename);
font->filepath = BLI_strdup(filepath);
blf_font_fill(font);
if (FT_HAS_KERNING(font->face)) {
@ -1303,7 +1303,7 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m
}
font->name = BLI_strdup(name);
font->filename = NULL;
font->filepath = NULL;
blf_font_fill(font);
return font;
}
@ -1317,8 +1317,8 @@ void blf_font_free(FontBLF *font)
}
FT_Done_Face(font->face);
if (font->filename) {
MEM_freeN(font->filename);
if (font->filepath) {
MEM_freeN(font->filepath);
}
if (font->name) {
MEM_freeN(font->name);

View File

@ -25,7 +25,7 @@ char *blf_dir_search(const char *file);
* Some font have additional file with metrics information,
* in general, the extension of the file is: `.afm` or `.pfm`
*/
char *blf_dir_metrics_search(const char *filename);
char *blf_dir_metrics_search(const char *filepath);
/* int blf_dir_split(const char *str, char *file, int *size); */ /* UNUSED */
int blf_font_init(void);
@ -36,7 +36,7 @@ bool blf_font_id_is_valid(int fontid);
void blf_draw_buffer__start(struct FontBLF *font);
void blf_draw_buffer__end(void);
struct FontBLF *blf_font_new(const char *name, const char *filename);
struct FontBLF *blf_font_new(const char *name, const char *filepath);
struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size);
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size);

View File

@ -147,8 +147,8 @@ typedef struct FontBLF {
/* # of times this font was loaded */
unsigned int reference_count;
/* filename or NULL. */
char *filename;
/** File-path or NULL. */
char *filepath;
/* aspect ratio or scale. */
float aspect[3];

View File

@ -29,7 +29,7 @@
#include "BLI_strict_flags.h"
void BLF_thumb_preview(const char *filename,
void BLF_thumb_preview(const char *filepath,
const char **draw_str,
const char **i18n_draw_str,
const unsigned char draw_str_lines,
@ -49,9 +49,9 @@ void BLF_thumb_preview(const char *filename,
FontBLF *font;
/* Create a new blender font obj and fill it with default values */
font = blf_font_new("thumb_font", filename);
font = blf_font_new("thumb_font", filepath);
if (!font) {
printf("Info: Can't load font '%s', no preview possible\n", filename);
printf("Info: Can't load font '%s', no preview possible\n", filepath);
return;
}

View File

@ -129,7 +129,7 @@ int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface,
struct Object *cObject,
int frame);
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface,
char *filename,
const char *filepath,
short output_layer);
/* PaintPoint state */

View File

@ -49,21 +49,26 @@ bool BKE_image_save(struct ReportList *reports,
/* Render saving. */
/* Save single or multilayer OpenEXR files from the render result.
* Optionally saves only a specific view or layer. */
/**
* Save single or multi-layer OpenEXR files from the render result.
* Optionally saves only a specific view or layer.
*/
bool BKE_image_render_write_exr(struct ReportList *reports,
const struct RenderResult *rr,
const char *filename,
const char *filepath,
const struct ImageFormatData *imf,
const bool save_as_render,
const char *view,
int layer);
/**
* \param filepath_basis: May be used as-is, or used as a basis for multi-view images.
*/
bool BKE_image_render_write(struct ReportList *reports,
struct RenderResult *rr,
const struct Scene *scene,
const bool stamp,
const char *name);
const char *filepath_basis);
#ifdef __cplusplus
}

View File

@ -45,7 +45,7 @@ enum ePF_FileStatus {
struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src);
struct PackedFile *BKE_packedfile_new(struct ReportList *reports,
const char *filename,
const char *filepath,
const char *basepath);
struct PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen);
@ -102,7 +102,7 @@ int BKE_packedfile_unpack_all_libraries(struct Main *bmain, struct ReportList *r
int BKE_packedfile_write_to_file(struct ReportList *reports,
const char *ref_file_name,
const char *filename,
const char *filepath,
struct PackedFile *pf,
bool guimode);
@ -122,7 +122,7 @@ int BKE_packedfile_count_all(struct Main *bmain);
* - #PF_NOFILE: the original file doesn't exist.
*/
enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
const char *filename,
const char *filepath_rel,
struct PackedFile *pf);
/* Read. */

View File

@ -3266,7 +3266,7 @@ static void dynamic_paint_output_surface_image_wetmap_cb(
}
void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
char *filename,
const char *filepath,
short output_layer)
{
ImBuf *ibuf = NULL;
@ -3286,7 +3286,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
format = R_IMF_IMTYPE_PNG;
}
#endif
BLI_strncpy(output_file, filename, sizeof(output_file));
BLI_strncpy(output_file, filepath, sizeof(output_file));
BKE_image_path_ensure_ext_from_imtype(output_file, format);
/* Validate output file path */

View File

@ -486,7 +486,7 @@ static float *image_exr_from_scene_linear_to_output(float *rect,
bool BKE_image_render_write_exr(ReportList *reports,
const RenderResult *rr,
const char *filename,
const char *filepath,
const ImageFormatData *imf,
const bool save_as_render,
const char *view,
@ -630,11 +630,11 @@ bool BKE_image_render_write_exr(ReportList *reports,
errno = 0;
BLI_make_existing_file(filename);
BLI_make_existing_file(filepath);
int compress = (imf ? imf->exr_codec : 0);
bool success = IMB_exr_begin_write(
exrhandle, filename, rr->rectx, rr->recty, compress, rr->stamp_data);
exrhandle, filepath, rr->rectx, rr->recty, compress, rr->stamp_data);
if (success) {
IMB_exr_write_channels(exrhandle);
}
@ -693,7 +693,7 @@ bool BKE_image_render_write(ReportList *reports,
RenderResult *rr,
const Scene *scene,
const bool stamp,
const char *filename)
const char *filepath_basis)
{
bool ok = true;
@ -711,8 +711,8 @@ bool BKE_image_render_write(ReportList *reports,
const float dither = scene->r.dither_intensity;
if (image_format.views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) {
ok = BKE_image_render_write_exr(reports, rr, filename, &image_format, true, nullptr, -1);
image_render_print_save_message(reports, filename, ok, errno);
ok = BKE_image_render_write_exr(reports, rr, filepath_basis, &image_format, true, nullptr, -1);
image_render_print_save_message(reports, filepath_basis, ok, errno);
}
/* mono, legacy code */
@ -722,10 +722,10 @@ bool BKE_image_render_write(ReportList *reports,
rv = rv->next, view_id++) {
char filepath[FILE_MAX];
if (is_mono) {
STRNCPY(filepath, filename);
STRNCPY(filepath, filepath_basis);
}
else {
BKE_scene_multiview_view_filepath_get(&scene->r, filename, rv->name, filepath);
BKE_scene_multiview_view_filepath_get(&scene->r, filepath_basis, rv->name, filepath);
}
if (is_exr_rr) {
@ -768,7 +768,7 @@ bool BKE_image_render_write(ReportList *reports,
BLI_assert(image_format.views_format == R_IMF_VIEWS_STEREO_3D);
char filepath[FILE_MAX];
STRNCPY(filepath, filename);
STRNCPY(filepath, filepath_basis);
if (image_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
printf("Stereo 3D not supported for MultiLayer image: %s\n", filepath);

View File

@ -174,16 +174,16 @@ PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen)
return pf;
}
PackedFile *BKE_packedfile_new(ReportList *reports, const char *filename, const char *basepath)
PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath, const char *basepath)
{
PackedFile *pf = NULL;
int file, filelen;
char name[FILE_MAX];
void *data;
/* render result has no filename and can be ignored
/* render result has no filepath and can be ignored
* any other files with no name can be ignored too */
if (filename[0] == '\0') {
if (filepath[0] == '\0') {
return pf;
}
@ -191,7 +191,7 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filename, const
/* convert relative filenames to absolute filenames */
BLI_strncpy(name, filename, sizeof(name));
BLI_strncpy(name, filepath, sizeof(name));
BLI_path_abs(name, basepath);
/* open the file
@ -285,7 +285,7 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
int BKE_packedfile_write_to_file(ReportList *reports,
const char *ref_file_name,
const char *filename,
const char *filepath,
PackedFile *pf,
const bool guimode)
{
@ -299,7 +299,7 @@ int BKE_packedfile_write_to_file(ReportList *reports,
if (guimode) {
} // XXX waitcursor(1);
BLI_strncpy(name, filename, sizeof(name));
BLI_strncpy(name, filepath, sizeof(name));
BLI_path_abs(name, ref_file_name);
if (BLI_exists(name)) {
@ -358,7 +358,7 @@ int BKE_packedfile_write_to_file(ReportList *reports,
}
enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
const char *filename,
const char *filepath,
PackedFile *pf)
{
BLI_stat_t st;
@ -366,7 +366,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
char buf[4096];
char name[FILE_MAX];
BLI_strncpy(name, filename, sizeof(name));
BLI_strncpy(name, filepath, sizeof(name));
BLI_path_abs(name, ref_file_name);
if (BLI_stat(name, &st) == -1) {

View File

@ -526,16 +526,16 @@ static bool font_paste_utf8(bContext *C, const char *str, const size_t str_len)
/** \name Paste From File Operator
* \{ */
static int paste_from_file(bContext *C, ReportList *reports, const char *filename)
static int paste_from_file(bContext *C, ReportList *reports, const char *filepath)
{
Object *obedit = CTX_data_edit_object(C);
char *strp;
size_t filelen;
int retval;
strp = BLI_file_read_text_as_mem(filename, 1, &filelen);
strp = BLI_file_read_text_as_mem(filepath, 1, &filelen);
if (strp == NULL) {
BKE_reportf(reports, RPT_ERROR, "Failed to open file '%s'", filename);
BKE_reportf(reports, RPT_ERROR, "Failed to open file '%s'", filepath);
return OPERATOR_CANCELLED;
}
strp[filelen] = 0;
@ -545,7 +545,7 @@ static int paste_from_file(bContext *C, ReportList *reports, const char *filenam
retval = OPERATOR_FINISHED;
}
else {
BKE_reportf(reports, RPT_ERROR, "File too long %s", filename);
BKE_reportf(reports, RPT_ERROR, "File too long %s", filepath);
retval = OPERATOR_CANCELLED;
}
@ -556,12 +556,12 @@ static int paste_from_file(bContext *C, ReportList *reports, const char *filenam
static int paste_from_file_exec(bContext *C, wmOperator *op)
{
char *path;
char *filepath;
int retval;
path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0, NULL);
retval = paste_from_file(C, op->reports, path);
MEM_freeN(path);
filepath = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0, NULL);
retval = paste_from_file(C, op->reports, filepath);
MEM_freeN(filepath);
return retval;
}
@ -2091,7 +2091,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
VFont *vfont = NULL;
const char *path;
const char *filepath;
PointerRNA idptr;
PropertyPointerRNA *pprop;
@ -2106,13 +2106,13 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
vfont = (VFont *)idptr.owner_id;
}
path = (vfont && !BKE_vfont_is_builtin(vfont)) ? vfont->filepath : U.fontdir;
filepath = (vfont && !BKE_vfont_is_builtin(vfont)) ? vfont->filepath : U.fontdir;
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return font_open_exec(C, op);
}
RNA_string_set(op->ptr, "filepath", path);
RNA_string_set(op->ptr, "filepath", filepath);
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;

View File

@ -399,27 +399,27 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
* Save output images
*/
{
char filename[FILE_MAX];
char filepath[FILE_MAX];
/* primary output layer */
if (surface->flags & MOD_DPAINT_OUT1) {
/* set filepath */
BLI_join_dirfile(
filename, sizeof(filename), surface->image_output_path, surface->output_name);
BLI_path_frame(filename, frame, 4);
filepath, sizeof(filepath), surface->image_output_path, surface->output_name);
BLI_path_frame(filepath, frame, 4);
/* save image */
dynamicPaint_outputSurfaceImage(surface, filename, 0);
dynamicPaint_outputSurfaceImage(surface, filepath, 0);
}
/* secondary output */
if (surface->flags & MOD_DPAINT_OUT2 && surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
/* set filepath */
BLI_join_dirfile(
filename, sizeof(filename), surface->image_output_path, surface->output_name2);
BLI_path_frame(filename, frame, 4);
filepath, sizeof(filepath), surface->image_output_path, surface->output_name2);
BLI_path_frame(filepath, frame, 4);
/* save image */
dynamicPaint_outputSurfaceImage(surface, filename, 1);
dynamicPaint_outputSurfaceImage(surface, filepath, 1);
}
}
}

View File

@ -44,12 +44,12 @@ void IMB_exr_add_channel(void *handle,
* Read from file.
*/
bool IMB_exr_begin_read(
void *handle, const char *filename, int *width, int *height, bool parse_channels);
void *handle, const char *filepath, int *width, int *height, bool parse_channels);
/**
* Used for output files (from #RenderResult) (single and multi-layer, single and multi-view).
*/
bool IMB_exr_begin_write(void *handle,
const char *filename,
const char *filepath,
int width,
int height,
int compress,
@ -59,7 +59,7 @@ bool IMB_exr_begin_write(void *handle,
* (FSA and Save Buffers).
*/
void IMB_exrtile_begin_write(
void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley);
void *handle, const char *filepath, int mipmap, int width, int height, int tilex, int tiley);
/**
* Still clumsy name handling, layers/channels can be ordered as list in list later.

View File

@ -155,15 +155,15 @@ class IMemStream : public Imf::IStream {
class IFileStream : public Imf::IStream {
public:
IFileStream(const char *filename) : IStream(filename)
IFileStream(const char *filepath) : IStream(filepath)
{
/* utf-8 file path support on windows */
#if defined(WIN32)
wchar_t *wfilename = alloc_utf16_from_8(filename, 0);
ifs.open(wfilename, std::ios_base::binary);
free(wfilename);
wchar_t *wfilepath = alloc_utf16_from_8(filepath, 0);
ifs.open(wfilepath, std::ios_base::binary);
free(wfilepath);
#else
ifs.open(filename, std::ios_base::binary);
ifs.open(filepath, std::ios_base::binary);
#endif
if (!ifs) {
@ -261,15 +261,15 @@ class OMemStream : public OStream {
class OFileStream : public OStream {
public:
OFileStream(const char *filename) : OStream(filename)
OFileStream(const char *filepath) : OStream(filepath)
{
/* utf-8 file path support on windows */
#if defined(WIN32)
wchar_t *wfilename = alloc_utf16_from_8(filename, 0);
ofs.open(wfilename, std::ios_base::binary);
free(wfilename);
wchar_t *wfilepath = alloc_utf16_from_8(filepath, 0);
ofs.open(wfilepath, std::ios_base::binary);
free(wfilepath);
#else
ofs.open(filename, std::ios_base::binary);
ofs.open(filepath, std::ios_base::binary);
#endif
if (!ofs) {
@ -834,7 +834,7 @@ void IMB_exr_add_channel(void *handle,
}
bool IMB_exr_begin_write(void *handle,
const char *filename,
const char *filepath,
int width,
int height,
int compress,
@ -872,7 +872,7 @@ bool IMB_exr_begin_write(void *handle,
/* avoid crash/abort when we don't have permission to write here */
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
try {
data->ofile_stream = new OFileStream(filename);
data->ofile_stream = new OFileStream(filepath);
data->ofile = new OutputFile(*(data->ofile_stream), header);
}
catch (const std::exception &exc) {
@ -889,7 +889,7 @@ bool IMB_exr_begin_write(void *handle,
}
void IMB_exrtile_begin_write(
void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley)
void *handle, const char *filepath, int mipmap, int width, int height, int tilex, int tiley)
{
ExrHandle *data = (ExrHandle *)handle;
Header header(width, height);
@ -941,7 +941,7 @@ void IMB_exrtile_begin_write(
/* avoid crash/abort when we don't have permission to write here */
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
try {
data->ofile_stream = new OFileStream(filename);
data->ofile_stream = new OFileStream(filepath);
data->mpofile = new MultiPartOutputFile(*(data->ofile_stream), &headers[0], headers.size());
}
catch (const std::exception &) {
@ -954,19 +954,19 @@ void IMB_exrtile_begin_write(
}
bool IMB_exr_begin_read(
void *handle, const char *filename, int *width, int *height, const bool parse_channels)
void *handle, const char *filepath, int *width, int *height, const bool parse_channels)
{
ExrHandle *data = (ExrHandle *)handle;
ExrChannel *echan;
/* 32 is arbitrary, but zero length files crashes exr. */
if (!(BLI_exists(filename) && BLI_file_size(filename) > 32)) {
if (!(BLI_exists(filepath) && BLI_file_size(filepath) > 32)) {
return false;
}
/* avoid crash/abort when we don't have permission to write here */
try {
data->ifile_stream = new IFileStream(filename);
data->ifile_stream = new IFileStream(filepath);
data->ifile = new MultiPartInputFile(*(data->ifile_stream));
}
catch (const std::exception &) {

View File

@ -29,7 +29,7 @@ void IMB_exr_add_channel(void * /*handle*/,
}
bool IMB_exr_begin_read(void * /*handle*/,
const char * /*filename*/,
const char * /*filepath*/,
int * /*width*/,
int * /*height*/,
const bool /*add_channels*/)
@ -37,7 +37,7 @@ bool IMB_exr_begin_read(void * /*handle*/,
return false;
}
bool IMB_exr_begin_write(void * /*handle*/,
const char * /*filename*/,
const char * /*filepath*/,
int /*width*/,
int /*height*/,
int /*compress*/,
@ -46,7 +46,7 @@ bool IMB_exr_begin_write(void * /*handle*/,
return false;
}
void IMB_exrtile_begin_write(void * /*handle*/,
const char * /*filename*/,
const char * /*filepath*/,
int /*mipmap*/,
int /*width*/,
int /*height*/,

View File

@ -72,11 +72,11 @@ typedef enum eGpencilExportFrame {
/**
* Main export entry point function.
*/
bool gpencil_io_export(const char *filename, struct GpencilIOParams *iparams);
bool gpencil_io_export(const char *filepath, struct GpencilIOParams *iparams);
/**
* Main import entry point function.
*/
bool gpencil_io_import(const char *filename, struct GpencilIOParams *iparams);
bool gpencil_io_import(const char *filepath, struct GpencilIOParams *iparams);
#ifdef __cplusplus
}

View File

@ -174,10 +174,10 @@ void GpencilIO::create_object_list()
});
}
void GpencilIO::filename_set(const char *filename)
void GpencilIO::filepath_set(const char *filepath)
{
BLI_strncpy(filename_, filename, FILE_MAX);
BLI_path_abs(filename_, BKE_main_blendfile_path(bmain_));
BLI_strncpy(filepath_, filepath, FILE_MAX);
BLI_path_abs(filepath_, BKE_main_blendfile_path(bmain_));
}
bool GpencilIO::gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co)

View File

@ -40,7 +40,7 @@ class GpencilIO {
bool invert_axis_[2];
float4x4 diff_mat_;
char filename_[FILE_MAX];
char filepath_[FILE_MAX];
/* Used for sorting objects. */
struct ObjectZ {
@ -94,9 +94,9 @@ class GpencilIO {
void selected_objects_boundbox_get(rctf *boundbox);
/**
* Set file input_text full path.
* \param filename: Path of the file provided by save dialog.
* \param filepath: Path of the file provided by save dialog.
*/
void filename_set(const char *filename);
void filepath_set(const char *filepath);
private:
float avg_opacity_;

View File

@ -161,32 +161,32 @@ static bool gpencil_io_export_frame_svg(GpencilExporterSVG *exporter,
}
#endif
bool gpencil_io_import(const char *filename, GpencilIOParams *iparams)
bool gpencil_io_import(const char *filepath, GpencilIOParams *iparams)
{
GpencilImporterSVG importer = GpencilImporterSVG(filename, iparams);
GpencilImporterSVG importer = GpencilImporterSVG(filepath, iparams);
return gpencil_io_import_frame(&importer, *iparams);
}
bool gpencil_io_export(const char *filename, GpencilIOParams *iparams)
bool gpencil_io_export(const char *filepath, GpencilIOParams *iparams)
{
Depsgraph *depsgraph_ = CTX_data_depsgraph_pointer(iparams->C);
Scene *scene_ = CTX_data_scene(iparams->C);
Object *ob = CTX_data_active_object(iparams->C);
UNUSED_VARS(filename, depsgraph_, scene_, ob);
UNUSED_VARS(filepath, depsgraph_, scene_, ob);
switch (iparams->mode) {
#ifdef WITH_PUGIXML
case GP_EXPORT_TO_SVG: {
GpencilExporterSVG exporter = GpencilExporterSVG(filename, iparams);
GpencilExporterSVG exporter = GpencilExporterSVG(filepath, iparams);
return gpencil_io_export_frame_svg(&exporter, scene_, iparams, true, true, true);
break;
}
#endif
#ifdef WITH_HARU
case GP_EXPORT_TO_PDF: {
GpencilExporterPDF exporter = GpencilExporterPDF(filename, iparams);
GpencilExporterPDF exporter = GpencilExporterPDF(filepath, iparams);
return gpencil_io_export_pdf(depsgraph_, scene_, ob, &exporter, iparams);
break;
}

View File

@ -43,10 +43,10 @@ static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *UNU
}
/* Constructor. */
GpencilExporterPDF::GpencilExporterPDF(const char *filename, const GpencilIOParams *iparams)
GpencilExporterPDF::GpencilExporterPDF(const char *filepath, const GpencilIOParams *iparams)
: GpencilExporter(iparams)
{
filename_set(filename);
filepath_set(filepath);
invert_axis_[0] = false;
invert_axis_[1] = false;
@ -78,16 +78,16 @@ bool GpencilExporterPDF::write()
/* TODO: It looks `libharu` does not support unicode. */
#if 0 /* `ifdef WIN32` */
char filename_cstr[FILE_MAX];
BLI_strncpy(filename_cstr, filename_, FILE_MAX);
char filepath_cstr[FILE_MAX];
BLI_strncpy(filepath_cstr, filepath_, FILE_MAX);
UTF16_ENCODE(filename_cstr);
std::wstring wstr(filename_cstr_16);
UTF16_ENCODE(filepath_cstr);
std::wstring wstr(filepath_cstr_16);
res = HPDF_SaveToFile(pdf_, wstr.c_str());
UTF16_UN_ENCODE(filename_cstr);
UTF16_UN_ENCODE(filepath_cstr);
#else
res = HPDF_SaveToFile(pdf_, filename_);
res = HPDF_SaveToFile(pdf_, filepath_);
#endif
return (res == 0) ? true : false;

View File

@ -21,7 +21,7 @@ namespace blender::io::gpencil {
class GpencilExporterPDF : public GpencilExporter {
public:
GpencilExporterPDF(const char *filename, const struct GpencilIOParams *iparams);
GpencilExporterPDF(const char *filepath, const struct GpencilIOParams *iparams);
bool new_document();
bool add_newpage();
bool add_body();

View File

@ -40,10 +40,10 @@
namespace blender ::io ::gpencil {
/* Constructor. */
GpencilExporterSVG::GpencilExporterSVG(const char *filename, const GpencilIOParams *iparams)
GpencilExporterSVG::GpencilExporterSVG(const char *filepath, const GpencilIOParams *iparams)
: GpencilExporter(iparams)
{
filename_set(filename);
filepath_set(filepath);
invert_axis_[0] = false;
invert_axis_[1] = true;
@ -66,16 +66,16 @@ bool GpencilExporterSVG::write()
bool result = true;
/* Support unicode character paths on Windows. */
#ifdef WIN32
char filename_cstr[FILE_MAX];
BLI_strncpy(filename_cstr, filename_, FILE_MAX);
char filepath_cstr[FILE_MAX];
BLI_strncpy(filepath_cstr, filepath_, FILE_MAX);
UTF16_ENCODE(filename_cstr);
std::wstring wstr(filename_cstr_16);
UTF16_ENCODE(filepath_cstr);
std::wstring wstr(filepath_cstr_16);
result = main_doc_.save_file(wstr.c_str());
UTF16_UN_ENCODE(filename_cstr);
UTF16_UN_ENCODE(filepath_cstr);
#else
result = main_doc_.save_file(filename_);
result = main_doc_.save_file(filepath_);
#endif
return result;

View File

@ -20,7 +20,7 @@ namespace blender::io::gpencil {
class GpencilExporterSVG : public GpencilExporter {
public:
GpencilExporterSVG(const char *filename, const struct GpencilIOParams *iparams);
GpencilExporterSVG(const char *filepath, const struct GpencilIOParams *iparams);
bool add_newpage();
bool add_body();
bool write();

View File

@ -33,17 +33,17 @@ using blender::MutableSpan;
namespace blender::io::gpencil {
/* Constructor. */
GpencilImporterSVG::GpencilImporterSVG(const char *filename, const GpencilIOParams *iparams)
GpencilImporterSVG::GpencilImporterSVG(const char *filepath, const GpencilIOParams *iparams)
: GpencilImporter(iparams)
{
filename_set(filename);
filepath_set(filepath);
}
bool GpencilImporterSVG::read()
{
bool result = true;
NSVGimage *svg_data = nullptr;
svg_data = nsvgParseFromFile(filename_, "mm", 96.0f);
svg_data = nsvgParseFromFile(filepath_, "mm", 96.0f);
if (svg_data == nullptr) {
std::cout << " Could not open SVG.\n ";
return false;

View File

@ -21,7 +21,7 @@ namespace blender::io::gpencil {
class GpencilImporterSVG : public GpencilImporter {
public:
GpencilImporterSVG(const char *filename, const struct GpencilIOParams *iparams);
GpencilImporterSVG(const char *filepath, const struct GpencilIOParams *iparams);
bool read();

View File

@ -102,14 +102,14 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
if (ibuf) {
char filename[FILE_MAX];
BLI_strncpy(filename, image->filepath, sizeof(filename));
BLI_path_abs(filename, ID_BLEND_PATH(bmain, &image->id));
char filepath[FILE_MAX];
BLI_strncpy(filepath, image->filepath, sizeof(filepath));
BLI_path_abs(filepath, ID_BLEND_PATH(bmain, &image->id));
/* NOTE: we purposefully ignore packed files here,
* developers need to explicitly write them via 'packed_files' */
if (IMB_saveiff(ibuf, filename, ibuf->flags)) {
if (IMB_saveiff(ibuf, filepath, ibuf->flags)) {
image->type = IMA_TYPE_IMAGE;
if (image->source == IMA_SRC_GENERATED) {

View File

@ -25,7 +25,7 @@
#ifdef RNA_RUNTIME
static void rna_Text_filename_get(PointerRNA *ptr, char *value)
static void rna_Text_filepath_get(PointerRNA *ptr, char *value)
{
Text *text = (Text *)ptr->data;
@ -37,13 +37,13 @@ static void rna_Text_filename_get(PointerRNA *ptr, char *value)
}
}
static int rna_Text_filename_length(PointerRNA *ptr)
static int rna_Text_filepath_length(PointerRNA *ptr)
{
Text *text = (Text *)ptr->data;
return (text->filepath) ? strlen(text->filepath) : 0;
}
static void rna_Text_filename_set(PointerRNA *ptr, const char *value)
static void rna_Text_filepath_set(PointerRNA *ptr, const char *value)
{
Text *text = (Text *)ptr->data;
@ -204,7 +204,7 @@ static void rna_def_text(BlenderRNA *brna)
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(
prop, "rna_Text_filename_get", "rna_Text_filename_length", "rna_Text_filename_set");
prop, "rna_Text_filepath_get", "rna_Text_filepath_length", "rna_Text_filepath_set");
RNA_def_property_ui_text(prop, "File Path", "Filename of the text file");
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);

View File

@ -396,41 +396,41 @@ static PyObject *py_blf_shadow_offset(PyObject *UNUSED(self), PyObject *args)
}
PyDoc_STRVAR(py_blf_load_doc,
".. function:: load(filename)\n"
".. function:: load(filepath)\n"
"\n"
" Load a new font.\n"
"\n"
" :arg filename: the filename of the font.\n"
" :type filename: string\n"
" :arg filepath: the filepath of the font.\n"
" :type filepath: string\n"
" :return: the new font's fontid or -1 if there was an error.\n"
" :rtype: integer\n");
static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
{
const char *filename;
const char *filepath;
if (!PyArg_ParseTuple(args, "s:blf.load", &filename)) {
if (!PyArg_ParseTuple(args, "s:blf.load", &filepath)) {
return NULL;
}
return PyLong_FromLong(BLF_load(filename));
return PyLong_FromLong(BLF_load(filepath));
}
PyDoc_STRVAR(py_blf_unload_doc,
".. function:: unload(filename)\n"
".. function:: unload(filepath)\n"
"\n"
" Unload an existing font.\n"
"\n"
" :arg filename: the filename of the font.\n"
" :type filename: string\n");
" :arg filepath: the filepath of the font.\n"
" :type filepath: string\n");
static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args)
{
const char *filename;
const char *filepath;
if (!PyArg_ParseTuple(args, "s:blf.unload", &filename)) {
if (!PyArg_ParseTuple(args, "s:blf.unload", &filepath)) {
return NULL;
}
BLF_unload(filename);
BLF_unload(filepath);
Py_RETURN_NONE;
}

View File

@ -169,10 +169,10 @@ void RE_engine_free(RenderEngine *engine);
* x/y offsets are only used on a partial copy when dimensions don't match.
*/
void RE_layer_load_from_file(
struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y);
struct RenderLayer *layer, struct ReportList *reports, const char *filepath, int x, int y);
void RE_result_load_from_file(struct RenderResult *result,
struct ReportList *reports,
const char *filename);
const char *filepath);
struct RenderResult *RE_engine_begin_result(
RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname);

View File

@ -2480,10 +2480,10 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
}
void RE_layer_load_from_file(
RenderLayer *layer, ReportList *reports, const char *filename, int x, int y)
RenderLayer *layer, ReportList *reports, const char *filepath, int x, int y)
{
/* OCIO_TODO: assume layer was saved in default color space */
ImBuf *ibuf = IMB_loadiffname(filename, IB_rect, NULL);
ImBuf *ibuf = IMB_loadiffname(filepath, IB_rect, NULL);
RenderPass *rpass = NULL;
/* multiview: since the API takes no 'view', we use the first combined pass found */
@ -2498,7 +2498,7 @@ void RE_layer_load_from_file(
RPT_ERROR,
"%s: no Combined pass found in the render layer '%s'",
__func__,
filename);
filepath);
}
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
@ -2527,7 +2527,7 @@ void RE_layer_load_from_file(
}
else {
BKE_reportf(
reports, RPT_ERROR, "%s: failed to allocate clip buffer '%s'", __func__, filename);
reports, RPT_ERROR, "%s: failed to allocate clip buffer '%s'", __func__, filepath);
}
}
else {
@ -2535,21 +2535,21 @@ void RE_layer_load_from_file(
RPT_ERROR,
"%s: incorrect dimensions for partial copy '%s'",
__func__,
filename);
filepath);
}
}
IMB_freeImBuf(ibuf);
}
else {
BKE_reportf(reports, RPT_ERROR, "%s: failed to load '%s'", __func__, filename);
BKE_reportf(reports, RPT_ERROR, "%s: failed to load '%s'", __func__, filepath);
}
}
void RE_result_load_from_file(RenderResult *result, ReportList *reports, const char *filename)
void RE_result_load_from_file(RenderResult *result, ReportList *reports, const char *filepath)
{
if (!render_result_exr_file_read_path(result, NULL, filename)) {
BKE_reportf(reports, RPT_ERROR, "%s: failed to load '%s'", __func__, filename);
if (!render_result_exr_file_read_path(result, NULL, filepath)) {
BKE_reportf(reports, RPT_ERROR, "%s: failed to load '%s'", __func__, filepath);
return;
}
}

View File

@ -1999,20 +1999,20 @@ void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer *UNUSED(wt))
void wm_autosave_delete(void)
{
char filename[FILE_MAX];
char filepath[FILE_MAX];
wm_autosave_location(filename);
wm_autosave_location(filepath);
if (BLI_exists(filename)) {
if (BLI_exists(filepath)) {
char str[FILE_MAX];
BLI_join_dirfile(str, sizeof(str), BKE_tempdir_base(), BLENDER_QUIT_FILE);
/* if global undo; remove tempsave, otherwise rename */
if (U.uiflag & USER_GLOBALUNDO) {
BLI_delete(filename, false, false);
BLI_delete(filepath, false, false);
}
else {
BLI_rename(filename, str);
BLI_rename(filepath, str);
}
}
}
@ -2959,10 +2959,10 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op)
static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
char filename[FILE_MAX];
char filepath[FILE_MAX];
wm_autosave_location(filename);
RNA_string_set(op->ptr, "filepath", filename);
wm_autosave_location(filepath);
RNA_string_set(op->ptr, "filepath", filepath);
wm_open_init_use_scripts(op, true);
WM_event_add_fileselect(C, op);

View File

@ -440,19 +440,19 @@ void WM_exit_ex(bContext *C, const bool do_python)
if (undo_memfile != NULL) {
/* save the undo state as quit.blend */
Main *bmain = CTX_data_main(C);
char filename[FILE_MAX];
char filepath[FILE_MAX];
bool has_edited;
const int fileflags = G.fileflags & ~G_FILE_COMPRESS;
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_base(), BLENDER_QUIT_FILE);
BLI_join_dirfile(filepath, sizeof(filepath), BKE_tempdir_base(), BLENDER_QUIT_FILE);
has_edited = ED_editors_flush_edits(bmain);
if ((has_edited &&
BLO_write_file(
bmain, filename, fileflags, &(const struct BlendFileWriteParams){0}, NULL)) ||
(BLO_memfile_write_file(undo_memfile, filename))) {
printf("Saved session recovery to '%s'\n", filename);
bmain, filepath, fileflags, &(const struct BlendFileWriteParams){0}, NULL)) ||
(BLO_memfile_write_file(undo_memfile, filepath))) {
printf("Saved session recovery to '%s'\n", filepath);
}
}
}

View File

@ -828,7 +828,7 @@ static int arg_handle_log_show_timestamp_set(int UNUSED(argc),
}
static const char arg_handle_log_file_set_doc[] =
"<filename>\n"
"<filepath>\n"
"\tSet a file to output the log to.";
static int arg_handle_log_file_set(int argc, const char **argv, void *UNUSED(data))
{
@ -1752,7 +1752,7 @@ static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
}
static const char arg_handle_python_file_run_doc[] =
"<filename>\n"
"<filepath>\n"
"\tRun the given Python script file.";
static int arg_handle_python_file_run(int argc, const char **argv, void *data)
{
@ -1762,12 +1762,12 @@ static int arg_handle_python_file_run(int argc, const char **argv, void *data)
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
if (argc > 1) {
/* Make the path absolute because its needed for relative linked blends to be found */
char filename[FILE_MAX];
BLI_strncpy(filename, argv[1], sizeof(filename));
BLI_path_abs_from_cwd(filename, sizeof(filename));
char filepath[FILE_MAX];
BLI_strncpy(filepath, argv[1], sizeof(filepath));
BLI_path_abs_from_cwd(filepath, sizeof(filepath));
bool ok;
BPY_CTX_SETUP(ok = BPY_run_filepath(C, filename, NULL));
BPY_CTX_SETUP(ok = BPY_run_filepath(C, filepath, NULL));
if (!ok && app_state.exit_code_on_error.python) {
printf("\nError: script failed, file: '%s', exiting.\n", argv[1]);
BPY_python_end();
@ -1952,22 +1952,22 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
bool success;
/* Make the path absolute because its needed for relative linked blends to be found */
char filename[FILE_MAX];
char filepath[FILE_MAX];
/* NOTE: we could skip these, but so far we always tried to load these files. */
if (argv[0][0] == '-') {
fprintf(stderr, "unknown argument, loading as file: %s\n", argv[0]);
}
BLI_strncpy(filename, argv[0], sizeof(filename));
BLI_path_slash_native(filename);
BLI_path_abs_from_cwd(filename, sizeof(filename));
BLI_path_normalize(NULL, filename);
BLI_strncpy(filepath, argv[0], sizeof(filepath));
BLI_path_slash_native(filepath);
BLI_path_abs_from_cwd(filepath, sizeof(filepath));
BLI_path_normalize(NULL, filepath);
/* load the file */
BKE_reports_init(&reports, RPT_PRINT);
WM_file_autoexec_init(filename);
success = WM_file_read(C, filename, &reports);
WM_file_autoexec_init(filepath);
success = WM_file_read(C, filepath, &reports);
BKE_reports_clear(&reports);
if (success) {
@ -1988,16 +1988,16 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
return -1;
}
if (BLO_has_bfile_extension(filename)) {
if (BLO_has_bfile_extension(filepath)) {
/* Just pretend a file was loaded, so the user can press Save and it'll
* save at the filename from the CLI. */
STRNCPY(G_MAIN->filepath, filename);
printf("... opened default scene instead; saving will write to: %s\n", filename);
* save at the filepath from the CLI. */
STRNCPY(G_MAIN->filepath, filepath);
printf("... opened default scene instead; saving will write to: %s\n", filepath);
}
else {
printf(
"Error: argument has no '.blend' file extension, not using as new file, exiting! %s\n",
filename);
filepath);
G.is_break = true;
WM_exit(C);
}