Cleanup: BLI path extension API

Use BLI_path_extension_* prefix.
This commit is contained in:
Campbell Barton 2018-06-17 16:13:24 +02:00
parent 6453814ec0
commit a0a1fc8938
26 changed files with 87 additions and 87 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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_path_extension_check(const char *str, const char *ext)
{
return testextensie_ex(str, strlen(str), ext, strlen(ext));
return path_extension_check_ex(str, strlen(str), ext, strlen(ext));
}
bool BLI_testextensie_n(const char *str, ...)
bool BLI_path_extension_check_n(const char *str, ...)
{
const size_t str_len = strlen(str);
@ -1380,7 +1380,7 @@ bool BLI_testextensie_n(const char *str, ...)
va_start(args, str);
while ((ext = (const char *) va_arg(args, void *))) {
if (testextensie_ex(str, str_len, ext, strlen(ext))) {
if (path_extension_check_ex(str, str_len, ext, strlen(ext))) {
ret = true;
break;
}
@ -1392,13 +1392,13 @@ bool BLI_testextensie_n(const char *str, ...)
}
/* does str end with any of the suffixes in *ext_array. */
bool BLI_testextensie_array(const char *str, const char **ext_array)
bool BLI_path_extension_check_array(const char *str, const char **ext_array)
{
const size_t str_len = strlen(str);
int i = 0;
while (ext_array[i]) {
if (testextensie_ex(str, str_len, ext_array[i], strlen(ext_array[i]))) {
if (path_extension_check_ex(str, str_len, ext_array[i], strlen(ext_array[i]))) {
return true;
}
@ -1412,7 +1412,7 @@ bool BLI_testextensie_array(const char *str, const char **ext_array)
* '*.zip;*.py;*.exe'
* does str match any of the semicolon-separated glob patterns in fnmatch.
*/
bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
bool BLI_path_extension_check_glob(const char *str, const char *ext_fnmatch)
{
const char *ext_step = ext_fnmatch;
char pattern[16];
@ -1443,7 +1443,7 @@ bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
* Removes any existing extension on the end of \a path and appends \a ext.
* \return false if there was no room.
*/
bool BLI_replace_extension(char *path, size_t maxlen, const char *ext)
bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext)
{
#ifdef DEBUG_STRSIZE
memset(path, 0xff, sizeof(*path) * maxlen);
@ -1472,7 +1472,7 @@ bool BLI_replace_extension(char *path, size_t maxlen, const char *ext)
/**
* Strip's trailing '.'s and adds the extension only when needed
*/
bool BLI_ensure_extension(char *path, size_t maxlen, const char *ext)
bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext)
{
#ifdef DEBUG_STRSIZE
memset(path, 0xff, sizeof(*path) * maxlen);

View File

@ -1356,7 +1356,7 @@ void blo_freefiledata(FileData *fd)
bool BLO_has_bfile_extension(const char *str)
{
const char *ext_test[4] = {".blend", ".ble", ".blend.gz", NULL};
return BLI_testextensie_array(str, ext_test);
return BLI_path_extension_check_array(str, ext_test);
}
/**

View File

@ -169,7 +169,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
BLI_make_file_string(NULL, tempfile, tempdir, name);
if (extension) {
BLI_ensure_extension(tempfile, FILE_MAX, extension);
BLI_path_extension_ensure(tempfile, FILE_MAX, extension);
}
COLLADABU::NativeString native_filename =

View File

@ -612,7 +612,7 @@ static void init_iconfile_list(struct ListBase *list)
if ((dir[i].type & S_IFREG)) {
const char *filename = dir[i].relname;
if (BLI_testextensie(filename, ".png")) {
if (BLI_path_extension_check(filename, ".png")) {
/* loading all icons on file start is overkill & slows startup
* its possible they change size after blender load anyway. */
#if 0

View File

@ -86,7 +86,7 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
}
BLI_replace_extension(filepath, sizeof(filepath), ".abc");
BLI_path_extension_replace(filepath, sizeof(filepath), ".abc");
RNA_string_set(op->ptr, "filepath", filepath);
}
@ -284,8 +284,8 @@ static bool wm_alembic_export_check(bContext *UNUSED(C), wmOperator *op)
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
if (!BLI_testextensie(filepath, ".abc")) {
BLI_ensure_extension(filepath, FILE_MAX, ".abc");
if (!BLI_path_extension_check(filepath, ".abc")) {
BLI_path_extension_ensure(filepath, FILE_MAX, ".abc");
RNA_string_set(op->ptr, "filepath", filepath);
return true;
}

View File

@ -61,7 +61,7 @@ static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *eve
Main *bmain = CTX_data_main(C);
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ".abc");
BLI_path_extension_replace(filepath, sizeof(filepath), ".abc");
RNA_string_set(op->ptr, "filepath", filepath);
}

View File

@ -71,7 +71,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
else
BLI_strncpy(filepath, blendfile_path, sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ".dae");
BLI_path_extension_replace(filepath, sizeof(filepath), ".dae");
RNA_string_set(op->ptr, "filepath", filepath);
}
@ -118,7 +118,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
}
RNA_string_get(op->ptr, "filepath", filepath);
BLI_ensure_extension(filepath, sizeof(filepath), ".dae");
BLI_path_extension_ensure(filepath, sizeof(filepath), ".dae");
/* Avoid File write exceptions in Collada */
@ -336,8 +336,8 @@ static bool wm_collada_export_check(bContext *UNUSED(C), wmOperator *op)
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
if (!BLI_testextensie(filepath, ".dae")) {
BLI_ensure_extension(filepath, FILE_MAX, ".dae");
if (!BLI_path_extension_check(filepath, ".dae")) {
BLI_path_extension_ensure(filepath, FILE_MAX, ".dae");
RNA_string_set(op->ptr, "filepath", filepath);
return true;
}

View File

@ -232,7 +232,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
char filepath[FILE_MAX] = "//screen";
if (G.relbase_valid) {
BLI_strncpy(filepath, BKE_main_blendfile_path_from_global(), sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ""); /* strip '.blend' */
BLI_path_extension_replace(filepath, sizeof(filepath), ""); /* strip '.blend' */
}
RNA_string_set(op->ptr, "filepath", filepath);

View File

@ -454,10 +454,10 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "filepath");
RNA_property_string_get(op->ptr, prop, filepath);
if (BLI_testextensie_array(filepath, snd_ext_sound))
check = BLI_replace_extension(filepath, FILE_MAX, extension);
if (BLI_path_extension_check_array(filepath, snd_ext_sound))
check = BLI_path_extension_replace(filepath, FILE_MAX, extension);
else
check = BLI_ensure_extension(filepath, FILE_MAX, extension);
check = BLI_path_extension_ensure(filepath, FILE_MAX, extension);
if (!check)
return check;

View File

@ -1973,31 +1973,31 @@ int ED_path_extension_type(const char *path)
else if (file_is_blend_backup(path)) {
return FILE_TYPE_BLENDER_BACKUP;
}
else if (BLI_testextensie(path, ".app")) {
else if (BLI_path_extension_check(path, ".app")) {
return FILE_TYPE_APPLICATIONBUNDLE;
}
else if (BLI_testextensie(path, ".py")) {
else if (BLI_path_extension_check(path, ".py")) {
return FILE_TYPE_PYSCRIPT;
}
else if (BLI_testextensie_n(path, ".txt", ".glsl", ".osl", ".data", ".pov", ".ini", ".mcr", ".inc", NULL)) {
else if (BLI_path_extension_check_n(path, ".txt", ".glsl", ".osl", ".data", ".pov", ".ini", ".mcr", ".inc", NULL)) {
return FILE_TYPE_TEXT;
}
else if (BLI_testextensie_n(path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", NULL)) {
else if (BLI_path_extension_check_n(path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", NULL)) {
return FILE_TYPE_FTFONT;
}
else if (BLI_testextensie(path, ".btx")) {
else if (BLI_path_extension_check(path, ".btx")) {
return FILE_TYPE_BTX;
}
else if (BLI_testextensie(path, ".dae")) {
else if (BLI_path_extension_check(path, ".dae")) {
return FILE_TYPE_COLLADA;
}
else if (BLI_testextensie(path, ".abc")) {
else if (BLI_path_extension_check(path, ".abc")) {
return FILE_TYPE_ALEMBIC;
}
else if (BLI_testextensie_array(path, imb_ext_image)) {
else if (BLI_path_extension_check_array(path, imb_ext_image)) {
return FILE_TYPE_IMAGE;
}
else if (BLI_testextensie(path, ".ogg")) {
else if (BLI_path_extension_check(path, ".ogg")) {
if (IMB_isanim(path)) {
return FILE_TYPE_MOVIE;
}
@ -2005,10 +2005,10 @@ int ED_path_extension_type(const char *path)
return FILE_TYPE_SOUND;
}
}
else if (BLI_testextensie_array(path, imb_ext_movie)) {
else if (BLI_path_extension_check_array(path, imb_ext_movie)) {
return FILE_TYPE_MOVIE;
}
else if (BLI_testextensie_array(path, imb_ext_audio)) {
else if (BLI_path_extension_check_array(path, imb_ext_audio)) {
return FILE_TYPE_SOUND;
}
return 0;
@ -2233,7 +2233,7 @@ static int filelist_readjob_list_dir(
/* Otherwise, do not check extensions for directories! */
else if (!(entry->typeflag & FILE_TYPE_DIR)) {
entry->typeflag = file_extension_type(root, entry->relpath);
if (filter_glob[0] && BLI_testextensie_glob(entry->relpath, filter_glob)) {
if (filter_glob[0] && BLI_path_extension_check_glob(entry->relpath, filter_glob)) {
entry->typeflag |= FILE_TYPE_OPERATOR;
}
}

View File

@ -1532,7 +1532,7 @@ static int image_replace_exec(bContext *C, wmOperator *op)
BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
}
if (BLI_testextensie_array(str, imb_ext_movie))
if (BLI_path_extension_check_array(str, imb_ext_movie))
sima->image->source = IMA_SRC_MOVIE;
else
sima->image->source = IMA_SRC_FILE;

View File

@ -3894,7 +3894,7 @@ static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const
else
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
BLI_replace_extension(filepath, sizeof(filepath), ".srt");
BLI_path_extension_replace(filepath, sizeof(filepath), ".srt");
RNA_string_set(op->ptr, "filepath", filepath);
}
@ -3919,7 +3919,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
}
RNA_string_get(op->ptr, "filepath", filepath);
BLI_ensure_extension(filepath, sizeof(filepath), ".srt");
BLI_path_extension_ensure(filepath, sizeof(filepath), ".srt");
/* Avoid File write exceptions */
if (!BLI_exists(filepath)) {

View File

@ -928,7 +928,7 @@ Render *Controller::RenderStrokes(Render *re, bool render)
void Controller::InsertStyleModule(unsigned index, const char *iFileName)
{
if (!BLI_testextensie(iFileName, ".py")) {
if (!BLI_path_extension_check(iFileName, ".py")) {
cerr << "Error: Cannot load \"" << string(iFileName) << "\", unknown extension" << endl;
return;
}

View File

@ -179,7 +179,7 @@ int imb_is_a_photoshop(const char *filename)
NULL
};
return BLI_testextensie_array(filename, photoshop_extension);
return BLI_path_extension_check_array(filename, photoshop_extension);
}
int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags)

View File

@ -159,7 +159,7 @@ static ImBuf *IMB_ibImageFromFile(const char *filepath, int flags, char colorspa
static bool imb_is_filepath_format(const char *filepath)
{
/* return true if this is one of the formats that can't be loaded from memory */
return BLI_testextensie_array(filepath, imb_ext_image_filepath_only);
return BLI_path_extension_check_array(filepath, imb_ext_image_filepath_only);
}
ImBuf *IMB_loadifffile(int file, const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
@ -199,7 +199,7 @@ static void imb_cache_filename(char *filename, const char *name, int flags)
/* read .tx instead if it exists and is not older */
if (flags & IB_tilecache) {
BLI_strncpy(filename, name, IMB_FILENAME_SIZE);
if (!BLI_replace_extension(filename, IMB_FILENAME_SIZE, ".tx"))
if (!BLI_path_extension_replace(filename, IMB_FILENAME_SIZE, ".tx"))
return;
if (BLI_file_older(name, filename))

View File

@ -281,7 +281,7 @@ static int isffmpeg(const char *filename)
AVCodec *pCodec;
AVCodecContext *pCodecCtx;
if (BLI_testextensie_n(
if (BLI_path_extension_check_n(
filename,
".swf", ".jpg", ".png", ".dds", ".tga", ".bmp", ".tif", ".exr", ".cin", ".wav", NULL))
{

View File

@ -723,7 +723,7 @@ void BPY_modules_load_user(bContext *C)
bpy_context_set(C, &gilstate);
for (text = bmain->text.first; text; text = text->id.next) {
if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name + 2, ".py")) {
if (text->flags & TXT_ISSCRIPT && BLI_path_extension_check(text->id.name + 2, ".py")) {
if (!(G.f & G_SCRIPT_AUTOEXEC)) {
if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
G.f |= G_SCRIPT_AUTOEXEC_FAIL;

View File

@ -3409,7 +3409,7 @@ bool RE_WriteRenderViewsImage(ReportList *reports, RenderResult *rr, Scene *scen
ImageFormatData imf = rd->im_format;
imf.imtype = R_IMF_IMTYPE_JPEG90;
if (BLI_testextensie(name, ".exr"))
if (BLI_path_extension_check(name, ".exr"))
name[strlen(name) - 4] = 0;
BKE_image_path_ensure_ext_from_imformat(name, &imf);
@ -3464,7 +3464,7 @@ bool RE_WriteRenderViewsImage(ReportList *reports, RenderResult *rr, Scene *scen
ImageFormatData imf = rd->im_format;
imf.imtype = R_IMF_IMTYPE_JPEG90;
if (BLI_testextensie(name, ".exr"))
if (BLI_path_extension_check(name, ".exr"))
name[strlen(name) - 4] = 0;
BKE_image_path_ensure_ext_from_imformat(name, &imf);

View File

@ -1257,7 +1257,7 @@ static void render_result_exr_file_cache_path(Scene *sce, const char *root, char
const char *blendfile_path = BKE_main_blendfile_path_from_global();
if (blendfile_path[0] != '\0') {
BLI_split_dirfile(blendfile_path, dirname, filename, sizeof(dirname), sizeof(filename));
BLI_replace_extension(filename, sizeof(filename), ""); /* strip '.blend' */
BLI_path_extension_replace(filename, sizeof(filename), ""); /* strip '.blend' */
BLI_hash_md5_buffer(blendfile_path, strlen(blendfile_path), path_digest);
}
else {

View File

@ -1087,7 +1087,7 @@ bool write_crash_blend(void)
int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on crash file */
BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path));
BLI_replace_extension(path, sizeof(path), "_crash.blend");
BLI_path_extension_replace(path, sizeof(path), "_crash.blend");
if (BLO_write_file(G_MAIN, path, fileflags, NULL, NULL)) {
printf("written: %s\n", path);
return 1;
@ -2116,9 +2116,9 @@ static bool blend_save_check(bContext *UNUSED(C), wmOperator *op)
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
if (!BLO_has_bfile_extension(filepath)) {
/* some users would prefer BLI_replace_extension(),
/* some users would prefer BLI_path_extension_replace(),
* we keep getting nitpicking bug reports about this - campbell */
BLI_ensure_extension(filepath, FILE_MAX, ".blend");
BLI_path_extension_ensure(filepath, FILE_MAX, ".blend");
RNA_string_set(op->ptr, "filepath", filepath);
return true;
}

View File

@ -130,7 +130,7 @@ static void sig_handle_crash(int signum)
}
else {
BLI_strncpy(fname, G_MAIN->name, sizeof(fname));
BLI_replace_extension(fname, sizeof(fname), ".crash.blend");
BLI_path_extension_replace(fname, sizeof(fname), ".crash.blend");
}
printf("Writing: %s\n", fname);
@ -151,7 +151,7 @@ static void sig_handle_crash(int signum)
}
else {
BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G_MAIN->name));
BLI_replace_extension(fname, sizeof(fname), ".crash.txt");
BLI_path_extension_replace(fname, sizeof(fname), ".crash.txt");
}
printf("Writing: %s\n", fname);

View File

@ -650,7 +650,7 @@ static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args)
}
while ((dirp = readdir(dp)) != NULL) {
if (BLI_testextensie(dirp->d_name, ".blend")) {
if (BLI_path_extension_check(dirp->d_name, ".blend")) {
value = PyC_UnicodeFromByte(dirp->d_name);
PyList_Append(list, value);
Py_DECREF(value);
@ -2926,7 +2926,7 @@ void pathGamePythonConfig(char *path)
BLI_strncpy(path, gp_GamePythonPathOrig, sizeof(gp_GamePythonPathOrig));
/* replace extension */
if (BLI_testextensie(path, ".blend")) {
if (BLI_path_extension_check(path, ".blend")) {
strcpy(path+(len-6), ".bgeconf");
} else {
strcpy(path+len, ".bgeconf");