Blender
V3.3
|
#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.
Macros | |
#define | INVALID_CHARS |
#define | INVALID_TOKENS "<>" |
Functions | |
int | BLI_path_sequence_decode (const char *string, char *head, char *tail, ushort *r_digits_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_ex (char *fname, bool allow_tokens) |
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_digits_len) |
void | BLI_path_frame_strip (char *path, char *r_ext, const size_t ext_maxlen) |
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_is_abs_from_cwd (const char *path) |
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) |
bool | BLI_path_contains (const char *container_path, const char *containee_path) |
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) |
int | BLI_path_cmp_normalized (const char *p1, const char *p2) |
Various string, file, list operations.
Definition in file path_util.c.
#define INVALID_CHARS |
#define INVALID_TOKENS "<>" |
bool BLI_filename_make_safe | ( | char * | fname | ) |
Definition at line 309 of file path_util.c.
References BLI_filename_make_safe_ex().
Referenced by BLI_path_make_safe(), renamebutton_cb(), seq_disk_cache_get_dir(), and unpack_generate_paths().
Make given name safe to be used in paths.
allow_tokens | Permit the usage of '<' and '>' characters. This can be leveraged by higher layers to support "virtual filenames" which contain substitution markers delineated between the two characters. |
For now, simply replaces reserved chars (as listed in https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words ) by underscores ('_').
Definition at line 232 of file path_util.c.
References BLI_str_tolower_ascii(), BLI_strdup(), INVALID_CHARS, INVALID_TOKENS, len, MEM_freeN, and NULL.
Referenced by BLI_filename_make_safe(), and file_filename_enter_handle().
const char* BLI_getenv | ( | const char * | env | ) |
Get an environment variable, 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 1168 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().
void BLI_join_dirfile | ( | char *__restrict | dst, |
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 1531 of file path_util.c.
References ALTSEP, BLI_assert, BLI_strncpy(), BLI_strnlen(), ELEM, file, and SEP.
Referenced by blender::bke::asset_definition_default_file_path_from_dir(), autocomplete_directory(), BKE_appdir_app_template_id_search(), BKE_appdir_program_python_search(), BKE_bpath_foreach_path_dirfile_fixed_process(), BKE_image_get_tile_info(), BKE_memfile_undo_encode(), BKE_modifier_path_init(), BKE_ptcache_disk_cache_rename(), BKE_ptcache_id_clear(), blf_dir_search(), blf_load_font_default(), bli_builddir(), BLI_path_abs_from_cwd(), BLI_path_parent_dir(), bookmark_add_exec(), bookmark_cleanup_exec(), bookmark_delete_exec(), bookmark_move_exec(), check_destination(), colormanagement_init(), blender::compositor::OutputFileNode::convert_to_operations(), draw_seq_text_get_source(), dynamicPaint_bakeImageSequence(), ED_assetlist_asset_filepath_get(), 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_execute(), file_filename_enter_handle(), file_sfile_to_operator_ex(), fileentry_uiname(), filelist_cache_previews_push(), filelist_geticon_ex(), filelist_readjob_list_dir(), filelist_readjob_recursive_dir_add_items(), Freestyle_Init(), fsmenu_read_system(), get_proxy_filepath(), get_tc_filename(), blender::compositor::DebugInfo::graphviz(), image_foreach_path(), image_sequence_get_frame_ranges(), init_iconfile_list(), init_internal_icons(), is_filtered_lib_type(), join_dirfile_alloc(), load_data_init_from_operator(), 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(), reset_recent_exec(), 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(), seq_sound_proxy_update_cb(), sequencer_add_movie_multiple_strips(), sequencer_add_sound_multiple_strips(), sequencer_change_path_invoke(), set_filepath_for_asset_lib(), sig_handle_crash(), view3d_copybuffer_exec(), view3d_pastebuffer_exec(), wm_autosave_delete(), wm_autosave_location(), wm_block_splash_image(), WM_exit_ex(), WM_file_recover_last_session(), wm_history_file_read(), wm_history_file_write(), wm_lib_relocate_exec_do(), wm_link_append_exec(), wm_platform_support_check_approval(), workspace_config_file_read(), workspace_system_file_read(), and DocumentImporter::writeImage().
bool BLI_make_existing_file | ( | const char * | name | ) |
Ensures that the parent directory of name
exists.
Definition at line 1197 of file path_util.c.
References BLI_dir_create_recursive(), BLI_split_dir_part(), and FILE_MAX.
Referenced by BKE_image_render_write_exr(), BKE_imbuf_write(), BKE_packedfile_compare_to_file(), blender::compositor::OutputOpenExrMultiLayerOperation::deinit_execution(), dynamicPaint_outputSurfaceImage(), blender::ed::asset::index::AssetIndexFile::ensure_parent_path_exists(), blender::compositor::DebugInfo::export_operation(), blender::compositor::OutputOpenExrSingleLayerMultiViewOperation::get_handle(), blender::compositor::OutputOpenExrMultiLayerMultiViewOperation::get_handle(), IMB_index_builder_create(), movieclip_build_proxy_ibuf(), blender::io::path_reference_copy(), ptcache_file_open(), RE_RenderAnim(), seq_disk_cache_create_version_file(), seq_disk_cache_read_file(), seq_disk_cache_write_file(), seq_proxy_build_frame(), and sequencer_export_subtitles_exec().
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
.
relabase | Optional prefix to substitute for "//" on front of dir . |
string | Area to return result. |
Definition at line 1206 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().
bool BLI_path_abs | ( | char * | path, |
const char * | basepath | ||
) |
If path begins with "//", strips that and replaces it with basepath
directory.
path | The path to convert. |
basepath | The directory to base relative paths with. |
Definition at line 897 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 absolute_convert_foreach_path_cb(), BKE_bpath_foreach_path_allocated_process(), BKE_bpath_foreach_path_dirfile_fixed_process(), BKE_bpath_foreach_path_fixed_process(), BKE_cachefile_filepath_get(), BKE_image_load(), BKE_image_load_exists_ex(), BKE_image_save_options_init(), BKE_image_signal(), BKE_image_user_file_path_ex(), 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(), BLI_path_normalize(), 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::filepath_set(), fileselect_ensure_updated_file_params(), fluid_bake_startjob(), fluid_validatepaths(), blender::io::usd::get_absolute_path(), get_drag_path(), get_proxy_fname(), get_sequence_fname(), icon_preview_imbuf_from_brush(), image_save_options_from_op(), image_save_sequence_exec(), image_update_views_format(), blender::io::usd::import_startjob(), lib_id_library_local_paths_callback(), meshcache_do(), movieclip_open_anim_file(), namebutton_fn(), open_invoke(), blender::io::path_reference(), ptcache_path(), relative_rebase_foreach_path_cb(), 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(), seq_sound_proxy_update_cb(), sequencer_generic_invoke_path__internal(), sound_mixdown_exec(), and txt_write_file().
bool BLI_path_abs_from_cwd | ( | char * | path, |
size_t | maxlen | ||
) |
Checks for relative path, expanding them relative to the current working directory.
Definition at line 1015 of file path_util.c.
References BLI_current_working_dir(), BLI_join_dirfile(), BLI_path_is_abs_from_cwd(), BLI_strncpy(), and FILE_MAX.
Referenced by arg_handle_load_file(), arg_handle_python_file_run(), and where_am_i().
void BLI_path_append | ( | char *__restrict | dst, |
size_t | maxlen, | ||
const char *__restrict | file | ||
) |
Append a filename to a dir, ensuring slash separates.
Definition at line 1514 of file path_util.c.
References BLI_strncpy(), BLI_strnlen(), file, and SEP.
Referenced by BLI_path_program_search(), file_directory_enter_handle(), file_execute(), get_index_dir(), blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path(), seq_disk_cache_get_dir(), seq_disk_cache_get_file_path(), seq_disk_cache_get_project_dir(), seq_disk_cache_handle_versioning(), and seq_proxy_index_dir_set().
const char* BLI_path_basename | ( | const char * | path | ) |
Like Python's os.path.basename()
Definition at line 1653 of file path_util.c.
References BLI_path_slash_rfind().
Referenced by asset_bundle_install_exec(), BKE_image_add_from_imbuf(), BKE_image_is_filename_tokenized(), BKE_image_load(), BKE_movieclip_file_add(), BKE_packedfile_unpack_image(), BKE_sound_new_file(), BKE_text_load_ex(), blo_find_main(), cachefile_open_exec(), blender::io::obj::obj_exporter_regression_test::compare_obj_export_to_golden(), blender::io::obj::create_placeholder_image(), do_versions_after_linking_300(), fileentry_uiname(), image_file_browse_exec(), blender::io::usd::import_startjob(), import_startjob(), blender::io::stl::importer_main(), load_data_init_from_operator(), blender::io::obj::load_texture_image(), missing_files_find_foreach_path_cb(), blender::io::obj::OBJParser::parse(), blender::io::path_reference(), recent_files_menu_draw(), report_duration(), set_filepath_for_asset_lib(), sig_handle_crash(), uiTemplateRecentFiles(), wm_autosave_location(), wm_file_write(), and blender::io::obj::MTLWriter::write_header().
int BLI_path_cmp_normalized | ( | const char * | p1, |
const char * | p2 | ||
) |
Definition at line 1816 of file path_util.c.
References BLI_assert_msg, BLI_path_cmp, BLI_path_is_rel(), BLI_path_normalize(), BLI_path_slash_native(), BLI_strncpy(), FILE_MAX, and NULL.
bool BLI_path_contains | ( | const char * | container_path, |
const char * | containee_path | ||
) |
Return true only if #containee_path is contained in #container_path.
Definition at line 1717 of file path_util.c.
References BLI_path_normalize(), BLI_path_slash_ensure(), BLI_path_slash_native(), BLI_str_startswith(), BLI_str_tolower_ascii(), BLI_strncpy(), NULL, PATH_MAX, and STREQ.
Referenced by BKE_preferences_asset_library_containing_path(), filelist_contains_main(), is_contained_in_selected_asset_library(), blender::io::path_reference(), and TEST().
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 1500 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().
bool BLI_path_extension_check | ( | const char * | str, |
const char * | ext | ||
) |
str
end with ext
(case insensitive). Definition at line 1299 of file path_util.c.
References path_extension_check_ex(), and str.
Referenced by BKE_image_is_openexr(), BKE_image_render_write(), BLI_file_alias_target(), BLI_file_attributes(), BLI_path_parent_dir(), blo_do_versions_300(), blender::compositor::DebugInfo::delete_operation_exports(), do_add_image_extension(), ED_path_extension_type(), init_iconfile_list(), Freestyle::Controller::InsertStyleModule(), and studiolight_add_file().
bool BLI_path_extension_check_array | ( | const char * | str, |
const char ** | ext_array | ||
) |
str
ends with any of the suffixes in ext_array
. Definition at line 1326 of file path_util.c.
References path_extension_check_ex(), and str.
Referenced by BKE_image_load(), BLO_has_bfile_extension(), do_add_image_extension(), ED_path_extension_type(), image_replace_exec(), imb_is_filepath_format(), and studiolight_add_file().
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 1341 of file path_util.c.
References BLI_strncpy(), BLI_strncpy_rlen(), and str.
Referenced by BKE_cachefile_eval(), and filelist_readjob_list_dir().
bool BLI_path_extension_check_n | ( | const char * | str, |
... | |||
) |
Definition at line 1304 of file path_util.c.
References path_extension_check_ex(), ret, and str.
Referenced by BKE_image_alpha_mode_from_extension_ex(), do_add_image_extension(), and ED_path_extension_type().
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 1420 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(), and sequencer_export_subtitles_exec().
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;
)
Definition at line 1367 of file path_util.c.
References ELEM.
Referenced by fileselect_ensure_updated_file_params().
bool BLI_path_extension_replace | ( | char * | path, |
size_t | maxlen, | ||
const char * | ext | ||
) |
Removes any existing extension on the end of path and appends ext.
Definition at line 1393 of file path_util.c.
References Freestyle::a, and ELEM.
Referenced by blender::io::obj::append_frame_to_filename(), BLI_path_to_display_name(), cachefile_layer_open_invoke(), cachefile_open_invoke(), do_add_image_extension(), filelist_readjob_list_dir(), imb_cache_filename(), blender::io::stl::importer_main(), blender::io::obj::MTLWriter::MTLWriter(), blender::io::obj::OBJParser::parse(), render_result_exr_file_cache_path(), screenshot_invoke(), sequencer_export_subtitles_invoke(), sig_handle_crash(), volume_import_exec(), and write_crash_blend().
bool BLI_path_filename_ensure | ( | char * | filepath, |
size_t | maxlen, | ||
const char * | filename | ||
) |
Ensure filepath
has a file component, adding filename
when it's empty or ends with a slash.
filename
was appended to filepath
. Definition at line 1452 of file path_util.c.
References BLI_path_slash_rfind(), and Freestyle::c.
Referenced by wm_filepath_default().
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.
Definition at line 709 of file path_util.c.
References BLI_snprintf(), BLI_strncpy(), ensure_digits(), FILE_MAX, and stringframe_chars().
Referenced by blender::io::obj::append_frame_to_filename(), BKE_cachefile_filepath_get(), do_makepicstring(), dynamicPaint_bakeImageSequence(), get_proxy_fname(), sequencer_image_seq_reserve_frames(), and TEST().
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 853 of file path_util.c.
References stringframe_chars().
bool BLI_path_frame_get | ( | char * | path, |
int * | r_frame, | ||
int * | r_digits_len | ||
) |
Get the frame from a filename formatted by blender's frame scheme
Definition at line 753 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().
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 727 of file path_util.c.
References BLI_snprintf(), BLI_strncpy(), ensure_digits(), FILE_MAX, and stringframe_chars().
void BLI_path_frame_strip | ( | char * | path, |
char * | r_ext, | ||
size_t | ext_maxlen | ||
) |
Given a path
with digits representing frame numbers, replace the digits with the '#' character and extract the extension. So: /some/path_123.jpeg
Becomes: /some/path_###
with r_ext
set to .jpeg
.
Definition at line 805 of file path_util.c.
References BLI_path_slash_rfind(), BLI_strncpy(), Freestyle::c, file, len, and NULL.
Referenced by BKE_cachefile_filepath_get(), and sequencer_image_seq_reserve_frames().
bool BLI_path_is_abs_from_cwd | ( | const char * | path | ) |
Checks for a relative path (ignoring Blender's "//") prefix (unlike !BLI_path_is_rel(path)
). When false, BLI_path_abs_from_cwd would expand the absolute path.
Definition at line 998 of file path_util.c.
References BLI_path_is_unc(), and BLI_strnlen().
Referenced by BLI_path_abs_from_cwd(), BLO_write_file(), and wm_save_as_mainfile_exec().
bool BLI_path_is_rel | ( | const char * | path | ) |
Does path begin with the special "//" prefix that Blender uses to indicate a path relative to the .blend file.
Definition at line 347 of file path_util.c.
Referenced by absolute_convert_foreach_path_cb(), BKE_image_tile_filepath_exists(), BKE_library_filepath_set(), BKE_packedfile_pack_all_libraries(), blf_dir_search(), BLI_access(), BLI_delete(), BLI_delete_soft(), BLI_exists(), BLI_fopen(), BLI_gzopen(), BLI_open(), BLI_path_abs(), BLI_path_cmp_normalized(), BLI_path_rel(), BLO_write_file(), ED_image_filesel_detect_sequences(), file_browse_invoke(), file_expand_directory(), fix_relpaths_library(), blender::io::usd::get_tex_image_asset_path(), image_replace_invoke(), imb_get_anim_type(), imb_ispic_read_header_from_filepath(), IMB_loadiffname(), IMB_open_anim(), IMB_saveiff(), IMB_testiffname(), lib_id_library_local_paths_callback(), missing_files_find_foreach_path_cb(), blender::io::path_reference(), ptcache_path(), relative_convert_foreach_path_cb(), and relative_rebase_foreach_path_cb().
bool BLI_path_is_unc | ( | const char * | path | ) |
Return true if the path is a UNC share.
Definition at line 352 of file path_util.c.
Referenced by BLI_make_file_string(), BLI_path_is_abs_from_cwd(), BLI_path_rel(), BLI_path_unc_prefix_len(), and file_expand_directory().
size_t BLI_path_join | ( | char *__restrict | dst, |
const size_t | dst_len, | ||
const char * | path, | ||
... | |||
) |
Definition at line 1573 of file path_util.c.
References ALTSEP, BLI_assert, BLI_strncpy_rlen(), ELEM, len, path_init(), SEP, and UNLIKELY.
bool BLI_path_make_safe | ( | char * | path | ) |
Make given path OS-safe.
Definition at line 314 of file path_util.c.
References backup, BLI_filename_make_safe(), and BLI_path_slash_find().
Referenced by MANTA::bakeData(), MANTA::bakeGuiding(), MANTA::bakeMesh(), MANTA::bakeNoise(), MANTA::bakeParticles(), BKE_image_save_options_init(), MANTA::exportLiquidScript(), MANTA::exportSmokeScript(), and file_directory_new_exec().
bool BLI_path_name_at_index | ( | const char *__restrict | path, |
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:
Ignores multiple slashes at any point in the path (including start/end).
Definition at line 1659 of file path_util.c.
References ALTSEP, Freestyle::c, ELEM, blender::meshintersect::prev(), and SEP.
Referenced by fsmenu_entry_generate_name().
void BLI_path_normalize | ( | const char * | relabase, |
char * | path | ||
) |
Remove redundant characters from path and optionally make absolute.
relabase | The path this is relative to, or ignored when NULL. |
path | Can be any input, and this function converts it to a regular full path. Also removes garbage from directory paths, like /../ or double slashes etc. |
Definition at line 131 of file path_util.c.
References Freestyle::a, BLI_path_abs(), and BLI_path_unc_prefix_len().
Referenced by arg_handle_load_file(), BLI_path_abs(), BLI_path_cmp_normalized(), BLI_path_contains(), BLI_path_normalize_dir(), BLI_path_parent_dir(), BLI_path_rel(), blo_find_main(), BLO_write_file(), direct_link_library(), blender::io::obj::export_frame(), file_execute(), blender::io::usd::get_absolute_path(), get_path_local_ex(), Freestyle::StringUtils::getPathName(), lib_id_library_local_paths_callback(), Freestyle::Controller::LoadMesh(), blender::io::path_reference(), relative_rebase_foreach_path_cb(), TEST(), where_am_i(), and blender::io::obj::MTLWriter::write_materials().
void BLI_path_normalize_dir | ( | const char * | relabase, |
char * | dir | ||
) |
Cleanup file-path ensuring a trailing slash.
Definition at line 221 of file path_util.c.
References BLI_path_normalize(), and BLI_path_slash_ensure().
Referenced by bookmark_select_exec(), file_directory_enter_handle(), file_filename_enter_handle(), file_parent_exec(), file_select_do(), filelist_readjob_recursive_dir_add_items(), filelist_setdir(), and fileselect_ensure_updated_file_params().
bool BLI_path_parent_dir | ( | char * | path | ) |
Go back one directory.
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 623 of file path_util.c.
References BLI_join_dirfile(), BLI_path_extension_check(), BLI_path_normalize(), FILE_MAX, NULL, and SEP.
Referenced by BKE_preferences_asset_library_path_set(), bli_builddir(), BLI_path_parent_dir_until_exists(), file_execute(), file_parent_exec(), file_select_do(), open_invoke(), and wm_link_append_invoke().
bool BLI_path_parent_dir_until_exists | ( | char * | path | ) |
Go back until the directory is found.
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 639 of file path_util.c.
References BLI_access(), and BLI_path_parent_dir().
Referenced by parent_dir_until_exists_or_default_root().
bool BLI_path_program_search | ( | char * | fullname, |
size_t | maxlen, | ||
const char * | name | ||
) |
Search for a binary (executable)
Definition at line 1091 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().
void BLI_path_rel | ( | char * | file, |
const char * | relfile | ||
) |
Replaces file
with a relative version (prefixed by "//") such that BLI_path_abs, given the same relfile
, will convert it back to its original value.
Definition at line 450 of file path_util.c.
References BLI_path_is_rel(), BLI_path_is_unc(), BLI_path_normalize(), BLI_path_slash_rfind(), BLI_path_unc_prefix_len(), BLI_str_replace_char(), BLI_strcpy_rlen(), BLI_strncpy(), BLI_strncpy_rlen(), BLI_strnlen(), BLI_windows_get_default_root_dir(), ELEM, file, FILE_MAX, NULL, and r.
Referenced by draw_seq_in_view(), ED_image_filesel_detect_sequences(), file_browse_exec(), file_sfile_to_operator_ex(), filelist_readjob_recursive_dir_add_items(), fix_relpaths_library(), fluid_validatepaths(), blender::io::usd::get_tex_image_asset_path(), image_open_single(), image_save_update_filepath(), lib_id_library_local_paths_callback(), library_link_end(), load_data_init_from_operator(), blender::io::obj::load_image_at_path(), missing_files_find_foreach_path_cb(), multires_external_save_exec(), open_exec(), blender::io::path_reference(), relative_convert_foreach_path_cb(), relative_rebase_foreach_path_cb(), sequencer_change_path_exec(), volume_import_exec(), and WM_operator_drop_load_path().
int BLI_path_sequence_decode | ( | const char * | string, |
char * | head, | ||
char * | tail, | ||
unsigned short * | r_digits_len | ||
) |
Looks for a sequence of decimal digits in string, preceding any filename extension, returning the integer value if found, or 0 if not.
string | String to scan. |
head | Optional area to return copy of part of string prior to digits, or before dot if no digits. |
tail | Optional area to return copy of part of string following digits, or from dot if no digits. |
r_digits_len | Optional to return number of digits found. |
Definition at line 56 of file path_util.c.
References BLI_path_slash_rfind(), BLI_strncpy(), NULL, and ret.
Referenced by BKE_image_sequence_guess_offset(), BKE_image_user_file_path_ex(), build_pict_list_ex(), filenum_newname(), blender::io::obj::get_image_filepath(), get_sequence_fname(), image_sequence_get_frame_ranges(), movieclip_calc_length(), put_imbuf_cache(), and user_frame_to_cache_frame().
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 123 of file path_util.c.
References MAX2.
Referenced by an_stringenc(), BKE_image_user_file_path_ex(), build_pict_list_ex(), filenum_newname(), blender::io::obj::get_image_filepath(), and get_sequence_fname().
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 1780 of file path_util.c.
Referenced by autocomplete_directory(), BKE_appdir_font_folder_default(), BLI_path_contains(), BLI_path_normalize_dir(), file_browse_exec(), file_execute(), 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(), blender::bke::tests::TEST_F(), and where_is_temp().
const char* BLI_path_slash_find | ( | const char * | string | ) |
Definition at line 1750 of file path_util.c.
Referenced by BKE_image_ensure_tile_token(), BLI_path_extension(), BLI_path_make_safe(), and blender::bke::AssetCatalogPath::iterate_components().
void BLI_path_slash_native | ( | char * | path | ) |
Changes to the path separators to the native ones for this OS.
Definition at line 1805 of file path_util.c.
References ALTSEP, BLI_path_unc_prefix_len(), BLI_str_replace_char(), BLI_strnlen(), and SEP.
Referenced by arg_handle_load_file(), BLI_make_file_string(), BLI_path_cmp_normalized(), BLI_path_contains(), clean_paths(), blender::io::obj::export_frame(), foreach_path_clean_cb(), blender::bke::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), blender::bke::tests::TEST_F(), and blender::io::obj::MTLWriter::write_materials().
const char* BLI_path_slash_rfind | ( | const char * | string | ) |
Definition at line 1765 of file path_util.c.
Referenced by BLI_dir_create_recursive(), BLI_make_file_string(), BLI_path_abs(), BLI_path_basename(), BLI_path_filename_ensure(), BLI_path_frame_get(), BLI_path_frame_strip(), BLI_path_rel(), BLI_path_sequence_decode(), BLI_split_dirfile(), BLO_library_path_explode(), check_destination(), ensure_digits(), file_browse_exec(), file_browse_invoke(), blender::io::obj::get_image_filepath(), groupname_to_code(), image_file_browse_invoke(), is_hidden_dot_filename(), uiTemplateImageInfo(), uiTemplateMovieclipInformation(), where_am_i(), and wm_open_mainfile_check().
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 1791 of file path_util.c.
Referenced by BLI_dir_create_recursive(), file_path_to_ui_path(), preferences_asset_library_add_exec(), and strip_last_slash().
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
string | original (and final) string |
maxlen | Maximum length of string |
suffix | String to append to the original string |
sep | Optional separator character |
Definition at line 588 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().
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 859 of file path_util.c.
References BLI_path_extension_replace(), BLI_str_replace_char(), BLI_strncpy(), and ELEM.
Referenced by blender::io::usd::import_startjob(), and workspace_add_invoke().
|
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 363 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().
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 1143 of file path_util.c.
References uputenv().
Referenced by arg_handle_env_system_set(), and BLI_setenv_if_new().
void BLI_setenv_if_new | ( | const char * | env, |
const char * | val | ||
) |
Only set an environment variable if already not there. Like Unix setenv(env, val, 0);
(not used anywhere).
Definition at line 1161 of file path_util.c.
References BLI_getenv(), BLI_setenv(), and NULL.
void BLI_split_dir_part | ( | const char * | string, |
char * | dir, | ||
size_t | dirlen | ||
) |
Copies the parent directory part of string into dir
, max length dirlen
.
Definition at line 1490 of file path_util.c.
References BLI_split_dirfile(), and NULL.
Referenced by autocomplete_directory(), BKE_appdir_program_path_init(), BKE_asset_library_find_suitable_root_path_from_path(), BKE_image_tile_filepath_exists(), BLI_make_existing_file(), BLO_write_file(), blender::io::obj::obj_exporter_regression_test::compare_obj_export_to_golden(), blender::io::obj::export_frame(), blender::io::usd::export_texture(), file_sfile_filepath_set(), fileselect_initialize_params_common(), blender::bke::AssetCatalogService::find_suitable_cdf_path_for_writing(), blender::io::usd::get_tex_image_asset_path(), image_foreach_path(), image_save_sequence_exec(), blender::io::obj::MTLParser::MTLParser(), sequencer_add_image_strip_load_files(), WM_file_autoexec_init(), blender::io::obj::MTLWriter::write_materials(), blender::bke::AssetCatalogDefinitionFile::write_to_disk_unsafe(), and DocumentImporter::writeImage().
void BLI_split_dirfile | ( | const char * | string, |
char * | dir, | ||
char * | file, | ||
size_t | dirlen, | ||
size_t | filelen | ||
) |
Converts /foo/bar.txt
to /foo/
and bar.txt
Definition at line 1465 of file path_util.c.
References BLI_path_slash_rfind(), BLI_strncpy(), file, and MIN2.
Referenced by BKE_bpath_foreach_path_dirfile_fixed_process(), BKE_image_get_tile_info(), BLI_file_is_writable(), BLI_split_dir_part(), BLI_split_file_part(), clip_drop_copy(), do_versions_nodetree_multi_file_output_format_2_62_1(), file_directory_enter_handle(), file_execute(), file_operator_to_sfile(), file_sfile_filepath_set(), fileselect_ensure_updated_file_params(), get_index_dir(), get_proxy_fname(), IMB_anim_get_fname(), lib_relocate(), render_result_exr_file_cache_path(), SEQ_add_movie_strip(), seq_disk_cache_add_file_to_list(), seq_disk_cache_get_files(), sequencer_drop_copy(), TEST(), ui_but_menu_add_path_operators(), unpack_generate_paths(), and blender::io::obj::OBJWriter::write_mtllib_name().
void BLI_split_file_part | ( | const char * | string, |
char * | file, | ||
size_t | filelen | ||
) |
Copies the leaf filename part of string into file
, max length filelen
.
Definition at line 1495 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(), block_create_save_file_forwardcompat_dialog(), blender::io::usd::copy_single_file(), blender::io::usd::copy_tiled_textures(), draw_seq_in_view(), blender::io::usd::export_in_memory_texture(), blender::ed::asset::index::BlendFile::get_filename(), blender::io::usd::get_tex_image_asset_path(), image_foreach_path(), preferences_asset_library_add_exec(), ptcache_path(), seq_disk_cache_get_project_dir(), studiolight_add_file(), unpack_menu(), and volume_import_exec().
|
static |
Ensure path
contains at least one "#" character in its last slash-separated component, appending one digits long if not.
Definition at line 691 of file path_util.c.
References BLI_path_slash_rfind(), file, len, and NULL.
Referenced by BLI_path_frame(), and BLI_path_frame_range().
|
static |
Definition at line 1287 of file path_util.c.
References BLI_assert, BLI_strcasecmp(), and str.
Referenced by BLI_path_extension_check(), BLI_path_extension_check_array(), and BLI_path_extension_check_n().
|
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 655 of file path_util.c.
References ELEM.
Referenced by BLI_path_frame(), BLI_path_frame_check_chars(), and BLI_path_frame_range().