Blender V4.3
BLI_path_utils.hh File Reference

Go to the source code of this file.

Macros

Current & Parent Directory Defines/Macros
#define FILENAME_PARENT   ".."
 
#define FILENAME_CURRENT   "."
 
#define FILENAME_IS_PARENT(_n)   (((_n)[0] == '.') && ((_n)[1] == '.') && ((_n)[2] == '\0'))
 
#define FILENAME_IS_CURRENT(_n)   (((_n)[0] == '.') && ((_n)[1] == '\0'))
 
#define FILENAME_IS_CURRPAR(_n)    (((_n)[0] == '.') && (((_n)[1] == '\0') || (((_n)[1] == '.') && ((_n)[2] == '\0'))))
 

Functions

Path Parent Operations
bool BLI_path_parent_dir (char *path) ATTR_NONNULL(1)
 
bool BLI_path_parent_dir_until_exists (char *path) ATTR_NONNULL(1)
 
const char * BLI_path_parent_dir_end (const char *path, size_t path_len) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
Path Make Safe / Sanitize
bool BLI_path_make_safe_filename_ex (char *filename, bool allow_tokens) ATTR_NONNULL(1)
 
bool BLI_path_make_safe_filename (char *filename) ATTR_NONNULL(1)
 
bool BLI_path_make_safe (char *path) ATTR_NONNULL(1)
 
void BLI_path_to_display_name (char *display_name, int display_name_maxncpy, const char *name) ATTR_NONNULL(1
 
Path Normalize
int BLI_path_normalize (char *path) ATTR_NONNULL(1)
 
int BLI_path_normalize_native (char *path) ATTR_NONNULL(1)
 
int BLI_path_normalize_dir (char *dir, size_t dir_maxncpy) ATTR_NONNULL(1)
 
Path Canonicalize
int BLI_path_canonicalize_native (char *path, int path_maxncpy)
 
Path FileName Manipulation
bool BLI_path_filename_ensure (char *filepath, size_t filepath_maxncpy, const char *filename) ATTR_NONNULL(1
 
bool bool BLI_path_suffix (char *path, size_t path_maxncpy, const char *suffix, const char *sep) ATTR_NONNULL(1
 
Path Slash Utilities
const char * BLI_path_slash_find (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
const char * BLI_path_slash_rfind (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
int BLI_path_slash_ensure_ex (char *path, size_t path_maxncpy, const size_t path_len) ATTR_NONNULL(1)
 
int BLI_path_slash_ensure (char *path, size_t path_maxncpy) ATTR_NONNULL(1)
 
void BLI_path_slash_rstrip (char *path) ATTR_NONNULL(1)
 
const char * BLI_path_slash_skip (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
void BLI_path_slash_native (char *path) ATTR_NONNULL(1)
 
Path Directory/FileName Split
void BLI_path_split_dir_file (const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
 
void void BLI_path_split_dir_part (const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
 
void void void BLI_path_split_file_part (const char *filepath, char *file, size_t file_maxncpy) ATTR_NONNULL(1
 
void void void const char * BLI_path_basename (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
Path Filtering Utilities
bool BLI_path_has_hidden_component (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
Path Append
size_t BLI_path_append (char *__restrict dst, size_t dst_maxncpy, const char *__restrict file) ATTR_NONNULL(1
 
size_t size_t BLI_path_append_dir (char *__restrict dst, size_t dst_maxncpy, const char *__restrict dir) ATTR_NONNULL(1
 
Path File Extensions
const char * BLI_path_extension_or_end (const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
 
const char * BLI_path_extension (const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
bool BLI_path_extension_check (const char *path, const char *ext) ATTR_NONNULL(1
 
bool BLI_path_extension_check_n (const char *path,...) ATTR_NONNULL(1) ATTR_SENTINEL(0)
 
bool BLI_path_extension_check_array (const char *path, const char **ext_array) ATTR_NONNULL(1
 
bool BLI_path_extension_check_glob (const char *path, const char *ext_fnmatch) ATTR_NONNULL(1
 
bool BLI_path_extension_glob_validate (char *ext_fnmatch) ATTR_NONNULL(1)
 
bool BLI_path_extension_replace (char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
 
bool bool BLI_path_extension_strip (char *path) ATTR_NONNULL(1)
 
bool BLI_path_extension_ensure (char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
 
Program Specific Path Functions
bool BLI_path_program_search (char *program_filepath, size_t program_filepath_maxncpy, const char *program_name) ATTR_NONNULL(1
 
Blender Specific Frame Sequence Encode/Decode
void BLI_path_sequence_encode (char *path, size_t path_maxncpy, const char *head, const char *tail, unsigned short numlen, int pic)
 
int BLI_path_sequence_decode (const char *path, char *head, size_t head_maxncpy, char *tail, size_t tail_maxncpy, unsigned short *r_digits_len)
 
Blender Specific Frame Number Apply/Strip
bool BLI_path_frame (char *path, size_t path_maxncpy, int frame, int digits) ATTR_NONNULL(1)
 
bool BLI_path_frame_range (char *path, size_t path_maxncpy, int sta, int end, int digits) ATTR_NONNULL(1)
 
bool BLI_path_frame_get (const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1
 
bool void BLI_path_frame_strip (char *path, char *r_ext, size_t ext_maxncpy) ATTR_NONNULL(1
 
bool void bool BLI_path_frame_check_chars (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
Current Working Directory Specific Paths
bool BLI_path_is_abs_from_cwd (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
bool BLI_path_abs_from_cwd (char *path, size_t path_maxncpy) ATTR_NONNULL(1)
 
OS Level Wrappers

TODO: move these to a different module, they are not path functions.

void BLI_setenv (const char *env, const char *val) ATTR_NONNULL(1)
 
void BLI_setenv_if_new (const char *env, const char *val) ATTR_NONNULL(1)
 
const char * BLI_getenv (const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 

Path Join

#define BLI_path_join(...)   VA_NARGS_CALL_OVERLOAD(_BLI_path_join_, __VA_ARGS__)
 
#define _BLI_PATH_JOIN_ARGS_1   char *__restrict dst, size_t dst_maxncpy, const char *a
 
#define _BLI_PATH_JOIN_ARGS_2   _BLI_PATH_JOIN_ARGS_1, const char *b
 
#define _BLI_PATH_JOIN_ARGS_3   _BLI_PATH_JOIN_ARGS_2, const char *c
 
#define _BLI_PATH_JOIN_ARGS_4   _BLI_PATH_JOIN_ARGS_3, const char *d
 
#define _BLI_PATH_JOIN_ARGS_5   _BLI_PATH_JOIN_ARGS_4, const char *e
 
#define _BLI_PATH_JOIN_ARGS_6   _BLI_PATH_JOIN_ARGS_5, const char *f
 
#define _BLI_PATH_JOIN_ARGS_7   _BLI_PATH_JOIN_ARGS_6, const char *g
 
#define _BLI_PATH_JOIN_ARGS_8   _BLI_PATH_JOIN_ARGS_7, const char *h
 
#define _BLI_PATH_JOIN_ARGS_9   _BLI_PATH_JOIN_ARGS_8, const char *i
 
#define _BLI_PATH_JOIN_ARGS_10   _BLI_PATH_JOIN_ARGS_9, const char *j
 
size_t BLI_path_join_array (char *__restrict dst, const size_t dst_maxncpy, const char *path_array[], const int path_array_num) ATTR_NONNULL(1
 
BLI_INLINE size_t _BLI_path_join_3 (_BLI_PATH_JOIN_ARGS_1) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_4 (_BLI_PATH_JOIN_ARGS_2) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_5 (_BLI_PATH_JOIN_ARGS_3) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_6 (_BLI_PATH_JOIN_ARGS_4) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_7 (_BLI_PATH_JOIN_ARGS_5) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_8 (_BLI_PATH_JOIN_ARGS_6) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_9 (_BLI_PATH_JOIN_ARGS_7) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_10 (_BLI_PATH_JOIN_ARGS_8) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_11 (_BLI_PATH_JOIN_ARGS_9) ATTR_NONNULL()
 
BLI_INLINE size_t _BLI_path_join_12 (_BLI_PATH_JOIN_ARGS_10) ATTR_NONNULL()
 

Path Comparison / Contains

#define BLI_path_cmp   strcmp
 
#define BLI_path_ncmp   strncmp
 
int BLI_path_cmp_normalized (const char *p1, const char *p2) ATTR_NONNULL(1
 
bool BLI_path_contains (const char *container_path, const char *containee_path) ATTR_NONNULL(1
 

Blender Specific File Relative Paths

#define FILE_MAXDIR   768
 
#define FILE_MAXFILE   256
 
#define FILE_MAX   1024
 
bool BLI_path_abs (char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
 
bool void BLI_path_rel (char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
 
bool BLI_path_is_rel (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 

Native Slash Defines & Checks

#define SEP   '/'
 
#define ALTSEP   '\\'
 
#define SEP_STR   "/"
 
#define ALTSEP_STR   "\\"
 
BLI_INLINE bool BLI_path_slash_is_native_compat (const char ch)
 

Path Queries

bool ATTR_WARN_UNUSED_RESULT
 
bool BLI_path_name_at_index (const char *__restrict path, int index, int *__restrict r_offset, int *__restrict r_len) ATTR_NONNULL(1
 
bool BLI_path_is_unc (const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
bool BLI_path_is_win32_drive (const char *path)
 
bool BLI_path_is_win32_drive_only (const char *path)
 
bool BLI_path_is_win32_drive_with_slash (const char *path)
 

Macro Definition Documentation

◆ _BLI_PATH_JOIN_ARGS_1

#define _BLI_PATH_JOIN_ARGS_1   char *__restrict dst, size_t dst_maxncpy, const char *a

Definition at line 370 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_10

#define _BLI_PATH_JOIN_ARGS_10   _BLI_PATH_JOIN_ARGS_9, const char *j

Definition at line 379 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_2

#define _BLI_PATH_JOIN_ARGS_2   _BLI_PATH_JOIN_ARGS_1, const char *b

Definition at line 371 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_3

#define _BLI_PATH_JOIN_ARGS_3   _BLI_PATH_JOIN_ARGS_2, const char *c

Definition at line 372 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_4

#define _BLI_PATH_JOIN_ARGS_4   _BLI_PATH_JOIN_ARGS_3, const char *d

Definition at line 373 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_5

#define _BLI_PATH_JOIN_ARGS_5   _BLI_PATH_JOIN_ARGS_4, const char *e

Definition at line 374 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_6

#define _BLI_PATH_JOIN_ARGS_6   _BLI_PATH_JOIN_ARGS_5, const char *f

Definition at line 375 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_7

#define _BLI_PATH_JOIN_ARGS_7   _BLI_PATH_JOIN_ARGS_6, const char *g

Definition at line 376 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_8

#define _BLI_PATH_JOIN_ARGS_8   _BLI_PATH_JOIN_ARGS_7, const char *h

Definition at line 377 of file BLI_path_utils.hh.

◆ _BLI_PATH_JOIN_ARGS_9

#define _BLI_PATH_JOIN_ARGS_9   _BLI_PATH_JOIN_ARGS_8, const char *i

Definition at line 378 of file BLI_path_utils.hh.

◆ ALTSEP

◆ ALTSEP_STR

◆ BLI_path_cmp

◆ BLI_path_join

#define BLI_path_join ( ...)    VA_NARGS_CALL_OVERLOAD(_BLI_path_join_, __VA_ARGS__)

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

Parameters
pathThe first patch which has special treatment, allowing // prefix which is kept intact unlike double-slashes which are stripped from the bounds of all other paths passed in. Passing in the following paths all result in the same output (//a/b/c):
  • "//", "a", "b", "c".
  • "//", "/a/", "/b/", "/c".
  • "//a", "b/c".
Note
If you want a trailing slash, add SEP_STR as the last path argument, duplicate slashes will be cleaned up.

Definition at line 368 of file BLI_path_utils.hh.

Referenced by blender::asset_system::asset_definition_default_file_path_from_dir(), autocomplete_directory(), blender::ed::object::bake_simulation::bake_directory_has_data(), blender::ed::object::bake_simulation::bake_geometry_nodes_startjob(), MANTA::bakeData(), MANTA::bakeGuiding(), MANTA::bakeMesh(), MANTA::bakeNoise(), MANTA::bakeParticles(), BKE_appdir_app_template_has_userpref(), BKE_appdir_app_template_id_search(), BKE_appdir_folder_caches(), BKE_appdir_folder_documents(), BKE_appdir_program_python_search(), BKE_blendfile_userdef_write_all(), BKE_bpath_foreach_path_dirfile_fixed_process(), BKE_image_get_tile_info(), BKE_image_save_options_init(), BKE_memfile_undo_encode(), BKE_modifier_path_init(), BKE_preferences_asset_library_default_add(), BKE_preferences_extension_repo_dirpath_get(), BKE_preferences_extension_repo_user_dirpath_get(), BKE_ptcache_disk_cache_rename(), BKE_ptcache_id_clear(), BlendfileLoadingBaseTest::blendfile_load(), blf_load_font_default(), BLI_path_abs_from_cwd(), BPY_python_start(), blender::io::hydra::cache_or_get_image_file(), blender::seq::check_media_missing(), blender::ed::object::collection_exporter_export(), colormanagement_init(), blender::io::usd::copy_asset_to_directory(), blender::io::usd::copy_single_file(), blender::io::usd::copy_tiled_textures(), blender::io::usd::copy_udim_asset_to_directory(), blender::io::usd::create_temp_path_for_usdz_export(), draw_seq_text_get_source(), dynamicPaint_bakeImageSequence(), ED_file_read_bookmarks(), ED_fsmenu_entry_set_name(), ED_fsmenu_entry_set_path(), blender::io::usd::export_endjob_usdz_cleanup(), blender::io::usd::export_in_memory_texture(), blender::io::usd::export_packed_texture(), blender::io::usd::export_texture(), MANTA::exportLiquidScript(), MANTA::exportSmokeScript(), file_draw_check_exists(), file_expand_directory(), file_filename_enter_handle(), file_sfile_to_operator_ex(), fileentry_uiname(), filelist_file_get_full_path(), filelist_readjob_list_dir(), blender::asset_system::AssetCatalogService::find_suitable_cdf_path_for_writing(), fluid_bake_startjob(), Freestyle_Init(), blender::bke::bake::BakePath::from_single_root(), fsmenu_read_system(), fsmenu_write_file_and_refresh_or_report_error(), fsmenu_xdg_insert_entry(), fsmenu_xdg_user_dirs_parse(), blender::asset_system::AssetRepresentation::full_path(), blender::bke::bake::get_default_modifier_bake_directory(), blender::bke::bake::get_default_node_bake_directory(), blender::io::usd::get_image_cache_file(), get_index_dir(), blender::bke::bake::get_node_bake_path(), blender::seq::get_path_from_seq(), get_path_local_ex(), get_proxy_filepath(), blender::ui::string_search::get_recent_searches_file_path(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::get_single_layer_image_base_path(), get_tc_filepath(), blender::io::usd::get_tex_image_asset_filepath(), blender::io::usd::get_tex_image_asset_filepath(), blender::compositor::DebugInfo::graphviz(), blender::io::usd::image_cache_file_path(), image_foreach_path(), image_sequence_get_frame_ranges(), load_data_init_from_operator(), blender::tests::ChangeWorkingDirectoryTest::make_pseudo_unique_temp_filename(), make_temp_filepath(), material_copybuffer_filepath_get(), missing_files_find__recursive(), blender::io::obj::MTLParser::MTLParser(), new_folder_path(), open_exec(), blender::ed::outliner::outliner_copybuffer_filepath_get(), path_destination_ensure_filename(), blender::io::path_reference(), blender::ed::io::paths_from_operator_properties(), blender::io::usd::perform_usdz_conversion(), pose_copybuffer_filepath_get(), blender::bke::bake::DiskBlobReader::read(), renamebutton_cb(), render_result_exr_file_cache_path(), SEQ_add_image_init_alpha_mode(), SEQ_add_reload_new_file(), seq_disk_cache_get_dir(), seq_disk_cache_get_project_dir(), seq_disk_cache_handle_versioning(), seq_doversion_250_sound_proxy_update_cb(), seq_open_anim_file(), seq_proxy_get_custom_file_filepath(), seq_proxy_index_dir_set(), seq_proxy_multiview_context_invalid(), seq_render_image_strip(), sequencer_add_movie_multiple_strips(), sequencer_add_sound_multiple_strips(), sequencer_change_path_invoke(), sequencer_copybuffer_filepath_get(), blender::ed::asset::set_filepath_for_asset_lib(), blender::io::usd::UsdUsdzExportTest::SetUp(), sig_handle_crash(), blender::io::usd::temp_textures_dir(), blender::seq::thumbnail_cache_invalidate_strip(), blender::bke::bake::unpack_bake_to_disk(), unpack_generate_paths(), unpack_menu(), blender::io::hydra::USDSceneDelegate::USDSceneDelegate(), view3d_copybuffer_filepath_get(), wm_autosave_delete(), wm_autosave_location(), wm_block_splash_create(), wm_block_splash_image(), WM_exit_ex(), WM_file_recover_last_session(), wm_history_file_read(), wm_history_file_write(), wm_homefile_read_ex(), wm_homefile_write_exec(), wm_init_splash_show_on_startup_check(), wm_lib_relocate_exec_do(), wm_link_append_exec(), wm_platform_support_check_approval(), workspace_config_file_read(), workspace_system_file_read(), blender::io::usd::world_material_to_dome_light(), blender::bke::bake::DiskBlobWriter::write(), blender::bke::bake::DiskBlobWriter::write_as_stream(), and DocumentImporter::writeImage().

◆ BLI_path_ncmp

◆ FILE_MAX

#define FILE_MAX   1024

Definition at line 657 of file BLI_path_utils.hh.

Referenced by absolute_convert_foreach_path_cb(), appdir_app_template_directories(), blender::io::obj::append_frame_to_filename(), arg_handle_python_file_run(), blender::ed::asset::asset_bundle_install_exec(), blender::bke::asset_root_path_for_save(), blender::bke::asset_weak_reference_for_user_library(), autocomplete_directory(), autocomplete_file(), blender::ed::object::bake_simulation::bake_directory_has_data(), blender::ed::object::bake_simulation::bake_geometry_nodes_startjob(), blender::ed::object::bake_simulation::bake_simulation_get_path_users(), blender::ed::object::bake_targets_output_external(), MANTA::bakeData(), MANTA::bakeGuiding(), MANTA::bakeMesh(), MANTA::bakeNoise(), MANTA::bakeParticles(), BKE_appdir_app_template_has_userpref(), BKE_appdir_folder_id(), BKE_appdir_folder_id_user_notest(), BKE_appdir_resource_path_id_with_version(), BKE_blendfile_append(), BKE_blendfile_userdef_write_all(), BKE_bpath_foreach_path_allocated_process(), BKE_bpath_foreach_path_dirfile_fixed_process(), BKE_bpath_foreach_path_fixed_process(), BKE_cachefile_eval(), BKE_cachefile_filepath_get(), BKE_image_get_tile_info(), BKE_image_load_exists_in_lib(), BKE_image_load_in_lib(), BKE_image_memorypack(), BKE_image_packfiles(), BKE_image_render_write(), BKE_image_set_filepath_from_tile_number(), BKE_image_signal(), BKE_image_user_file_path_ex(), BKE_memfile_undo_encode(), BKE_movieclip_file_add(), BKE_movieclip_file_add_exists_ex(), BKE_movieclip_filepath_for_frame(), BKE_packedfile_compare_to_file(), BKE_packedfile_new(), BKE_packedfile_unpack(), BKE_packedfile_unpack_to_file(), BKE_packedfile_write_to_file(), BKE_scene_multiview_filepath_get(), BKE_scene_multiview_view_filepath_get(), BKE_scene_undo_depsgraphs_restore(), 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(), BKE_volume_load(), BlendfileLoadingBaseTest::blendfile_load(), blf_load_font_default(), BLI_change_working_dir(), BLI_dir_create_recursive(), BLI_expand_tilde(), BLI_file_ensure_parent_dir_exists(), BLI_file_is_writable(), BLI_path_abs(), BLI_path_rel(), blo_find_main(), BLO_write_file_impl(), block_create__close_file_dialog(), block_create_save_file_overwrite_dialog(), bpy_lib_write(), BPY_python_start(), blender::ed::sculpt_paint::brush_asset_load_preview_exec(), build_pict_list_from_image_sequence(), blender::gpu::cache_dir_get(), blender::io::hydra::cache_or_get_image_file(), cachefile_layer_add_exec(), cachefile_layer_open_invoke(), cachefile_open_exec(), cachefile_open_invoke(), blender::seq::check_media_missing(), blender::seq::check_sound_media_missing(), clip_drop_copy(), blender::ed::object::collection_exporter_export(), colormanagement_init(), console_drop_path_copy(), blender::io::usd::copy_asset_to_directory(), copy_material_exec(), blender::io::usd::copy_single_file(), blender::io::usd::copy_tiled_textures(), blender::io::usd::copy_udim_asset_to_directory(), blender::io::alembic::create_archive(), blender::io::usd::create_temp_path_for_usdz_export(), customdata_external_filename(), CustomData_external_read(), CustomData_external_write(), detect_clip_source(), do_history(), do_makepicstring(), do_versions_nodetree_multi_file_output_format_2_62_1(), do_write_image_or_movie(), blender::nodes::draw_common_bake_settings(), draw_seq_in_view(), draw_seq_text_get_overlay_string(), draw_seq_text_overlay(), drop_import_file_copy(), dynamicPaint_bakeImageSequence(), dynamicPaint_outputSurfaceImage(), ED_file_path_button(), ED_file_read_bookmarks(), ED_fileselect_ensure_default_filepath(), ED_image_filesel_detect_sequences(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::execute_multi_layer(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::execute_single_layer(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::execute_single_layer_multi_view_exr(), blender::io::usd::export_endjob_usdz_cleanup(), blender::io::obj::export_frame(), blender::io::stl::export_frame(), blender::io::usd::export_in_memory_texture(), blender::io::usd::export_packed_texture(), blender::io::usd::export_texture(), blender::io::obj::exporter_main(), MANTA::exportLiquidScript(), MANTA::exportSmokeScript(), file_browse_exec(), file_browse_invoke(), file_directory_new_exec(), file_draw_check_exists(), file_draw_tooltip_custom_func(), file_execute(), file_external_operation_exec(), file_filename_enter_handle(), file_handler_import_operator_create_ptr(), blender::bke::bake::file_name_to_frame(), file_operator_to_sfile(), FILE_OT_directory_new(), FILE_OT_external_operation(), FILE_OT_filepath_drop(), file_select_do(), file_select_match(), file_sfile_to_operator(), file_sfile_to_operator_ex(), filelist_readjob_list_dir(), filepath_drop_exec(), blender::ed::io::filesel_drop_import_invoke(), fileselect_ensure_updated_file_params(), fluid_bake_startjob(), fluid_validatepaths(), font_open_exec(), blender::bke::bake::frame_to_file_name(), Freestyle_Init(), blender::bke::bake::BakePath::from_single_root(), fsmenu_read_system(), fsmenu_write_file(), fsmenu_write_file_and_refresh_or_report_error(), fsmenu_xdg_user_dirs_parse(), blender::asset_system::AssetRepresentation::full_path(), blender::io::usd::get_absolute_path(), blender::bke::bake::get_blend_file_name(), blender::bke::bake::get_default_modifier_bake_directory(), blender::bke::bake::get_default_node_bake_directory(), get_drag_path(), blender::ed::asset::index::BlendFile::get_filename(), blender::io::usd::get_image_cache_file(), blender::io::obj::get_image_filepath(), blender::io::usd::get_in_memory_texture_filename(), blender::bke::bake::get_modifier_bake_path(), blender::bke::bake::get_node_bake_path(), get_path_environment_ex(), blender::seq::get_path_from_seq(), get_path_local_ex(), get_path_system_ex(), get_path_user_ex(), get_proxy_filepath(), blender::ui::string_search::get_recent_searches_file_path(), blender::io::usd::get_relative_path(), get_sequence_filepath(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::get_single_layer_image_base_path(), blender::io::usd::get_tex_image_asset_filepath(), blender::io::usd::get_tex_image_asset_filepath(), blender::io::usd::get_tex_image_asset_filepath(), get_thumb_dir(), get_udim_tiles(), Freestyle::StringUtils::getPathName(), blender::compositor::DebugInfo::graphviz(), handle_load_file(), icon_preview_imbuf_from_brush(), image_abs_path(), blender::io::usd::image_cache_file_path(), image_file_browse_exec(), image_file_browse_invoke(), image_foreach_path(), image_init_color_management(), image_replace_exec(), image_save_sequence_exec(), image_save_single(), image_sequence_get_frame_ranges(), image_update_views_format(), IMB_anim_index_rebuild_context(), IMB_anim_open_index(), IMB_anim_open_proxy(), IMB_anim_proxy_get_existing(), IMB_thumb_delete(), IMB_thumb_makedirs(), IMB_thumb_manage(), IMB_thumb_read(), blender::io::usd::import_asset(), blender::io::ply::import_mesh(), blender::io::ply::importer_main(), blender::io::stl::importer_main(), index_dir_set(), blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path(), lib_id_library_local_paths_callback(), lib_id_load_custom_preview_exec(), blender::ed::outliner::lib_relocate(), load_image_single(), load_movie_single(), Freestyle::Controller::LoadMesh(), blender::tests::ChangeWorkingDirectoryTest::make_pseudo_unique_temp_filename(), make_temp_filepath(), meshcache_do(), missing_files_find__recursive(), missing_files_find_foreach_path_cb(), movieclip_build_proxy_ibuf(), movieclip_calc_length(), movieclip_load_sequence_file(), movieclip_open_anim_file(), blender::io::obj::MTLParser::MTLParser(), blender::io::obj::MTLWriter::MTLWriter(), blender::ed::object::multires_external_save_exec(), blender::ed::object::multires_external_save_invoke(), blender::ed::outliner::namebutton_fn(), new_folder_path(), blender::ed::object::OBJECT_OT_bake(), open_anim_file_multiview(), open_exec(), open_invoke(), open_invoke(), blender::ed::outliner::outliner_id_copy_exec(), blender::ed::outliner::outliner_id_paste_exec(), PAINT_OT_image_from_view(), blender::io::usd::parent_dir_exists_on_file_system(), paste_material_exec(), blender::ed::io::paths_from_operator_properties(), blender::io::usd::perform_usdz_conversion(), playanim_toscreen_ex(), pose_paste_exec(), preferences_extension_repo_add_exec(), preferences_extension_repo_remove_exec(), preferences_extension_repo_remove_invoke(), prefetch_read_file_to_memory(), blender::io::usd::process_usdz_textures(), proxy_thread_next_frame(), python_script_exec(), RE_RenderAnim(), RE_RenderFrame(), blender::bke::bake::DiskBlobReader::read(), blender::io::grease_pencil::SVGImporter::read(), recursive_operation(), relative_convert_foreach_path_cb(), relative_rebase_foreach_path_cb(), renamebutton_cb(), render_result_exr_file_cache_path(), rigidbody_world_export_exec(), RNA_api_image(), RNA_api_scene(), RNA_api_scene_render(), rna_def_depsgraph(), rna_def_fluid_domain_settings(), RNA_def_main(), RNA_def_main_movieclips(), RNA_def_main_sounds(), RNA_def_main_texts(), rna_def_render_result(), run_pyfile_exec(), save_set_filepath(), scene_undo_depsgraph_gen_key(), screen_opengl_render_anim_step(), screen_opengl_render_write(), screenshot_exec(), screenshot_invoke(), SCRIPT_OT_python_file_run(), SEQ_add_image_init_alpha_mode(), SEQ_add_image_strip(), SEQ_add_movie_strip(), SEQ_add_reload_new_file(), seq_disk_cache_add_file_to_list(), seq_disk_cache_delete_invalid_files(), seq_disk_cache_get_dir(), seq_disk_cache_get_files(), seq_disk_cache_get_project_dir(), seq_disk_cache_handle_versioning(), seq_disk_cache_read_file(), seq_disk_cache_write_file(), seq_doversion_250_sound_proxy_update_cb(), SEQ_effect_text_font_load(), seq_open_anim_file(), seq_proxy_get_custom_file_filepath(), seq_proxy_index_dir_set(), seq_proxy_multiview_context_invalid(), seq_render_image_strip(), seq_render_image_strip_view(), sequence_guess_offset(), sequencer_add_movie_multiple_strips(), sequencer_add_sound_multiple_strips(), sequencer_change_path_exec(), sequencer_change_path_invoke(), sequencer_clipboard_copy_exec(), sequencer_clipboard_paste_exec(), sequencer_drop_copy(), sequencer_export_subtitles_exec(), sequencer_generic_invoke_path__internal(), sequencer_image_seq_reserve_frames(), blender::ed::asset::set_filepath_for_asset_lib(), blender::io::usd::UsdUsdzExportTest::SetUp(), blender::tests::FileOpsTest::SetUp(), sig_handle_crash(), sound_mixdown_exec(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::io::obj::TEST(), blender::io::obj::TEST(), blender::io::obj::TEST(), blender::tests::TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test_env_path(), blender::io::usd::TEST_F(), blender::tests::TEST_F(), text_jump_to_file_at_point_exec(), text_open_exec(), TEXT_OT_jump_to_file_at_point(), text_save_as_exec(), texture_paint_image_from_view_exec(), thumb_create_ex(), blender::seq::thumbnail_cache_invalidate_strip(), thumbpathname_from_uri(), txt_write_file(), ui_but_menu_add_path_operators(), ui_popup_context_menu_for_button(), ui_tooltip_from_clip(), ui_tooltip_from_image(), uiTemplateMovieclipInformation(), uiTemplateRecentFiles_tooltip_func(), blender::bke::bake::unpack_bake_to_disk(), unpack_generate_paths(), blender::bke::bake::unpack_geometry_nodes_bake(), unpack_menu(), uri_from_filename(), blender::io::usd::USD_path_abs(), blender::io::hydra::USDSceneDelegate::USDSceneDelegate(), user_frame_to_cache_frame(), view3d_copybuffer_exec(), VIEW3D_OT_camera_background_image_add(), view3d_pastebuffer_exec(), blender::ed::object::volume_import_exec(), wm_autosave_delete(), wm_autosave_location(), WM_autosave_write(), wm_autosave_write_try(), wm_block_splash_create(), wm_block_splash_image(), WM_exit_ex(), WM_file_autoexec_init(), WM_file_recover_last_session(), wm_file_write_check_with_report_on_failure(), wm_filepath_default(), wm_history_file_read(), wm_history_file_write(), wm_homefile_read_ex(), wm_homefile_read_exec(), wm_homefile_write_exec(), wm_homefile_write_invoke(), wm_init_splash_show_on_startup_check(), wm_lib_relocate_exec_do(), wm_link_append_exec(), wm_link_append_invoke(), wm_open_mainfile__open(), wm_open_mainfile_check(), wm_open_mainfile_get_description(), WM_operator_drop_load_path(), WM_operator_filesel_ensure_ext_imtype(), WM_operator_properties_filesel(), WM_OT_drop_import_file(), WM_OT_read_homefile(), wm_platform_support_check_approval(), wm_read_factory_settings_invoke(), wm_recover_auto_save_exec(), wm_recover_auto_save_invoke(), wm_revert_mainfile_exec(), wm_save_as_mainfile_exec(), wm_save_mainfile_check(), wm_userpref_read_invoke(), workspace_add_invoke(), workspace_append_activate_exec(), workspace_config_file_read(), WORKSPACE_OT_append_activate(), workspace_system_file_read(), blender::io::usd::world_material_to_dome_light(), blender::bke::bake::DiskBlobWriter::write(), blender::bke::bake::DiskBlobWriter::write_as_stream(), write_crash_blend(), blender::io::obj::MTLWriter::write_materials(), write_result(), and DocumentImporter::writeImage().

◆ FILE_MAXDIR

#define FILE_MAXDIR   768

These values need to be hard-coded in structs, DNA does not recognize defines (also defined in DNA_space_types.h).

Note
In general path functions should not depend on these hard coded limits, there is an exception for:
  • BLI_path_abs
  • BLI_path_rel These functions deal specifically with .blend file paths, where FILE_MAX assumed to be the limit of all paths passes into these functions.

Some parts of the API which use FILE_MAX which aren't specifically handling blend file paths, in most cases these can be updated to use PATH_MAX or a platform specific limit.

Definition at line 655 of file BLI_path_utils.hh.

Referenced by AS_asset_library_find_suitable_root_path_from_path(), BKE_appdir_folder_default(), BKE_appdir_folder_documents(), BKE_appdir_font_folder_default(), BKE_image_get_tile_info(), BKE_image_tile_filepath_exists(), BKE_main_merge(), BKE_preferences_asset_library_default_add(), bli_builddir(), BLI_dir_free_space(), BLI_file_alias_target(), BLI_file_alias_target(), BLI_file_attributes(), blender::io::hydra::cache_or_get_image_file(), do_versions_nodetree_multi_file_output_format_2_62_1(), ED_sequencer_select_sequence_single(), FILE_OT_select_bookmark(), filelist_cache_previews_push(), filelist_readjob_list_dir(), fluid_validatepaths(), folderlist_popdir(), fsmenu_read_bookmarks(), fsmenu_read_system(), fsmenu_xdg_insert_entry(), fsmenu_xdg_user_dirs_parse(), get_index_dir(), get_proxy_filepath(), get_tc_filepath(), image_foreach_path(), image_sequence_get_frame_ranges(), blender::io::usd::import_asset(), lib_id_library_local_paths_callback(), blender::ed::outliner::lib_relocate(), blender::io::obj::MTLParser::MTLParser(), relative_rebase_foreach_path_cb(), render_result_exr_file_cache_path(), seq_disk_cache_add_file_to_list(), sequencer_select_set_active(), blender::io::usd::temp_textures_dir(), ui_but_menu_add_path_operators(), ui_popup_context_menu_for_button(), unpack_generate_paths(), unpack_menu(), wm_lib_relocate_exec_do(), wm_link_append_exec(), and blender::io::obj::OBJWriter::write_mtllib_name().

◆ FILE_MAXFILE

◆ FILENAME_CURRENT

#define FILENAME_CURRENT   "."

Definition at line 779 of file BLI_path_utils.hh.

Referenced by bli_builddir().

◆ FILENAME_IS_CURRENT

#define FILENAME_IS_CURRENT ( _n)    (((_n)[0] == '.') && ((_n)[1] == '\0'))

Definition at line 783 of file BLI_path_utils.hh.

Referenced by bli_builddir(), compare_direntry_generic(), and direntry_cmp().

◆ FILENAME_IS_CURRPAR

◆ FILENAME_IS_PARENT

#define FILENAME_IS_PARENT ( _n)    (((_n)[0] == '.') && ((_n)[1] == '.') && ((_n)[2] == '\0'))

◆ FILENAME_PARENT

#define FILENAME_PARENT   ".."

◆ SEP

◆ SEP_STR

#define SEP_STR   "/"

Definition at line 719 of file BLI_path_utils.hh.

Function Documentation

◆ _BLI_path_join_10()

BLI_INLINE size_t _BLI_path_join_10 ( _BLI_PATH_JOIN_ARGS_8 )

Definition at line 427 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, BLI_path_join_array(), and e.

◆ _BLI_path_join_11()

BLI_INLINE size_t _BLI_path_join_11 ( _BLI_PATH_JOIN_ARGS_9 )

Definition at line 432 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, BLI_path_join_array(), and e.

◆ _BLI_path_join_12()

BLI_INLINE size_t _BLI_path_join_12 ( _BLI_PATH_JOIN_ARGS_10 )

Definition at line 437 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, BLI_path_join_array(), and e.

◆ _BLI_path_join_3()

BLI_INLINE size_t _BLI_path_join_3 ( _BLI_PATH_JOIN_ARGS_1 )

Definition at line 392 of file BLI_path_utils.hh.

References ARRAY_SIZE, and BLI_path_join_array().

◆ _BLI_path_join_4()

BLI_INLINE size_t _BLI_path_join_4 ( _BLI_PATH_JOIN_ARGS_2 )

Definition at line 397 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, and BLI_path_join_array().

◆ _BLI_path_join_5()

BLI_INLINE size_t _BLI_path_join_5 ( _BLI_PATH_JOIN_ARGS_3 )

Definition at line 402 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, and BLI_path_join_array().

◆ _BLI_path_join_6()

BLI_INLINE size_t _BLI_path_join_6 ( _BLI_PATH_JOIN_ARGS_4 )

Definition at line 407 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, and BLI_path_join_array().

◆ _BLI_path_join_7()

BLI_INLINE size_t _BLI_path_join_7 ( _BLI_PATH_JOIN_ARGS_5 )

Definition at line 412 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, BLI_path_join_array(), and e.

◆ _BLI_path_join_8()

BLI_INLINE size_t _BLI_path_join_8 ( _BLI_PATH_JOIN_ARGS_6 )

Definition at line 417 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, BLI_path_join_array(), and e.

◆ _BLI_path_join_9()

BLI_INLINE size_t _BLI_path_join_9 ( _BLI_PATH_JOIN_ARGS_7 )

Definition at line 422 of file BLI_path_utils.hh.

References ARRAY_SIZE, b, BLI_path_join_array(), and e.

◆ BLI_getenv()

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 1368 of file path_utils.cc.

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

Referenced by BKE_appdir_folder_home(), BLI_current_working_dir(), BLI_path_program_search(), BLI_setenv_if_new(), BLI_temp_directory_path_get(), BLT_lang_init(), BPY_python_start(), colormanagement_init(), fsmenu_read_system(), get_thumb_dir(), GHOST_WindowWin32::GHOST_WindowWin32(), imb_init_dds(), test_env_path(), and wm_block_splash_create().

◆ BLI_path_abs()

bool BLI_path_abs ( char path[FILE_MAX],
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 "//").

Referenced by absolute_convert_foreach_path_cb(), add_ibuf_for_tile(), blender::ed::object::bake_simulation::bake_simulation_get_path_users(), 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_exists_in_lib(), 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_filepath_for_frame(), BKE_packedfile_compare_to_file(), BKE_packedfile_new(), BKE_packedfile_unpack_to_file(), BKE_packedfile_write_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(), blo_find_main(), bookmark_select_exec(), bpy_lib_load(), bpy_lib_write(), blender::seq::check_media_missing(), blender::seq::check_sound_media_missing(), blender::ed::object::collection_exporter_export(), customdata_external_filename(), detect_clip_source(), direct_link_library(), do_makepicstring(), dynamicPaint_outputSurfaceImage(), file_browse_exec(), file_directory_enter_handle(), file_execute(), file_expand_directory(), file_filename_enter_handle(), file_operator_to_sfile(), file_parent_exec(), file_select_do(), filelist_readjob_recursive_dir_add_items(), filelist_setdir(), fileselect_ensure_updated_file_params(), fluid_bake_startjob(), fluid_validatepaths(), blender::io::usd::get_absolute_path(), get_drag_path(), blender::bke::bake::get_modifier_bake_path(), blender::bke::bake::get_node_bake_path(), blender::seq::get_path_from_seq(), get_proxy_filepath(), get_sequence_filepath(), icon_preview_imbuf_from_brush(), image_abs_path(), image_file_browse_exec(), image_file_browse_invoke(), image_save_options_from_op(), image_update_views_format(), blender::io::usd::import_asset(), blender::io::usd::import_startjob(), lib_id_library_local_paths_callback(), meshcache_do(), movieclip_open_anim_file(), blender::ed::outliner::namebutton_fn(), open_invoke(), open_invoke(), blender::io::path_reference(), proxy_dir_get(), ptcache_path(), blender::io::grease_pencil::SVGImporter::read(), relative_rebase_foreach_path_cb(), render_result_exr_file_cache_path(), screenshot_exec(), SEQ_add_image_init_alpha_mode(), SEQ_add_image_strip(), SEQ_add_movie_strip(), SEQ_add_reload_new_file(), seq_doversion_250_sound_proxy_update_cb(), SEQ_effect_text_font_load(), seq_open_anim_file(), seq_proxy_get_custom_file_filepath(), seq_proxy_get_filepath(), seq_proxy_multiview_context_invalid(), seq_render_image_strip(), sequencer_generic_invoke_path__internal(), sound_mixdown_exec(), blender::seq::thumbnail_cache_invalidate_strip(), txt_write_file(), blender::bke::bake::unpack_geometry_nodes_bake(), and blender::io::usd::USD_path_abs().

◆ BLI_path_abs_from_cwd()

bool BLI_path_abs_from_cwd ( char * path,
size_t path_maxncpy )

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 1217 of file path_utils.cc.

References BLI_current_working_dir(), BLI_path_is_abs_from_cwd(), BLI_path_join, BLI_string_debug_size_after_nil, PATH_MAX, printf, and STRNCPY.

Referenced by BLI_path_canonicalize_native(), BLI_temp_directory_path_copy_if_valid(), and where_am_i().

◆ BLI_path_append()

size_t BLI_path_append ( char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict file )

◆ BLI_path_append_dir()

size_t size_t BLI_path_append_dir ( char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict dir )

A version of BLI_path_append that ensures a trailing slash if there is space in dst.

Returns
The new length of dst.

Referenced by file_execute(), file_select_do(), and blender::io::usd::world_material_to_dome_light().

◆ BLI_path_basename()

void void void const char * BLI_path_basename ( const char * path)

Like Python's os.path.basename()

Returns
The pointer into path string immediately after last slash, or start of path if none found.

Definition at line 1778 of file path_utils.cc.

References BLI_path_slash_rfind().

Referenced by blender::ed::asset::asset_bundle_install_exec(), blender::bke::asset_weak_reference_for_essentials(), BKE_image_add_from_imbuf(), BKE_image_ensure_tile_token(), BKE_image_is_filename_tokenized(), BKE_image_load_in_lib(), BKE_movieclip_file_add(), BKE_preferences_extension_remote_to_name(), BKE_sound_new_file(), BKE_text_load_ex(), BKE_volume_load(), blf_font_new_impl(), BLI_path_filename_ensure(), BLI_path_frame_get(), BLI_path_frame_strip(), BLI_path_split_dir_file(), BLI_path_split_dir_part(), BLI_path_split_file_part(), blo_find_main(), blender::io::hydra::cache_or_get_image_file(), cachefile_open_exec(), blender::ed::object::collection_exporter_export(), blender::io::obj::OBJExportRegressionTest::compare_obj_export_to_golden(), blender::io::stl::STLExportTest::compare_to_golden(), blender::io::obj::create_placeholder_image(), blender::io::usd::create_temp_path_for_usdz_export(), ensure_digits(), blender::io::stl::export_frame(), fileentry_uiname(), blender::io::obj::get_image_filepath(), import_file(), blender::io::ply::import_mesh(), blender::io::usd::import_startjob(), blender::io::ply::importer_main(), 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(), path_destination_ensure_filename(), blender::io::path_reference(), preferences_extension_repo_add_exec(), report_duration(), report_duration(), seq_disk_cache_get_project_dir(), blender::ed::asset::set_filepath_for_asset_lib(), sig_handle_crash(), text_jump_to_file_at_point_external(), uiTemplateImageInfo(), uiTemplateMovieclipInformation(), uiTemplateRecentFiles(), wm_autosave_location(), wm_file_write(), WM_window_title(), and blender::io::obj::MTLWriter::write_header().

◆ BLI_path_canonicalize_native()

int BLI_path_canonicalize_native ( char * path,
int path_maxncpy )

Convert path to a canonical representation. This is intended for system paths (passed in as command-line arguments of via scripts) which are valid in that they resolve to a file/directory and but could be CWD relative or contain redundant slashes that cause absolute/relative conversion to fail. (specifically the "//" prefix used by Blender).

Perform the following operations:

  • Make absolute (relative to the current working directory).
  • Convert slash direction (WIN32 only, as other systems may use back-slashes in filenames).
  • Normalize redundant slashes.
  • Strip trailing slashes.

Definition at line 388 of file path_utils.cc.

References ALTSEP, BLI_path_abs_from_cwd(), BLI_path_normalize_native(), BLI_path_slash_is_native_compat(), BLI_path_slash_native(), and SEP.

Referenced by arg_handle_python_file_run(), BKE_appdir_program_path_init(), handle_load_file(), wm_open_mainfile__open(), wm_recover_auto_save_exec(), and wm_save_as_mainfile_exec().

◆ BLI_path_cmp_normalized()

int BLI_path_cmp_normalized ( const char * p1,
const char * p2 )

Returns the result of BLI_path_cmp with both paths normalized and slashes made native.

Note
BLI_path_cmp is used for Blender's internal logic to consider paths to be the same BLI_path_cmp_normalized may be used in when handling other kinds of paths (e.g. importers/exporters) but should be used consistently.

Checking the normalized paths is not a guarantee the paths reference different files. An equivalent to Python's os.path.samefile could be supported for checking if paths point to the same location on the file-system (following symbolic-links).

Referenced by blender::io::usd::UsdExportTest::compare_blender_image_to_usd_image_shader(), blender::io::usd::copy_single_file(), blender::io::usd::copy_tiled_textures(), blender::io::usd::export_in_memory_texture(), blender::ed::sculpt_paint::library_to_library_ref(), blender::ed::object::bake_simulation::PathStringEquality::operator()(), operator==(), blender::io::path_reference_copy(), TEST(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::tests::TEST_F().

◆ BLI_path_contains()

bool BLI_path_contains ( const char * container_path,
const char * containee_path )

◆ BLI_path_extension()

const char * BLI_path_extension ( const char * filepath)

◆ BLI_path_extension_check()

◆ BLI_path_extension_check_array()

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

◆ BLI_path_extension_check_glob()

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

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

Referenced by BKE_cachefile_eval(), and filelist_readjob_list_dir().

◆ BLI_path_extension_check_n()

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

◆ BLI_path_extension_ensure()

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

◆ 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 1477 of file path_utils.cc.

References ELEM.

Referenced by fileselect_ensure_updated_file_params().

◆ BLI_path_extension_or_end()

const char * BLI_path_extension_or_end ( const char * filepath)

Returns a pointer to the last extension (e.g. the position of the last period). Returns a pointer to the nil byte when no extension is found.

Definition at line 1612 of file path_utils.cc.

References ALTSEP, BLI_assert, and SEP.

Referenced by BLI_path_extension(), BLI_path_extension_ensure(), BLI_path_extension_replace(), BLI_path_frame_get(), BLI_path_frame_strip(), BLI_path_sequence_decode(), BLI_path_suffix(), blender::io::hydra::cache_image_file(), and WM_window_title().

◆ BLI_path_extension_replace()

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

◆ BLI_path_extension_strip()

◆ BLI_path_filename_ensure()

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

Ensure filepath has a file component, adding filename when it's empty or ends with a slash.

Returns
true if the filename was appended to filepath.

Referenced by wm_filepath_default().

◆ BLI_path_frame()

bool BLI_path_frame ( char * path,
size_t path_maxncpy,
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 955 of file path_utils.cc.

References BLI_string_debug_size_after_nil, BLI_string_replace_range(), ensure_digits(), FILENAME_FRAME_CHARS_MAX, path_frame_chars_find_range(), and SNPRINTF.

Referenced by blender::io::obj::append_frame_to_filename(), BKE_cachefile_filepath_get(), do_makepicstring(), dynamicPaint_bakeImageSequence(), get_proxy_filepath(), sequencer_image_seq_reserve_frames(), and TEST().

◆ BLI_path_frame_check_chars()

bool void 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 1052 of file path_utils.cc.

References path_frame_chars_find_range().

◆ BLI_path_frame_get()

bool BLI_path_frame_get ( const char * path,
int * r_frame,
int * r_digits_len )

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

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,
size_t path_maxncpy,
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 975 of file path_utils.cc.

References BLI_string_debug_size_after_nil, BLI_string_replace_range(), ensure_digits(), FILENAME_FRAME_CHARS_MAX, path_frame_chars_find_range(), and SNPRINTF.

◆ BLI_path_frame_strip()

bool void BLI_path_frame_strip ( char * path,
char * r_ext,
size_t ext_maxncpy )

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.

Referenced by BKE_cachefile_filepath_get(), and sequencer_image_seq_reserve_frames().

◆ BLI_path_has_hidden_component()

bool BLI_path_has_hidden_component ( const char * path)

Return true if any path component starts with a dot.

Definition at line 2019 of file path_utils.cc.

References ELEM.

Referenced by filelist_readjob_list_dir(), and TEST().

◆ BLI_path_is_abs_from_cwd()

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 1201 of file path_utils.cc.

Referenced by BLI_path_abs_from_cwd(), BLO_read_from_file(), BLO_write_file_impl(), blender::tests::TEST(), and TEST().

◆ BLI_path_is_rel()

bool BLI_path_is_rel ( const char * path)

◆ BLI_path_is_unc()

bool BLI_path_is_unc ( const char * path)

Return true if the path is a UNC share.

Definition at line 531 of file path_utils.cc.

Referenced by BLI_path_rel(), BLI_path_unc_prefix_len(), file_expand_directory(), TEST(), and uri_from_filename().

◆ BLI_path_is_win32_drive()

bool BLI_path_is_win32_drive ( const char * path)

Definition at line 566 of file path_utils.cc.

Referenced by path_normalize_impl(), TEST(), and uri_from_filename().

◆ BLI_path_is_win32_drive_only()

bool BLI_path_is_win32_drive_only ( const char * path)

Definition at line 571 of file path_utils.cc.

Referenced by dir_create_recursive(), file_expand_directory(), and TEST().

◆ BLI_path_is_win32_drive_with_slash()

bool BLI_path_is_win32_drive_with_slash ( const char * path)

Definition at line 576 of file path_utils.cc.

References ELEM.

Referenced by BLI_path_abs(), and TEST().

◆ BLI_path_join_array()

size_t BLI_path_join_array ( char *__restrict dst,
const size_t dst_maxncpy,
const char * path_array[],
const int path_array_num )

◆ BLI_path_make_safe()

bool BLI_path_make_safe ( char * path)

◆ BLI_path_make_safe_filename()

◆ BLI_path_make_safe_filename_ex()

bool BLI_path_make_safe_filename_ex ( char * filename,
bool allow_tokens )

Make given name safe to be used in paths.

Parameters
allow_tokensPermit 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.
Returns
true if filename 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 #45900). 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 411 of file path_utils.cc.

References BLI_str_tolower_ascii(), BLI_strdupn(), INVALID_CHARS, INVALID_TOKENS, len, MEM_freeN(), and NULL.

Referenced by BLI_path_make_safe_filename(), and file_filename_enter_handle().

◆ BLI_path_name_at_index()

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:

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

Ignored elements in the path:

  • Multiple slashes at any point in the path (including start/end).
  • Single '.' in the path: /./ except for the beginning of the path where it's used to signify a $PWD relative path.

Referenced by fsmenu_entry_generate_name().

◆ BLI_path_normalize()

int BLI_path_normalize ( char * path)

Remove redundant characters from path.

The following operations are performed:

  • Redundant path components such as //, /./ & ./ (prefix) are stripped. (with the exception of // prefix used for blend-file relative paths).
  • .. are resolved so <parent>/../<child>/ resolves to <child>/. Note that the resulting path may begin with .. if it's relative.

Details:

  • The slash direction is expected to be native (see SEP). When calculating a canonical paths you may need to run BLI_path_slash_native first. BLI_path_cmp_normalized can be used for canonical path comparison.
  • Trailing slashes are left intact (unlike Python which strips them).
  • Handling paths beginning with .. depends on them being absolute or relative. For absolute paths they are removed (e.g. /../path becomes /path). For relative paths they are kept as it's valid to reference paths above a relative location such as //../parent or ../parent.
Parameters
pathThe path to a file or directory which can be absolute or relative.
Returns
the length of path.

Definition at line 367 of file path_utils.cc.

References path_normalize_impl().

Referenced by blender::bke::asset_root_path_for_save(), BKE_preferences_extension_repo_add(), BLI_path_abs(), BLI_path_cmp_normalized(), BLI_path_contains(), BLI_path_normalize_dir(), BLI_path_rel(), blo_find_main(), BLO_write_file_impl(), blender::io::usd::copy_asset_to_directory(), direct_link_library(), blender::io::obj::export_frame(), blender::io::usd::get_absolute_path(), Freestyle::StringUtils::getPathName(), blender::io::usd::import_asset(), lib_id_library_local_paths_callback(), Freestyle::Controller::LoadMesh(), blender::asset_system::utils::normalize_path(), blender::ed::object::bake_simulation::PathStringHash::operator()(), blender::io::path_reference(), relative_rebase_foreach_path_cb(), and blender::io::obj::MTLWriter::write_materials().

◆ BLI_path_normalize_dir()

int BLI_path_normalize_dir ( char * dir,
size_t dir_maxncpy )

◆ BLI_path_normalize_native()

int BLI_path_normalize_native ( char * path)

A version of BLI_path_normalize without special handling of // blend file relative prefix.

Note
On UNIX //path is a valid path which gets normalized to /path.
Returns
the length of path.

Definition at line 372 of file path_utils.cc.

References path_normalize_impl().

Referenced by BKE_main_merge(), BLI_path_canonicalize_native(), file_execute(), get_path_local_ex(), and where_am_i().

◆ BLI_path_parent_dir()

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.

On success, the resulting path will always have a trailing slash.

Definition at line 859 of file path_utils.cc.

References BLI_assert, and BLI_path_name_at_index().

Referenced by BKE_preferences_asset_library_path_set(), bli_builddir(), BLI_path_parent_dir_until_exists(), file_execute(), file_parent_exec(), file_select_do(), and open_invoke().

◆ BLI_path_parent_dir_end()

const char * BLI_path_parent_dir_end ( const char * path,
size_t path_len )

In the simple case this is similar to BLI_path_slash_rfind(dirname) however it behaves differently when there are redundant characters:

/test///dir/./file ^ /test/dir/subdir//file ^

Returns
The position after the parent paths last character or NULL on failure. Neither path or &path[path_len - 1] are ever returned.

Definition at line 832 of file path_utils.cc.

References BLI_path_slash_is_native_compat().

Referenced by dir_create_recursive().

◆ BLI_path_parent_dir_until_exists()

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 885 of file path_utils.cc.

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 * program_filepath,
size_t program_filepath_maxncpy,
const char * program_name )

Search for a binary (executable)

Referenced by BKE_appdir_program_python_search(), and where_am_i().

◆ BLI_path_rel()

bool void BLI_path_rel ( char path[FILE_MAX],
const char * basepath )

◆ BLI_path_sequence_decode()

int BLI_path_sequence_decode ( const char * path,
char * head,
size_t head_maxncpy,
char * tail,
size_t tail_maxncpy,
unsigned short * r_digits_len )

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

Parameters
pathString to scan.
headOptional area to return copy of part of path prior to digits, or before dot if no digits.
tailOptional area to return copy of part of path following digits, or from dot if no digits.
r_digits_lenOptional to return number of digits found.

Definition at line 57 of file path_utils.cc.

References BLI_path_extension_or_end(), BLI_path_slash_rfind(), BLI_string_debug_size, BLI_strncpy(), int, and ret.

Referenced by BKE_image_sequence_guess_offset(), BKE_image_user_file_path_ex(), build_pict_list_from_image_sequence(), filenum_newname(), blender::io::obj::get_image_filepath(), get_sequence_filepath(), image_sequence_get_frame_ranges(), movieclip_calc_length(), put_imbuf_cache(), user_frame_to_cache_frame(), and wm_save_as_mainfile_exec().

◆ BLI_path_sequence_encode()

void BLI_path_sequence_encode ( char * path,
size_t path_maxncpy,
const char * head,
const char * tail,
unsigned short numlen,
int pic )

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

Definition at line 127 of file path_utils.cc.

References BLI_snprintf(), and BLI_string_debug_size.

Referenced by BKE_image_user_file_path_ex(), build_pict_list_from_image_sequence(), filenum_newname(), blender::io::obj::get_image_filepath(), get_sequence_filepath(), and wm_save_as_mainfile_exec().

◆ BLI_path_slash_ensure()

◆ BLI_path_slash_ensure_ex()

int BLI_path_slash_ensure_ex ( char * path,
size_t path_maxncpy,
const size_t path_len )

Appends a slash to path if there isn't one there already.

Parameters
path_lenThe length of path.
Returns
the new length of the path.

Definition at line 1925 of file path_utils.cc.

References BLI_assert, BLI_path_slash_is_native_compat(), BLI_string_debug_size_after_nil, and SEP.

Referenced by BLI_path_append_dir(), BLI_path_normalize_dir(), and BLI_path_slash_ensure().

◆ BLI_path_slash_find()

const char * BLI_path_slash_find ( const char * path)
Returns
pointer to the leftmost path separator in path (or NULL when not found).

Definition at line 1895 of file path_utils.cc.

Referenced by BKE_image_ensure_tile_token_filename_only(), BLI_path_make_safe(), blender::asset_system::AssetCatalogPath::iterate_components(), and TEST().

◆ BLI_path_slash_is_native_compat()

◆ BLI_path_slash_native()

◆ BLI_path_slash_rfind()

const char * BLI_path_slash_rfind ( const char * path)

◆ BLI_path_slash_rstrip()

void BLI_path_slash_rstrip ( char * path)

◆ BLI_path_slash_skip()

const char * BLI_path_slash_skip ( const char * path)
Returns
the next non-slash character or the null byte (when path only contains slashes).

Definition at line 1959 of file path_utils.cc.

References BLI_path_slash_is_native_compat().

Referenced by BLI_path_abs(), and uri_from_filename().

◆ BLI_path_split_dir_file()

◆ BLI_path_split_dir_part()

void void BLI_path_split_dir_part ( const char * filepath,
char * dir,
size_t dir_maxncpy )

◆ BLI_path_split_file_part()

◆ BLI_path_suffix()

bool bool BLI_path_suffix ( char * path,
size_t path_maxncpy,
const char * suffix,
const char * sep )

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

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

Parameters
pathoriginal (and final) string.
path_maxncpyMaximum length of path.
suffixString to append to the original path.
sepOptional separator character.
Returns
true if succeeded.

Referenced by blender::ed::object::bake_targets_output_external(), BKE_image_memorypack(), BKE_scene_multiview_filepath_get(), BKE_scene_multiview_view_filepath_get(), do_makepicstring(), and blender::io::stl::export_frame().

◆ BLI_path_to_display_name()

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

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

Referenced by blender::io::usd::import_startjob(), wm_homefile_write_invoke(), wm_read_factory_settings_invoke(), wm_userpref_read_invoke(), and workspace_add_invoke().

◆ 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 1345 of file path_utils.cc.

References uputenv().

Referenced by arg_handle_env_system_set(), BLI_change_working_dir(), BLI_setenv_if_new(), BPY_python_start(), and blender::render::hydra::Engine::Engine().

◆ 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 1361 of file path_utils.cc.

References BLI_getenv(), and BLI_setenv().

Variable Documentation

◆ ATTR_WARN_UNUSED_RESULT

bool ATTR_WARN_UNUSED_RESULT

Definition at line 34 of file BLI_path_utils.hh.