Blender  V2.93
Functions
path_util.c File Reference
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "DNA_listBase.h"
#include "BLI_fileops.h"
#include "BLI_fnmatch.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "unistd.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

Functions

int BLI_path_sequence_decode (const char *string, char *head, char *tail, ushort *r_num_len)
 
void BLI_path_sequence_encode (char *string, const char *head, const char *tail, unsigned short numlen, int pic)
 
static int BLI_path_unc_prefix_len (const char *path)
 
void BLI_path_normalize (const char *relabase, char *path)
 
void BLI_path_normalize_dir (const char *relabase, char *dir)
 
bool BLI_filename_make_safe (char *fname)
 
bool BLI_path_make_safe (char *path)
 
bool BLI_path_is_rel (const char *path)
 
bool BLI_path_is_unc (const char *name)
 
void BLI_path_rel (char *file, const char *relfile)
 
bool BLI_path_suffix (char *string, size_t maxlen, const char *suffix, const char *sep)
 
bool BLI_path_parent_dir (char *path)
 
bool BLI_path_parent_dir_until_exists (char *dir)
 
static bool stringframe_chars (const char *path, int *char_start, int *char_end)
 
static void ensure_digits (char *path, int digits)
 
bool BLI_path_frame (char *path, int frame, int digits)
 
bool BLI_path_frame_range (char *path, int sta, int end, int digits)
 
bool BLI_path_frame_get (char *path, int *r_frame, int *r_numdigits)
 
void BLI_path_frame_strip (char *path, char *r_ext)
 
bool BLI_path_frame_check_chars (const char *path)
 
void BLI_path_to_display_name (char *display_name, int maxlen, const char *name)
 
bool BLI_path_abs (char *path, const char *basepath)
 
bool BLI_path_abs_from_cwd (char *path, const size_t maxlen)
 
bool BLI_path_program_search (char *fullname, const size_t maxlen, const char *name)
 
void BLI_setenv (const char *env, const char *val)
 
void BLI_setenv_if_new (const char *env, const char *val)
 
const char * BLI_getenv (const char *env)
 
bool BLI_make_existing_file (const char *name)
 
void BLI_make_file_string (const char *relabase, char *string, const char *dir, const char *file)
 
static bool path_extension_check_ex (const char *str, const size_t str_len, const char *ext, const size_t ext_len)
 
bool BLI_path_extension_check (const char *str, const char *ext)
 
bool BLI_path_extension_check_n (const char *str,...)
 
bool BLI_path_extension_check_array (const char *str, const char **ext_array)
 
bool BLI_path_extension_check_glob (const char *str, const char *ext_fnmatch)
 
bool BLI_path_extension_glob_validate (char *ext_fnmatch)
 
bool BLI_path_extension_replace (char *path, size_t maxlen, const char *ext)
 
bool BLI_path_extension_ensure (char *path, size_t maxlen, const char *ext)
 
bool BLI_path_filename_ensure (char *filepath, size_t maxlen, const char *filename)
 
void BLI_split_dirfile (const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen)
 
void BLI_split_dir_part (const char *string, char *dir, const size_t dirlen)
 
void BLI_split_file_part (const char *string, char *file, const size_t filelen)
 
const char * BLI_path_extension (const char *filepath)
 
void BLI_path_append (char *__restrict dst, const size_t maxlen, const char *__restrict file)
 
void BLI_join_dirfile (char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file)
 
size_t BLI_path_join (char *__restrict dst, const size_t dst_len, const char *path,...)
 
const char * BLI_path_basename (const char *path)
 
bool BLI_path_name_at_index (const char *__restrict path, const int index, int *__restrict r_offset, int *__restrict r_len)
 
const char * BLI_path_slash_find (const char *string)
 
const char * BLI_path_slash_rfind (const char *string)
 
int BLI_path_slash_ensure (char *string)
 
void BLI_path_slash_rstrip (char *string)
 
void BLI_path_slash_native (char *path)
 

Function Documentation

◆ BLI_filename_make_safe()

bool BLI_filename_make_safe ( char *  fname)

Make given name safe to be used in paths.

Returns
true if fname was changed, false otherwise.

For now, simply replaces reserved chars (as listed in https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words ) by underscores ('_').

Note
Space case ' ' is a bit of an edge case here - in theory it is allowed, but again can be an issue in some cases, so we simply replace it by an underscore too (good practice anyway). REMOVED based on popular demand (see T45900). Percent '' char is a bit same case - not recommended to use it, but supported by all decent file-systems/operating-systems around.
On Windows, it also ensures there is no '.' (dot char) at the end of the file, this can lead to issues.
On Windows, it also checks for forbidden names (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx ).

Definition at line 299 of file path_util.c.

References BLI_str_tolower_ascii(), BLI_strdup(), len, MEM_freeN, and NULL.

Referenced by BLI_path_make_safe(), file_filename_enter_handle(), renamebutton_cb(), render_result_exr_file_path(), seq_disk_cache_get_dir(), and unpack_generate_paths().

◆ BLI_getenv()

const char* BLI_getenv ( const char *  env)

Get an env var, result has to be used immediately.

On windows #getenv gets its variables from a static copy of the environment variables taken at process start-up, causing it to not pick up on environment variables created during runtime. This function uses an alternative method to get environment variables that does pick up on runtime environment variables. The result will be UTF-8 encoded.

Definition at line 1313 of file path_util.c.

References alloc_utf16_from_8(), alloc_utf_8_from_16(), ARRAY_SIZE, buffer, free(), NULL, and result.

Referenced by BKE_appdir_folder_default(), BKE_appdir_folder_home(), BLI_current_working_dir(), BLI_path_program_search(), BLI_setenv_if_new(), BLT_lang_init(), colormanagement_init(), fsmenu_read_system(), get_thumb_dir(), test_env_path(), and where_is_temp().

◆ BLI_join_dirfile()

void BLI_join_dirfile ( char *__restrict  dst,
const size_t  maxlen,
const char *__restrict  dir,
const char *__restrict  file 
)

Simple appending of filename to dir, does not check for valid path! Puts result into dst, which may be same area as dir.

Definition at line 1737 of file path_util.c.

References ALTSEP, BLI_assert, BLI_strncpy(), BLI_strnlen(), ELEM, file, and SEP.

Referenced by autocomplete_directory(), BKE_appdir_app_template_id_search(), BKE_appdir_program_python_search(), BKE_memfile_undo_encode(), BKE_modifier_path_init(), BKE_ptcache_disk_cache_rename(), BKE_ptcache_id_clear(), BKE_ptcache_remove(), blf_dir_search(), blf_load_font_default(), bli_builddir(), BLI_path_abs_from_cwd(), BLI_path_parent_dir(), blo_do_versions_250(), bookmark_add_exec(), bookmark_cleanup_exec(), bookmark_delete_exec(), bookmark_move_exec(), check_destination(), colormanagement_init(), blender::compositor::OutputFileNode::convertToOperations(), draw_seq_text_get_source(), dynamicPaint_bakeImageSequence(), ED_file_read_bookmarks(), ED_fsmenu_entry_set_name(), ED_fsmenu_entry_set_path(), file_delete_single(), file_draw_check_exists(), file_draw_list(), file_exec(), file_expand_directory(), file_filename_enter_handle(), file_sfile_to_operator_ex(), fileentry_uiname(), filelist_cache_previews_push(), filelist_geticon_ex(), filelist_readjob_do(), filelist_readjob_list_dir(), Freestyle_Init(), fsmenu_read_system(), get_proxy_filename(), get_tc_filename(), image_get_udim(), image_sequence_get_frame_ranges(), init_iconfile_list(), init_internal_icons(), is_filtered_lib(), join_dirfile_alloc(), make_temp_filepath(), missing_files_find__recursive(), new_folder_path(), open_exec(), outliner_id_copy_exec(), outliner_id_paste_exec(), pose_copy_exec(), pose_paste_exec(), renamebutton_cb(), render_result_exr_file_path(), reset_recent_exec(), rewrite_path_fixed_dirfile(), SEQ_add_image_init_alpha_mode(), SEQ_add_reload_new_file(), seq_open_anim_file(), seq_proxy_get_custom_file_fname(), seq_proxy_multiview_context_invalid(), seq_render_image_strip(), sequencer_add_movie_multiple_strips(), sequencer_add_sound_multiple_strips(), sequencer_change_path_invoke(), sig_handle_crash(), view3d_copybuffer_exec(), view3d_pastebuffer_exec(), wm_autosave_delete(), wm_autosave_location(), wm_block_splash_image(), WM_exit_ex(), wm_history_file_read(), wm_history_file_write(), WM_init(), wm_lib_relocate_exec_do(), wm_link_append_exec(), wm_platform_support_check_approval(), WM_recover_last_session(), workspace_config_file_read(), workspace_system_file_read(), and DocumentImporter::writeImage().

◆ BLI_make_existing_file()

bool BLI_make_existing_file ( const char *  name)

◆ BLI_make_file_string()

void BLI_make_file_string ( const char *  relabase,
char *  string,
const char *  dir,
const char *  file 
)

Returns in string the concatenation of dir and file (also with relabase on the front if specified and dir begins with "//"). Normalizes all occurrences of path separators, including ensuring there is exactly one between the copies of dir and file, and between the copies of relabase and dir.

Parameters
relabaseOptional prefix to substitute for "//" on front of dir.
stringArea to return result.

Definition at line 1365 of file path_util.c.

References BLI_path_is_unc(), BLI_path_slash_native(), BLI_path_slash_rfind(), BLI_strncpy(), BLI_strnlen(), BLI_windows_get_default_root_dir(), ELEM, file, and NULL.

Referenced by icon_preview_imbuf_from_brush(), render_result_exr_file_cache_path(), and wm_autosave_location().

◆ BLI_path_abs()

bool BLI_path_abs ( char *  path,
const char *  basepath 
)

If path begins with "//", strips that and replaces it with basepath directory.

Note
Also converts drive-letter prefix to something more sensible if this is a non-drive-letter-based system.
Parameters
pathThe path to convert.
basepathThe directory to base relative paths with.
Returns
true if the path was relative (started with "//").

Definition at line 1016 of file path_util.c.

References BLI_path_is_rel(), BLI_path_normalize(), BLI_path_slash_rfind(), BLI_path_unc_prefix_len(), BLI_str_replace_char(), BLI_strncpy(), BLI_windows_get_default_root_dir(), ELEM, FILE_MAX, and NULL.

Referenced by blender::io::alembic::ArchiveReader::ArchiveReader(), BKE_bpath_relocate_visitor(), BKE_cachefile_filepath_get(), BKE_image_load(), BKE_image_load_exists_ex(), BKE_image_user_file_path(), BKE_library_filepath_set(), BKE_movieclip_file_add(), BKE_movieclip_file_add_exists_ex(), BKE_movieclip_filename_for_frame(), BKE_packedfile_compare_to_file(), BKE_packedfile_new(), BKE_packedfile_unpack_to_file(), BKE_sound_new_file(), BKE_sound_new_file_exists_ex(), BKE_text_file_modified_check(), BKE_text_file_modified_ignore(), BKE_text_load_ex(), BKE_text_reload(), BKE_vfont_load_exists_ex(), blf_dir_search(), BLI_path_normalize(), blo_do_versions_250(), bpath_absolute_convert_visit_cb(), bpath_relative_rebase_visit_cb(), bpy_lib_load(), bpy_lib_write(), customdata_external_filename(), detect_clip_source(), do_makepicstring(), dynamicPaint_outputSurfaceImage(), file_browse_exec(), file_expand_directory(), file_operator_to_sfile(), blender::io::gpencil::GpencilIO::filename_set(), fileselect_ensure_updated_file_params(), fluid_bake_startjob(), fluid_validatepaths(), get_proxy_fname(), get_sequence_fname(), icon_preview_imbuf_from_brush(), image_save_options_from_op(), image_save_options_init(), image_save_sequence_exec(), image_update_views_format(), meshcache_do(), movieclip_open_anim_file(), namebutton_fn(), open_invoke(), ptcache_path(), rewrite_path_alloc(), rewrite_path_fixed(), rewrite_path_fixed_dirfile(), screenshot_exec(), SEQ_add_image_init_alpha_mode(), SEQ_add_image_strip(), SEQ_add_movie_strip(), SEQ_add_reload_new_file(), SEQ_effect_text_font_load(), seq_open_anim_file(), seq_proxy_get_custom_file_fname(), seq_proxy_get_fname(), seq_proxy_multiview_context_invalid(), seq_render_image_strip(), sequencer_generic_invoke_path__internal(), sound_mixdown_exec(), and txt_write_file().

◆ BLI_path_abs_from_cwd()

bool BLI_path_abs_from_cwd ( char *  path,
const size_t  maxlen 
)

Checks for relative path, expanding them relative to the current working directory. Returns true if the expansion was performed.

Note
Should only be called with command line paths. This is not something Blender's internal paths support, instead they use the "//" prefix. In most cases BLI_path_abs should be used instead.

Definition at line 1128 of file path_util.c.

References BLI_current_working_dir(), BLI_join_dirfile(), BLI_path_is_unc(), BLI_strncpy(), and FILE_MAX.

Referenced by arg_handle_load_file(), arg_handle_python_file_run(), and where_am_i().

◆ BLI_path_append()

void BLI_path_append ( char *__restrict  dst,
const size_t  maxlen,
const char *__restrict  file 
)

◆ BLI_path_basename()

const char* BLI_path_basename ( const char *  path)

◆ BLI_path_extension()

const char* BLI_path_extension ( const char *  filepath)

Returns a pointer to the last extension (e.g. the position of the last period). Returns NULL if there is no extension.

Definition at line 1699 of file path_util.c.

References BLI_path_slash_find(), and NULL.

Referenced by ED_text_is_syntax_highlight_supported(), seq_disk_cache_get_files(), and TEST().

◆ BLI_path_extension_check()

bool BLI_path_extension_check ( const char *  str,
const char *  ext 
)

◆ BLI_path_extension_check_array()

bool BLI_path_extension_check_array ( const char *  str,
const char **  ext_array 
)

◆ BLI_path_extension_check_glob()

bool BLI_path_extension_check_glob ( const char *  str,
const char *  ext_fnmatch 
)

Semicolon separated wildcards, eg: *.zip;*.py;*.exe does str match any of the semicolon-separated glob patterns in #fnmatch.

Definition at line 1506 of file path_util.c.

References BLI_strncpy(), BLI_strncpy_rlen(), and str.

Referenced by filelist_readjob_list_dir().

◆ BLI_path_extension_check_n()

bool BLI_path_extension_check_n ( const char *  str,
  ... 
)

◆ BLI_path_extension_ensure()

bool BLI_path_extension_ensure ( char *  path,
size_t  maxlen,
const char *  ext 
)

Strip's trailing '.'s and adds the extension only when needed

Definition at line 1601 of file path_util.c.

References Freestyle::a, and STREQ.

Referenced by BKE_cachefile_filepath_get(), blend_save_check(), do_add_image_extension(), make_temp_filepath(), sequencer_export_subtitles_exec(), and wm_gpencil_import_svg_common_check().

◆ BLI_path_extension_glob_validate()

bool BLI_path_extension_glob_validate ( char *  ext_fnmatch)

Does basic validation of the given glob string, to prevent common issues from string truncation.

For now, only forbids last group to be a wildcard-only one, if there are more than one group (i.e. things like *.txt;*.cpp;* are changed to *.txt;*.cpp;)

Returns
true if it had to modify given ext_fnmatch pattern.

Definition at line 1541 of file path_util.c.

References ELEM.

Referenced by fileselect_ensure_updated_file_params().

◆ BLI_path_extension_replace()

bool BLI_path_extension_replace ( char *  path,
size_t  maxlen,
const char *  ext 
)

◆ BLI_path_filename_ensure()

bool BLI_path_filename_ensure ( char *  filepath,
size_t  maxlen,
const char *  filename 
)

Definition at line 1633 of file path_util.c.

References BLI_path_slash_rfind(), and Freestyle::c.

Referenced by wm_filepath_default().

◆ BLI_path_frame()

bool BLI_path_frame ( char *  path,
int  frame,
int  digits 
)

Replaces "#" character sequence in last slash-separated component of path with frame as decimal integer, with leading zeroes as necessary, to make digits digits.

Definition at line 802 of file path_util.c.

References BLI_snprintf(), BLI_strncpy(), ensure_digits(), FILE_MAX, and stringframe_chars().

Referenced by BKE_cachefile_filepath_get(), do_makepicstring(), dynamicPaint_bakeImageSequence(), get_proxy_fname(), sequencer_image_seq_reserve_frames(), and TEST().

◆ BLI_path_frame_check_chars()

bool BLI_path_frame_check_chars ( const char *  path)

Check if we have '#' chars, usable for BLI_path_frame, BLI_path_frame_range

Definition at line 958 of file path_util.c.

References stringframe_chars().

◆ BLI_path_frame_get()

bool BLI_path_frame_get ( char *  path,
int *  r_frame,
int *  r_numdigits 
)

Get the frame from a filename formatted by blender's frame scheme

Definition at line 854 of file path_util.c.

References BLI_path_slash_rfind(), Freestyle::c, file, len, and NULL.

Referenced by BKE_cachefile_filepath_get(), sequencer_image_seq_get_minmax_frame(), and volume_sequence_frame().

◆ BLI_path_frame_range()

bool BLI_path_frame_range ( char *  path,
int  sta,
int  end,
int  digits 
)

Replaces "#" character sequence in last slash-separated component of path with sta and end as decimal integers, with leading zeroes as necessary, to make digits digits each, with a hyphen in-between.

Definition at line 825 of file path_util.c.

References BLI_snprintf(), BLI_strncpy(), ensure_digits(), FILE_MAX, and stringframe_chars().

◆ BLI_path_frame_strip()

void BLI_path_frame_strip ( char *  path,
char *  r_ext 
)

◆ BLI_path_is_rel()

bool BLI_path_is_rel ( const char *  path)

◆ BLI_path_is_unc()

bool BLI_path_is_unc ( const char *  name)

◆ BLI_path_join()

size_t BLI_path_join ( char *__restrict  dst,
const size_t  dst_len,
const char *  path,
  ... 
)

Join multiple strings into a path, ensuring only a single path separator between each, and trailing slash is kept.

Note
If you want a trailing slash, add SEP_STR as the last path argument, duplicate slashes will be cleaned up.

Definition at line 1782 of file path_util.c.

References ALTSEP, BLI_assert, BLI_strncpy_rlen(), ELEM, len, path_init(), SEP, and UNLIKELY.

◆ BLI_path_make_safe()

bool BLI_path_make_safe ( char *  path)

◆ BLI_path_name_at_index()

bool BLI_path_name_at_index ( const char *__restrict  path,
const int  index,
int *__restrict  r_offset,
int *__restrict  r_len 
)

Get an element of the path at an index, eg: "/some/path/file.txt" where an index of...

  • 0 or -3: "some"
  • 1 or -2: "path"
  • 2 or -1: "file.txt"

Ignores multiple slashes at any point in the path (including start/end).

Definition at line 1883 of file path_util.c.

References ALTSEP, Freestyle::c, ELEM, and SEP.

Referenced by fsmenu_entry_generate_name().

◆ BLI_path_normalize()

void BLI_path_normalize ( const char *  relabase,
char *  path 
)

Remove redundant characters from path and optionally make absolute.

Parameters
relabaseThe path this is relative to, or ignored when NULL.
pathCan be any input, and this function converts it to a regular full path. Also removes garbage from directory paths, like /../ or double slashes etc.
Note
path isn't protected for max string names...

Definition at line 173 of file path_util.c.

References Freestyle::a, BLI_path_abs(), and BLI_path_unc_prefix_len().

Referenced by BKE_bpath_relocate_visitor(), BLI_path_abs(), BLI_path_normalize_dir(), BLI_path_parent_dir(), BLI_path_rel(), blo_find_main(), BLO_write_file(), bpath_relative_rebase_visit_cb(), direct_link_library(), file_exec(), get_path_local_ex(), Freestyle::StringUtils::getPathName(), Freestyle::Controller::LoadMesh(), TEST(), and where_am_i().

◆ BLI_path_normalize_dir()

void BLI_path_normalize_dir ( const char *  relabase,
char *  dir 
)

◆ BLI_path_parent_dir()

bool BLI_path_parent_dir ( char *  path)

Replaces path with the path of its parent directory, returning true if it was able to find a parent directory within the path.

Definition at line 708 of file path_util.c.

References BLI_join_dirfile(), BLI_path_extension_check(), BLI_path_normalize(), FILE_MAX, NULL, and SEP.

Referenced by bli_builddir(), BLI_path_parent_dir_until_exists(), file_exec(), file_parent_exec(), file_select_do(), open_invoke(), and wm_link_append_invoke().

◆ BLI_path_parent_dir_until_exists()

bool BLI_path_parent_dir_until_exists ( char *  dir)

Strips off nonexistent (or non-accessible) sub-directories from the end of dir, leaving the path of the lowest-level directory that does exist and we can read.

Definition at line 728 of file path_util.c.

References BLI_access(), and BLI_path_parent_dir().

Referenced by parent_dir_until_exists_or_default_root().

◆ BLI_path_program_search()

bool BLI_path_program_search ( char *  fullname,
const size_t  maxlen,
const char *  name 
)

Search for a binary (executable)

Definition at line 1218 of file path_util.c.

References BLI_exists(), BLI_getenv(), BLI_path_append(), BLI_strncpy(), and FILE_MAX.

Referenced by BKE_appdir_program_python_search(), and where_am_i().

◆ BLI_path_rel()

void BLI_path_rel ( char *  file,
const char *  relfile 
)

◆ BLI_path_sequence_decode()

int BLI_path_sequence_decode ( const char *  string,
char *  head,
char *  tail,
ushort r_num_len 
)

Looks for a sequence of decimal digits in string, preceding any filename extension, returning the integer value if found, or 0 if not.

Parameters
stringString to scan.
headOptional area to return copy of part of string prior to digits, or before dot if no digits.
tailOptional area to return copy of part of string following digits, or from dot if no digits.
r_num_lenOptional to return number of digits found.

Definition at line 83 of file path_util.c.

References BLI_path_slash_rfind(), BLI_strncpy(), NULL, and ret.

Referenced by BKE_image_save(), BKE_image_sequence_guess_offset(), BKE_image_user_file_path(), build_pict_list_ex(), filenum_newname(), get_sequence_fname(), image_get_udim(), image_save_options_init(), image_sequence_get_frame_ranges(), movieclip_calc_length(), put_imbuf_cache(), and user_frame_to_cache_frame().

◆ BLI_path_sequence_encode()

void BLI_path_sequence_encode ( char *  string,
const char *  head,
const char *  tail,
unsigned short  numlen,
int  pic 
)

Returns in area pointed to by string a string of the form "<head><pic><tail>", where pic is formatted as numlen digits with leading zeroes.

Definition at line 154 of file path_util.c.

References MAX2.

Referenced by an_stringenc(), BKE_image_save(), BKE_image_user_file_path(), build_pict_list_ex(), filenum_newname(), get_sequence_fname(), and image_get_udim().

◆ BLI_path_slash_ensure()

int BLI_path_slash_ensure ( char *  string)

Appends a slash to string if there isn't one there already. Returns the new length of the string.

Definition at line 1981 of file path_util.c.

References len, and SEP.

Referenced by autocomplete_directory(), BLI_path_normalize_dir(), file_browse_exec(), file_exec(), file_select_do(), filelist_geticon_ex(), filelist_readjob_list_dir(), ptcache_path(), seq_disk_cache_delete_invalid_files(), seq_disk_cache_get_files(), tempdir_session_create(), and where_is_temp().

◆ BLI_path_slash_find()

const char* BLI_path_slash_find ( const char *  string)

Returns pointer to the leftmost path separator in string. Not actually used anywhere.

Definition at line 1944 of file path_util.c.

Referenced by BLI_path_extension(), and BLI_path_make_safe().

◆ BLI_path_slash_native()

void BLI_path_slash_native ( char *  path)

Changes to the path separators to the native ones for this OS.

Definition at line 2012 of file path_util.c.

References BLI_path_unc_prefix_len(), BLI_str_replace_char(), and BLI_strnlen().

Referenced by BLI_make_file_string(), clean_paths(), and clean_paths_visit_cb().

◆ BLI_path_slash_rfind()

const char* BLI_path_slash_rfind ( const char *  string)

◆ BLI_path_slash_rstrip()

void BLI_path_slash_rstrip ( char *  string)

Removes the last slash and everything after it to the end of string, if there is one.

Definition at line 1995 of file path_util.c.

References len, and SEP.

Referenced by BLI_dir_create_recursive(), file_path_to_ui_path(), and strip_last_slash().

◆ BLI_path_suffix()

bool BLI_path_suffix ( char *  string,
size_t  maxlen,
const char *  suffix,
const char *  sep 
)

Appends a suffix to the string, fitting it before the extension

string = Foo.png, suffix = 123, separator = _ Foo.png -> Foo_123.png

Parameters
stringoriginal (and final) string
maxlenMaximum length of string
suffixString to append to the original string
sepOptional separator character
Returns
true if succeeded

Definition at line 669 of file path_util.c.

References Freestyle::a, BLI_strncpy(), ELEM, and FILE_MAX.

Referenced by bake_targets_output_external(), BKE_image_memorypack(), BKE_scene_multiview_filepath_get(), BKE_scene_multiview_view_filepath_get(), and do_makepicstring().

◆ BLI_path_to_display_name()

void BLI_path_to_display_name ( char *  display_name,
int  maxlen,
const char *  name 
)

Creates a display string from path to be used menus and the user interface. Like bpy.path.display_name().

Definition at line 968 of file path_util.c.

References BLI_path_extension_replace(), BLI_str_replace_char(), BLI_strncpy(), and ELEM.

Referenced by workspace_add_invoke().

◆ BLI_path_unc_prefix_len()

static int BLI_path_unc_prefix_len ( const char *  path)
static

Returns the length of the identifying prefix of a UNC path which can start with '\' (short version) or '\?\' (long version) If the path is not a UNC path, return 0

Definition at line 428 of file path_util.c.

References BLI_path_is_unc().

Referenced by BLI_path_abs(), BLI_path_normalize(), BLI_path_rel(), and BLI_path_slash_native().

◆ BLI_setenv()

void BLI_setenv ( const char *  env,
const char *  val 
)

Sets the specified environment variable to the specified value, and clears it if val == NULL.

Definition at line 1274 of file path_util.c.

References uputenv().

Referenced by arg_handle_env_system_set(), and BLI_setenv_if_new().

◆ BLI_setenv_if_new()

void BLI_setenv_if_new ( const char *  env,
const char *  val 
)

Only set an env var if already not there. Like Unix setenv(env, val, 0);

(not used anywhere).

Definition at line 1298 of file path_util.c.

References BLI_getenv(), BLI_setenv(), and NULL.

◆ BLI_split_dir_part()

void BLI_split_dir_part ( const char *  string,
char *  dir,
const size_t  dirlen 
)

◆ BLI_split_dirfile()

void BLI_split_dirfile ( const char *  string,
char *  dir,
char *  file,
const size_t  dirlen,
const size_t  filelen 
)

◆ BLI_split_file_part()

void BLI_split_file_part ( const char *  string,
char *  file,
const size_t  filelen 
)

Copies the leaf filename part of string into file, max length filelen.

Definition at line 1690 of file path_util.c.

References BLI_split_dirfile(), file, and NULL.

Referenced by BKE_studiolight_create(), BKE_vfont_load(), BKE_volume_load(), block_create__close_file_dialog(), ptcache_path(), seq_disk_cache_get_project_dir(), studiolight_add_file(), unpack_menu(), and volume_import_exec().

◆ ensure_digits()

static void ensure_digits ( char *  path,
int  digits 
)
static

Ensure path contains at least one "#" character in its last slash-separated component, appending one digits long if not.

Definition at line 780 of file path_util.c.

References BLI_path_slash_rfind(), file, len, and NULL.

Referenced by BLI_path_frame(), and BLI_path_frame_range().

◆ path_extension_check_ex()

static bool path_extension_check_ex ( const char *  str,
const size_t  str_len,
const char *  ext,
const size_t  ext_len 
)
static

◆ stringframe_chars()

static bool stringframe_chars ( const char *  path,
int *  char_start,
int *  char_end 
)
static

Looks for a sequence of "#" characters in the last slash-separated component of path, returning the indexes of the first and one past the last character in the sequence in char_start and char_end respectively. Returns true if such a sequence was found.

Definition at line 744 of file path_util.c.

References ELEM.

Referenced by BLI_path_frame(), BLI_path_frame_check_chars(), and BLI_path_frame_range().