|
Blender V4.3
|
#include <algorithm>#include <cctype>#include <cstdlib>#include <cstring>#include "BLI_fileops.h"#include "BLI_fnmatch.h"#include "BLI_path_utils.hh"#include "BLI_string.h"#include "BLI_string_utils.hh"#include "BLI_utildefines.h"#include <unistd.h>#include "MEM_guardedalloc.h"Go to the source code of this file.
Macros | |
| #define | FILENAME_FRAME_CHARS_MAX FILE_MAX |
| #define | IS_PARENT_DIR(p) ((p)[0] == '.' && (p)[1] == '.' && ELEM((p)[2], SEP, '\0')) |
| #define | INVALID_CHARS |
| #define | INVALID_TOKENS "<>" |
Functions | |
| static int | BLI_path_unc_prefix_len (const char *path) |
| int | BLI_path_sequence_decode (const char *path, char *head, const size_t head_maxncpy, char *tail, const size_t tail_maxncpy, ushort *r_digits_len) |
| void | BLI_path_sequence_encode (char *path, const size_t path_maxncpy, const char *head, const char *tail, ushort numlen, int pic) |
| static int | path_normalize_impl (char *path, bool check_blend_relative_prefix) |
| int | BLI_path_normalize (char *path) |
| int | BLI_path_normalize_native (char *path) |
| int | BLI_path_normalize_dir (char *dir, size_t dir_maxncpy) |
| int | BLI_path_canonicalize_native (char *path, int path_maxncpy) |
| bool | BLI_path_make_safe_filename_ex (char *filename, bool allow_tokens) |
| bool | BLI_path_make_safe_filename (char *filename) |
| bool | BLI_path_make_safe (char *path) |
| bool | BLI_path_is_rel (const char *path) |
| bool | BLI_path_is_unc (const char *path) |
| 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) |
| void | BLI_path_rel (char path[FILE_MAX], const char *basepath) |
| bool | BLI_path_suffix (char *path, size_t path_maxncpy, const char *suffix, const char *sep) |
| const char * | BLI_path_parent_dir_end (const char *path, size_t path_len) |
| bool | BLI_path_parent_dir (char *path) |
| bool | BLI_path_parent_dir_until_exists (char *path) |
| static bool | path_frame_chars_find_range (const char *path, int *r_char_start, int *r_char_end) |
| static void | ensure_digits (char *path, int digits) |
| bool | BLI_path_frame (char *path, size_t path_maxncpy, int frame, int digits) |
| bool | BLI_path_frame_range (char *path, size_t path_maxncpy, int sta, int end, int digits) |
| bool | BLI_path_frame_get (const char *path, int *r_frame, int *r_digits_len) |
| void | BLI_path_frame_strip (char *path, char *r_ext, const size_t ext_maxncpy) |
| bool | BLI_path_frame_check_chars (const char *path) |
| void | BLI_path_to_display_name (char *display_name, int display_name_maxncpy, const char *name) |
| bool | BLI_path_abs (char path[FILE_MAX], const char *basepath) |
| bool | BLI_path_is_abs_from_cwd (const char *path) |
| bool | BLI_path_abs_from_cwd (char *path, const size_t path_maxncpy) |
| bool | BLI_path_program_search (char *program_filepath, const size_t program_filepath_maxncpy, const char *program_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) |
| static bool | path_extension_check_ex (const char *path, const size_t path_len, const char *ext, const size_t ext_len) |
| bool | BLI_path_extension_check (const char *path, const char *ext) |
| bool | BLI_path_extension_check_n (const char *path,...) |
| bool | BLI_path_extension_check_array (const char *path, const char **ext_array) |
| bool | BLI_path_extension_check_glob (const char *path, const char *ext_fnmatch) |
| bool | BLI_path_extension_glob_validate (char *ext_fnmatch) |
| bool | BLI_path_extension_replace (char *path, size_t path_maxncpy, const char *ext) |
| bool | BLI_path_extension_strip (char *path) |
| bool | BLI_path_extension_ensure (char *path, size_t path_maxncpy, const char *ext) |
| bool | BLI_path_filename_ensure (char *filepath, size_t filepath_maxncpy, const char *filename) |
| void | BLI_path_split_dir_file (const char *filepath, char *dir, const size_t dir_maxncpy, char *file, const size_t file_maxncpy) |
| void | BLI_path_split_dir_part (const char *filepath, char *dir, const size_t dir_maxncpy) |
| void | BLI_path_split_file_part (const char *filepath, char *file, const size_t file_maxncpy) |
| const char * | BLI_path_extension_or_end (const char *filepath) |
| const char * | BLI_path_extension (const char *filepath) |
| size_t | BLI_path_append (char *__restrict dst, const size_t dst_maxncpy, const char *__restrict file) |
| size_t | BLI_path_append_dir (char *__restrict dst, const size_t dst_maxncpy, const char *__restrict dir) |
| size_t | BLI_path_join_array (char *__restrict dst, const size_t dst_maxncpy, const char *path_array[], const int path_array_num) |
| const char * | BLI_path_basename (const char *path) |
| static bool | path_name_at_index_forward (const char *__restrict path, const int index, int *__restrict r_offset, int *__restrict r_len) |
| static bool | path_name_at_index_backward (const char *__restrict path, const int index, int *__restrict r_offset, int *__restrict r_len) |
| 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 *path) |
| const char * | BLI_path_slash_rfind (const char *path) |
| int | BLI_path_slash_ensure_ex (char *path, size_t path_maxncpy, size_t path_len) |
| int | BLI_path_slash_ensure (char *path, size_t path_maxncpy) |
| void | BLI_path_slash_rstrip (char *path) |
| const char * | BLI_path_slash_skip (const char *path) |
| void | BLI_path_slash_native (char *path) |
| int | BLI_path_cmp_normalized (const char *p1, const char *p2) |
| bool | BLI_path_has_hidden_component (const char *path) |
Various string, file, list operations.
Definition in file path_utils.cc.
The maximum number of # characters expanded for BLI_path_frame & BLI_path_frame_range Typically 12 is enough and even 16 is very large. Use a much larger value so hitting the upper limit is not an issue. Exceeding this limit won't fail either, it will just not insert so many leading zeros.
Definition at line 55 of file path_utils.cc.
Referenced by BLI_path_frame(), and BLI_path_frame_range().
| #define INVALID_CHARS |
Referenced by BLI_path_make_safe_filename_ex().
| #define INVALID_TOKENS "<>" |
Referenced by BLI_path_make_safe_filename_ex().
Referenced by path_normalize_impl().
| 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().
| bool BLI_path_abs | ( | char | path[FILE_MAX], |
| const char * | basepath ) |
Definition at line 1097 of file path_utils.cc.
References BLI_assert, BLI_assert_msg, BLI_path_is_rel(), BLI_path_is_win32_drive_with_slash(), BLI_path_normalize(), BLI_path_slash_rfind(), BLI_path_slash_skip(), BLI_path_unc_prefix_len(), BLI_string_debug_size_after_nil, BLI_string_replace_char(), BLI_strncpy(), BLI_windows_get_default_root_dir(), FILE_MAX, int, and STRNCPY.
| bool BLI_path_abs_from_cwd | ( | char * | path, |
| size_t | path_maxncpy ) |
Checks for relative path, expanding them relative to the current working directory.
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().
| size_t BLI_path_append | ( | char *__restrict | dst, |
| const size_t | dst_maxncpy, | ||
| const char *__restrict | file ) |
Definition at line 1655 of file path_utils.cc.
References BLI_path_slash_ensure(), and BLI_strncpy_rlen().
Referenced by BLI_path_append_dir(), and BLI_path_program_search().
| size_t BLI_path_append_dir | ( | char *__restrict | dst, |
| const size_t | dst_maxncpy, | ||
| const char *__restrict | dir ) |
Definition at line 1665 of file path_utils.cc.
References BLI_path_append(), and BLI_path_slash_ensure_ex().
| const char * BLI_path_basename | ( | const char * | path | ) |
Like Python's os.path.basename()
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().
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:
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().
| int BLI_path_cmp_normalized | ( | const char * | p1, |
| const char * | p2 ) |
Definition at line 1979 of file path_utils.cc.
References BLI_assert_msg, BLI_path_cmp, BLI_path_is_rel(), BLI_path_normalize(), BLI_path_slash_native(), BLI_path_slash_rstrip(), MEM_freeN(), and result.
| bool BLI_path_contains | ( | const char * | container_path, |
| const char * | containee_path ) |
Definition at line 1862 of file path_utils.cc.
References BLI_path_normalize(), BLI_path_slash_ensure(), BLI_path_slash_native(), BLI_str_startswith(), BLI_str_tolower_ascii(), BLI_strncpy(), PATH_MAX, STREQ, and STRNCPY.
| 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 1649 of file path_utils.cc.
References BLI_path_extension_or_end().
Referenced by BLI_path_extension_strip(), blender::ed::object::collection_exporter_export(), drop_extension_path_poll(), drop_extension_url_poll(), ED_text_is_syntax_highlight_supported(), blender::bke::file_handlers_poll_file_drop(), blender::bke::FileHandlerType::filter_supported_paths(), seq_disk_cache_get_files(), and TEST().
| bool BLI_path_extension_check | ( | const char * | path, |
| const char * | ext ) |
Definition at line 1409 of file path_utils.cc.
References path_extension_check_ex().
| bool BLI_path_extension_check_array | ( | const char * | path, |
| const char ** | ext_array ) |
Definition at line 1436 of file path_utils.cc.
References path_extension_check_ex().
| bool BLI_path_extension_check_glob | ( | const char * | path, |
| const char * | ext_fnmatch ) |
Definition at line 1451 of file path_utils.cc.
References BLI_strncpy(), and STRNCPY_RLEN.
| bool BLI_path_extension_check_n | ( | const char * | path, |
| ... ) |
Definition at line 1414 of file path_utils.cc.
References path_extension_check_ex(), and ret.
Referenced by BKE_image_alpha_mode_from_extension_ex(), blf_load_datafiles_dir(), ED_path_extension_type(), and blender::io::usd::set_job_filepath().
| bool BLI_path_extension_ensure | ( | char * | path, |
| size_t | path_maxncpy, | ||
| const char * | ext ) |
Definition at line 1527 of file path_utils.cc.
References BLI_path_extension_or_end(), BLI_string_debug_size_after_nil, and STREQ.
| 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 1477 of file path_utils.cc.
References ELEM.
Referenced by fileselect_ensure_updated_file_params().
| 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().
| bool BLI_path_extension_replace | ( | char * | path, |
| size_t | path_maxncpy, | ||
| const char * | ext ) |
Definition at line 1503 of file path_utils.cc.
References BLI_path_extension_or_end(), and BLI_string_debug_size_after_nil.
| bool BLI_path_extension_strip | ( | char * | path | ) |
Remove the file extension.
path. Definition at line 1517 of file path_utils.cc.
References BLI_path_extension().
Referenced by blender::io::obj::append_frame_to_filename(), BLI_path_to_display_name(), filelist_readjob_list_dir(), blender::io::ply::import_mesh(), blender::io::ply::importer_main(), blender::io::stl::importer_main(), blender::io::obj::OBJParser::parse(), ptcache_path(), render_result_exr_file_cache_path(), screenshot_invoke(), and blender::ed::object::volume_import_exec().
| bool BLI_path_filename_ensure | ( | char * | filepath, |
| size_t | filepath_maxncpy, | ||
| const char * | filename ) |
Definition at line 1560 of file path_utils.cc.
References BLI_path_basename(), and BLI_string_debug_size_after_nil.
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().
| 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().
Definition at line 995 of file path_utils.cc.
References BLI_path_basename(), and BLI_path_extension_or_end().
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.
| void BLI_path_frame_strip | ( | char * | path, |
| char * | r_ext, | ||
| const size_t | ext_maxncpy ) |
Definition at line 1024 of file path_utils.cc.
References BLI_path_basename(), BLI_path_extension_or_end(), BLI_string_debug_size, and BLI_strncpy().
| 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().
| 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().
| 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 526 of file path_utils.cc.
Referenced by absolute_convert_foreach_path_cb(), BKE_image_get_ibuf_with_name(), BKE_image_signal(), BKE_image_tile_filepath_exists(), BKE_library_filepath_set(), BKE_packedfile_pack_all_libraries(), BLI_access(), BLI_delete(), BLI_delete_soft(), BLI_delete_soft(), BLI_exists(), BLI_fopen(), BLI_gzopen(), BLI_open(), BLI_path_abs(), BLI_path_cmp_normalized(), BLI_path_rel(), BLO_read_from_file(), BLO_write_file_impl(), current_relpath_append(), blender::nodes::draw_common_bake_settings(), ED_image_filesel_detect_sequences(), file_browse_invoke(), file_expand_directory(), fix_relpaths_library(), blender::bke::bake::get_modifier_bake_path(), blender::bke::bake::get_node_bake_path(), blender::io::usd::get_relative_path(), image_file_browse_exec(), image_replace_invoke(), IMB_isanim(), imb_ispic_read_header_from_filepath(), IMB_loadiffname(), IMB_open_anim(), IMB_saveiff(), IMB_testiffname(), blender::io::usd::import_asset(), lib_id_library_local_paths_callback(), missing_files_find_foreach_path_cb(), blender::io::path_reference(), blender::io::usd::paths_equal(), blender::ed::io::paths_from_operator_properties(), ptcache_path(), relative_convert_foreach_path_cb(), relative_rebase_foreach_path_cb(), render_result_exr_file_cache_path(), blender::io::usd::should_import_asset(), TEST(), and blender::io::usd::USD_path_abs().
| 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().
| 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().
| 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().
| 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().
| size_t BLI_path_join_array | ( | char *__restrict | dst, |
| const size_t | dst_maxncpy, | ||
| const char * | path_array[], | ||
| const int | path_array_num ) |
Definition at line 1673 of file path_utils.cc.
References BLI_assert, BLI_path_join_array(), BLI_path_slash_is_native_compat(), BLI_string_debug_size, BLI_strncpy_rlen(), len, path_init(), SEP, and UNLIKELY.
Referenced by BLI_path_join_array().
| bool BLI_path_make_safe | ( | char * | path | ) |
Make given path OS-safe.
Definition at line 492 of file path_utils.cc.
References BLI_path_make_safe_filename(), 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_make_safe_filename | ( | char * | filename | ) |
Definition at line 487 of file path_utils.cc.
References BLI_path_make_safe_filename_ex().
Referenced by blender::bke::asset_blendfile_path_for_save(), BLI_path_make_safe(), blender::io::stl::export_frame(), blender::bke::FileHandlerType::get_default_filename(), renamebutton_cb(), seq_disk_cache_get_dir(), and unpack_generate_paths().
| bool BLI_path_make_safe_filename_ex | ( | char * | filename, |
| bool | allow_tokens ) |
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 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().
| bool BLI_path_name_at_index | ( | const char *__restrict | path, |
| const int | index, | ||
| int *__restrict | r_offset, | ||
| int *__restrict | r_len ) |
Definition at line 1853 of file path_utils.cc.
References path_name_at_index_backward(), and path_name_at_index_forward().
Referenced by BLI_path_parent_dir().
| int BLI_path_normalize | ( | char * | path | ) |
Remove redundant characters from path.
The following operations are performed:
//, /./ & ./ (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:
.. 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.| path | The path to a file or directory which can be absolute or relative. |
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().
| int BLI_path_normalize_dir | ( | char * | dir, |
| size_t | dir_maxncpy ) |
Cleanup file-path ensuring a trailing slash.
dir. Definition at line 377 of file path_utils.cc.
References BLI_path_normalize(), and BLI_path_slash_ensure_ex().
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(), fileselect_ensure_updated_file_params(), and blender::asset_system::utils::normalize_directory_path().
| int BLI_path_normalize_native | ( | char * | path | ) |
A version of BLI_path_normalize without special handling of // blend file relative prefix.
//path is a valid path which gets normalized to /path.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().
| 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().
| 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 ^
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().
| 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().
| bool BLI_path_program_search | ( | char * | program_filepath, |
| const size_t | program_filepath_maxncpy, | ||
| const char * | program_name ) |
Definition at line 1291 of file path_utils.cc.
References BLI_exists(), BLI_getenv(), BLI_path_append(), BLI_string_debug_size, BLI_strncpy(), PATH_MAX, program_filepath, and STRNCPY.
| void BLI_path_rel | ( | char | path[FILE_MAX], |
| const char * | basepath ) |
Replaces path with a relative version (prefixed by "//") such that BLI_path_abs, given the same basepath, will convert it back to its original value.
Definition at line 662 of file path_utils.cc.
References BLI_assert_msg, BLI_path_is_rel(), BLI_path_is_unc(), BLI_path_normalize(), BLI_path_slash_rfind(), BLI_path_unc_prefix_len(), BLI_string_debug_size_after_nil, BLI_string_replace_char(), BLI_strncpy(), BLI_strncpy_rlen(), BLI_strnlen(), BLI_windows_get_default_root_dir(), ELEM, FILE_MAX, STRNCPY, and UNUSED_VARS.
Referenced by blender::bke::asset_weak_reference_for_user_library(), BKE_image_signal(), blender::nodes::draw_common_bake_settings(), 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_relative_path(), image_file_browse_exec(), 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(), blender::ed::object::multires_external_save_exec(), open_exec(), blender::io::path_reference(), blender::ed::io::paths_from_operator_properties(), relative_convert_foreach_path_cb(), relative_rebase_foreach_path_cb(), sequencer_change_path_exec(), blender::ed::object::volume_import_exec(), and WM_operator_drop_load_path().
| 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.
| path | String to scan. |
| head | Optional area to return copy of part of path prior to digits, or before dot if no digits. |
| tail | Optional area to return copy of part of path following digits, or from dot if no digits. |
| r_digits_len | Optional 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().
| 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().
| int BLI_path_slash_ensure | ( | char * | path, |
| size_t | path_maxncpy ) |
Appends a slash to path if there isn't one there already.
Definition at line 1940 of file path_utils.cc.
References BLI_path_slash_ensure_ex().
Referenced by blender::bke::asset_weak_reference_for_user_library(), autocomplete_directory(), BKE_blendfile_userdef_from_defaults(), BLI_path_append(), BLI_path_contains(), BLI_temp_directory_path_copy_if_valid(), file_browse_exec(), file_browse_invoke(), file_sfile_to_operator_ex(), filelist_geticon_ex(), filelist_readjob_list_dir(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::get_single_layer_image_base_path(), open_invoke(), blender::io::usd::process_usdz_textures(), ptcache_path(), seq_disk_cache_delete_invalid_files(), seq_disk_cache_get_files(), tempdir_session_create(), blender::asset_system::tests::TEST_F(), and ui_but_menu_add_path_operators().
| 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.
| path_len | The length of 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().
| const char * BLI_path_slash_find | ( | const char * | path | ) |
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().
| void BLI_path_slash_native | ( | char * | path | ) |
Changes to the path separators to the native ones for this OS.
Definition at line 1968 of file path_utils.cc.
References ALTSEP, BLI_path_unc_prefix_len(), BLI_string_replace_char(), BLI_strnlen(), and SEP.
Referenced by blender::bke::asset_root_path_for_save(), BKE_preferences_extension_remote_to_name(), BLI_path_canonicalize_native(), BLI_path_cmp_normalized(), BLI_path_contains(), clean_paths(), blender::io::obj::export_frame(), foreach_path_clean_cb(), blender::asset_system::utils::normalize_path(), blender::ed::object::bake_simulation::PathStringHash::operator()(), blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::io::obj::MTLWriter::write_materials().
| const char * BLI_path_slash_rfind | ( | const char * | path | ) |
Definition at line 1910 of file path_utils.cc.
Referenced by BKE_blendfile_library_path_explode(), BLI_path_abs(), BLI_path_basename(), BLI_path_rel(), BLI_path_sequence_decode(), file_browse_exec(), file_browse_invoke(), groupname_to_code(), image_file_browse_invoke(), TEST(), where_am_i(), and wm_open_mainfile_check().
| void BLI_path_slash_rstrip | ( | char * | path | ) |
Removes the last slash and everything after it to the end of path, if there is one.
Definition at line 1945 of file path_utils.cc.
References BLI_path_slash_is_native_compat(), and len.
Referenced by BKE_preferences_extension_repo_add(), BLI_path_cmp_normalized(), file_path_to_ui_path(), blender::ed::object::bake_simulation::PathStringHash::operator()(), path_destination_ensure_filename(), preferences_asset_library_add_exec(), and preferences_extension_repo_add_exec().
| const char * BLI_path_slash_skip | ( | const char * | path | ) |
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().
| void BLI_path_split_dir_file | ( | const char * | filepath, |
| char * | dir, | ||
| const size_t | dir_maxncpy, | ||
| char * | file, | ||
| const size_t | file_maxncpy ) |
Definition at line 1572 of file path_utils.cc.
References BLI_path_basename(), BLI_string_debug_size, and BLI_strncpy().
| void BLI_path_split_dir_part | ( | const char * | filepath, |
| char * | dir, | ||
| const size_t | dir_maxncpy ) |
Definition at line 1592 of file path_utils.cc.
References BLI_path_basename(), BLI_string_debug_size, and BLI_strncpy().
| void BLI_path_split_file_part | ( | const char * | filepath, |
| char * | file, | ||
| const size_t | file_maxncpy ) |
Definition at line 1605 of file path_utils.cc.
References BLI_path_basename(), BLI_string_debug_size, and BLI_strncpy().
| bool BLI_path_suffix | ( | char * | path, |
| size_t | path_maxncpy, | ||
| const char * | suffix, | ||
| const char * | sep ) |
Definition at line 801 of file path_utils.cc.
References BLI_path_extension_or_end(), and BLI_string_debug_size_after_nil.
| void BLI_path_to_display_name | ( | char * | display_name, |
| int | display_name_maxncpy, | ||
| const char * | name ) |
Definition at line 1058 of file path_utils.cc.
References BLI_path_extension_strip(), BLI_string_debug_size, BLI_string_replace_char(), BLI_strncpy(), and ELEM.
|
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 542 of file path_utils.cc.
References BLI_path_is_unc().
Referenced by BLI_path_abs(), BLI_path_rel(), BLI_path_slash_native(), and path_normalize_impl().
| 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().
| 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().
|
static |
Ensure path contains at least one "#" character in its last slash-separated component, appending one digits long if not.
Definition at line 942 of file path_utils.cc.
References BLI_path_basename(), and len.
Referenced by BLI_path_frame(), and BLI_path_frame_range().
|
static |
Definition at line 1397 of file path_utils.cc.
References BLI_assert, and BLI_strcasecmp().
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 r_char_start and r_char_end respectively.
| r_char_start | The first # character. |
| r_char_end | The last # character +1. |
Definition at line 906 of file path_utils.cc.
References ELEM.
Referenced by BLI_path_frame(), BLI_path_frame_check_chars(), and BLI_path_frame_range().
|
static |
Definition at line 1818 of file path_utils.cc.
References BLI_assert, and BLI_path_slash_is_native_compat().
Referenced by BLI_path_name_at_index().
|
static |
Definition at line 1784 of file path_utils.cc.
References BLI_assert, and BLI_path_slash_is_native_compat().
Referenced by BLI_path_name_at_index().
|
static |
Implementation for BLI_path_normalize & BLI_path_normalize_native.
Definition at line 143 of file path_utils.cc.
References BLI_assert, BLI_path_is_win32_drive(), BLI_path_unc_prefix_len(), IS_PARENT_DIR, SEP, SEP_STR, STREQ, and UNLIKELY.
Referenced by BLI_path_normalize(), and BLI_path_normalize_native().