|
Blender V4.3
|
File and directory operations. More...
#include <stdint.h>#include <stdio.h>#include <sys/stat.h>#include <stddef.h>#include <limits.h>#include "BLI_compiler_attrs.h"#include "BLI_fileops_types.h"#include "BLI_utildefines.h"Go to the source code of this file.
Macros | |
| #define | PATH_MAX 4096 |
Files | |
| #define | O_BINARY 0 |
| FILE * | BLI_fopen (const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| void * | BLI_gzopen (const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| int | BLI_open (const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| int | BLI_access (const char *filepath, int mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| int64_t | BLI_read (int fd, void *buf, size_t nbytes) |
| bool | BLI_file_is_writable (const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| bool | BLI_file_touch (const char *filepath) ATTR_NONNULL(1) |
| bool | BLI_file_ensure_parent_dir_exists (const char *filepath) ATTR_NONNULL(1) |
| bool | BLI_file_alias_target (const char *filepath, char *r_targetpath) ATTR_WARN_UNUSED_RESULT |
| bool | BLI_file_magic_is_gzip (const char header[4]) |
| size_t | BLI_file_zstd_from_mem_at_pos (void *buf, size_t len, FILE *file, size_t file_offset, int compression_level) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| size_t | BLI_file_unzstd_to_mem_at_pos (void *buf, size_t len, FILE *file, size_t file_offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| bool | BLI_file_magic_is_zstd (const char header[4]) |
| size_t | BLI_file_descriptor_size (int file) ATTR_WARN_UNUSED_RESULT |
| size_t | BLI_file_size (const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| bool | BLI_file_older (const char *file1, const char *file2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| struct LinkNode * | BLI_file_read_as_lines (const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() |
| void * | BLI_file_read_data_as_mem_from_handle (FILE *fp, bool read_size_exact, size_t pad_bytes, size_t *r_size) |
| void * | BLI_file_read_text_as_mem (const char *filepath, size_t pad_bytes, size_t *r_size) |
| void * | BLI_file_read_text_as_mem_with_newline_as_nil (const char *filepath, bool trim_trailing_space, size_t pad_bytes, size_t *r_size) |
| void * | BLI_file_read_binary_as_mem (const char *filepath, size_t pad_bytes, size_t *r_size) |
| void | BLI_file_free_lines (struct LinkNode *lines) |
External File Operations | |
| enum | FileExternalOperation { FILE_EXTERNAL_OPERATION_OPEN = 1 , FILE_EXTERNAL_OPERATION_FOLDER_OPEN , FILE_EXTERNAL_OPERATION_EDIT , FILE_EXTERNAL_OPERATION_NEW , FILE_EXTERNAL_OPERATION_FIND , FILE_EXTERNAL_OPERATION_SHOW , FILE_EXTERNAL_OPERATION_PLAY , FILE_EXTERNAL_OPERATION_BROWSE , FILE_EXTERNAL_OPERATION_PREVIEW , FILE_EXTERNAL_OPERATION_PRINT , FILE_EXTERNAL_OPERATION_INSTALL , FILE_EXTERNAL_OPERATION_RUNAS , FILE_EXTERNAL_OPERATION_PROPERTIES , FILE_EXTERNAL_OPERATION_FOLDER_FIND , FILE_EXTERNAL_OPERATION_FOLDER_CMD } |
| typedef enum FileExternalOperation | FileExternalOperation |
| bool | BLI_file_external_operation_supported (const char *filepath, FileExternalOperation operation) |
| bool | BLI_file_external_operation_execute (const char *filepath, FileExternalOperation operation) |
File and directory operations.
Definition in file BLI_fileops.h.
| #define FILE_ATTR_ANY_LINK |
Definition at line 164 of file BLI_fileops.h.
Referenced by blender::compositor::DebugInfo::delete_operation_exports(), file_draw_list(), filelist_geticon_ex(), and seq_disk_cache_get_files().
| #define O_BINARY 0 |
Definition at line 446 of file BLI_fileops.h.
Referenced by BKE_image_load_in_lib(), BKE_movieclip_file_add(), BKE_packedfile_compare_to_file(), BKE_packedfile_new(), BKE_packedfile_write_to_file(), blo_filedata_from_file_open(), buffer_from_filepath(), extract_png_from_blend_file(), image_update_views_format(), imb_ispic_read_header_from_filepath(), imb_load_filepath_thumbnail_webp(), IMB_loadiffname(), IMB_testiffname(), imbuf_load_impl(), IMMapStream::IMMapStream(), RawWriteWrap::open(), prefetch_read_file_to_memory(), proxy_thread_next_frame(), blender::tests::TEST_F(), and wm_read_exotic().
| #define PATH_MAX 4096 |
Definition at line 30 of file BLI_fileops.h.
Referenced by blender::asset_system::asset_definition_default_file_path_from_dir(), BLI_current_working_dir(), BLI_path_abs_from_cwd(), BLI_path_contains(), BLI_path_program_search(), blender::asset_system::AssetCatalogService::find_suitable_cdf_path_for_writing(), blender::asset_system::utils::normalize_directory_path(), blender::io::path_reference(), blender::asset_system::tests::TEST_F(), and blender::asset_system::AssetCatalogDefinitionFile::write_to_disk_unsafe().
| typedef struct stat BLI_stat_t |
Definition at line 131 of file BLI_fileops.h.
| typedef enum eFileAttributes eFileAttributes |
| typedef enum FileExternalOperation FileExternalOperation |
| enum eFileAttributes |
Definition at line 144 of file BLI_fileops.h.
Definition at line 174 of file BLI_fileops.h.
Definition at line 1182 of file fileops_c.cc.
References BLI_assert, and BLI_path_is_rel().
Referenced by bli_builddir(), BLI_file_is_writable(), BLI_path_parent_dir_until_exists(), seq_proxy_multiview_context_invalid(), wm_homefile_read_ex(), and wm_homefile_read_exec().
| bool BLI_change_working_dir | ( | const char * | dir | ) |
Changes the current working directory to the provided path.
Usage of this function is strongly discouraged as it is not thread safe. It will likely cause issues if there is an operation on another thread that does not expect the current working directory to change. This has been added to support USDZ export, which has a problematic "feature" described in this issue #99807. It will be removed if it is possible to resolve that issue upstream in the USD library.
Definition at line 63 of file storage.cc.
References ARRAY_SIZE, BLI_assert, BLI_is_dir(), BLI_setenv(), BLI_thread_is_main(), conv_utf_8_to_16(), and FILE_MAX.
Referenced by blender::io::usd::perform_usdz_conversion(), and blender::tests::TEST_F().
| int BLI_copy | ( | const char * | path_src, |
| const char * | path_dst ) |
Definition at line 1519 of file fileops_c.cc.
References copy_callback_pre(), copy_single_file(), ELEM, FILE_MAX_STATIC_BUF, MEM_freeN(), path_destination_ensure_filename(), recursive_operation(), and ret.
Referenced by BKE_packedfile_write_to_file(), blender::io::usd::copy_single_file(), blender::io::usd::copy_tiled_textures(), DocumentExporter::exportCurrentScene(), blender::io::path_reference_copy(), blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::io::usd::world_material_to_dome_light().
| char * BLI_current_working_dir | ( | char * | dir, |
| size_t | maxncpy ) |
Copies the current working directory into *dir (max size maxncpy), and returns a pointer to same.
Definition at line 85 of file storage.cc.
References BLI_getenv(), BLI_strncpy(), BLI_strncpy_wchar_as_utf8(), BLI_strnlen(), NULL, and PATH_MAX.
Referenced by BLI_path_abs_from_cwd(), blender::io::usd::perform_usdz_conversion(), blender::io::usd::TEST_F(), and blender::tests::TEST_F().
| int BLI_delete | ( | const char * | path, |
| bool | dir, | ||
| bool | recursive ) |
Deletes the specified file or directory.
| dir | Delete an empty directory instead of a file. The value is ignored when recursive is true but should true to make the intention clear. If the directory is not empty, delete fails. |
| recursive | Recursively delete files including path which may be a directory of a file. |
path itself links to another directory, deleting path behaves as if a regular file is being deleted.dir is true and path is a link, delete fails.Definition at line 1189 of file fileops_c.cc.
References BLI_assert, BLI_path_is_rel(), delete_callback_post(), delete_single_file(), and recursive_operation().
Referenced by blender::bke::asset_edit_id_delete(), BKE_packedfile_write_to_file(), BKE_ptcache_id_clear(), BKE_tempdir_session_purge(), BLI_rename_overwrite(), blender::gpu::VKShaderCompiler::cache_dir_clear_old(), cdf_remove(), blender::io::obj::OBJMTLParserTest::check_string(), blender::io::obj::OBJExportRegressionTest::compare_obj_export_to_golden(), blender::io::stl::STLExportTest::compare_to_golden(), blender::ed::asset::index::AssetLibraryIndex::delete_file_index(), blender::compositor::DebugInfo::delete_operation_exports(), blender::io::alembic::AlembicExportTest::deleteArchive(), blender::io::alembic::export_endjob(), blender::io::usd::export_endjob(), blender::io::usd::export_endjob_usdz_cleanup(), DocumentExporter::exportCurrentScene(), IMB_thumb_delete(), IMB_thumb_manage(), blender::io::usd::load_image(), blender::io::usd::USDMaterialReader::load_tex_image(), blender::io::usd::perform_usdz_conversion(), blender::io::hydra::USDSceneDelegate::populate(), preferences_extension_repo_remove_exec(), RE_RenderAnim(), seq_disk_cache_delete_file(), seq_disk_cache_handle_versioning(), blender::asset_system::tests::AssetLibraryServiceTest::TearDown(), blender::asset_system::tests::AssetLibraryTestBase::TearDown(), blender::io::usd::UsdCurvesTest::TearDown(), blender::io::usd::UsdExportTest::TearDown(), blender::io::usd::UsdUsdzExportTest::TearDown(), blender::tests::ChangeWorkingDirectoryTest::TearDown(), blender::tests::FileOpsTest::TearDown(), blender::tests::TEST_F(), blender::ed::object::bake_simulation::try_delete_bake(), blender::bke::bake::unpack_geometry_nodes_bake(), wm_autosave_delete(), and blender::io::hydra::USDSceneDelegate::~USDSceneDelegate().
| int BLI_delete_soft | ( | const char * | filepath, |
| const char ** | r_error_message ) |
Soft deletes the specified file or directory (depending on dir) by moving the files to the recycling bin, optionally doing recursive delete of directory contents.
Definition at line 16 of file fileops_apple.mm.
References BLI_assert, BLI_assert_unreachable, BLI_path_is_rel(), BLI_string_elem_split_by_delim(), error(), result, STREQ, and UNLIKELY.
Referenced by file_delete_single().
| bool BLI_dir_create_recursive | ( | const char * | dirname | ) |
Definition at line 391 of file fileops_c.cc.
References BLI_assert, BLI_exists(), BLI_path_slash_is_native_compat(), dir_create_recursive(), dirname(), FILE_MAX, len, MEM_freeN(), ret, S_ISDIR, and true.
Referenced by blender::bke::asset_blendfile_path_for_save(), BKE_appdir_folder_id_create(), BLI_file_ensure_parent_dir_exists(), blender::gpu::cache_dir_get(), blender::asset_system::tests::AssetLibraryServiceTest::create_temp_path(), blender::asset_system::tests::AssetLibraryTestBase::create_temp_path(), blender::asset_system::AssetCatalogDefinitionFile::ensure_directory_exists(), blender::io::usd::export_texture(), MANTA::exportLiquidScript(), MANTA::exportSmokeScript(), file_directory_new_exec(), fluid_bake_startjob(), fluid_validatepaths(), blender::io::usd::get_export_textures_dir(), blender::io::usd::get_image_cache_file(), IMB_thumb_makedirs(), blender::io::usd::import_asset(), blender::io::hydra::USDSceneDelegate::populate(), blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), blender::io::usd::UsdUsdzExportTest::SetUp(), blender::tests::FileOpsTest::SetUp(), tempdir_session_create(), blender::asset_system::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::io::hydra::USDSceneDelegate::USDSceneDelegate(), blender::io::usd::world_material_to_dome_light(), and MANTA::writeConfiguration().
| double BLI_dir_free_space | ( | const char * | dir | ) |
Returns the number of free bytes on the volume containing the specified path.
Definition at line 110 of file storage.cc.
References dirname(), double(), ELEM, FILE_MAXDIR, and len.
| int BLI_exists | ( | const char * | path | ) |
Returns the st_mode from stat-ing the specified path name, or 0 if stat fails (most likely doesn't exist or no access).
Definition at line 350 of file storage.cc.
References alloc_utf16_from_8(), BLI_assert, BLI_path_is_rel(), ELEM, free(), L, and len.
Referenced by BKE_appdir_app_template_has_userpref(), BKE_appdir_font_folder_default(), BKE_appdir_program_python_search(), BKE_blendfile_userdef_write_app_template(), BKE_cachefile_filepath_get(), BKE_packedfile_unpack_to_file(), BKE_packedfile_write_to_file(), BKE_ptcache_id_exist(), BKE_text_file_modified_check(), BKE_text_file_modified_ignore(), BKE_volume_load(), blf_dir_metrics_search(), BLF_load_unique(), BLI_dir_create_recursive(), BLI_is_dir(), BLI_is_file(), BLI_path_program_search(), BLI_rename(), BLI_rename_overwrite(), blender::io::usd::cache_image_color(), blender::io::hydra::cache_image_file(), blender::seq::check_media_missing(), check_missing_files_foreach_path_cb(), blender::seq::check_sound_media_missing(), blender::io::usd::copy_single_file(), blender::io::usd::copy_tiled_textures(), blender::compositor::DebugInfo::delete_operation_exports(), blender::io::alembic::AlembicExportTest::deleteArchive(), dir_create_recursive(), do_history(), blender::asset_system::AssetCatalogDefinitionFile::ensure_directory_exists(), blender::ed::asset::index::AbstractFile::exists(), blender::io::alembic::export_endjob(), blender::io::usd::export_endjob(), blender::io::usd::export_endjob_usdz_cleanup(), blender::io::usd::export_in_memory_texture(), file_delete_single(), file_directory_new_exec(), file_execute(), file_sfile_filepath_set(), filepath_drop_exec(), fsmenu_read_bookmarks(), handle_load_file(), MANTA::hasConfig(), MANTA::hasData(), MANTA::hasGuiding(), MANTA::hasMesh(), MANTA::hasNoise(), MANTA::hasParticles(), image_save_exec(), IMB_anim_proxy_get_existing(), IMB_exr_begin_read(), IMB_thumb_delete(), IMB_thumb_manage(), blender::asset_system::AssetCatalogService::load_directory_recursive(), missing_files_find_foreach_path_cb(), movieclip_calc_length(), blender::ed::outliner::namebutton_fn(), new_folder_path(), openanim(), blender::io::path_reference_copy(), blender::io::usd::perform_usdz_conversion(), RE_RenderAnim(), blender::gpu::VKPipelinePool::read_from_disk(), blender::gpu::read_spirv_from_disk(), renamebutton_cb(), blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), screen_opengl_render_anim_step(), seq_disk_cache_enforce_limits(), seq_disk_cache_handle_versioning(), seq_proxy_build_frame(), seq_proxy_fetch(), sequencer_export_subtitles_exec(), blender::tests::FileOpsTest::SetUp(), blender::io::usd::UsdCurvesTest::TearDown(), blender::io::usd::UsdExportTest::TearDown(), blender::tests::FileOpsTest::TearDown(), blender::tests::TEST(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::ed::object::bake_simulation::try_delete_bake(), txt_write_file(), ui_but_menu_add_path_operators(), ui_popup_context_menu_for_button(), ui_tooltip_from_vfont(), uiTemplateRecentFiles_tooltip_func(), where_am_i(), wm_autosave_delete(), wm_block_splash_create(), wm_clear_recent_files_exec(), wm_file_write(), wm_homefile_read_ex(), wm_init_splash_show_on_startup_check(), WM_lib_reload(), wm_lib_relocate_exec_do(), wm_save_as_mainfile_exec(), workspace_config_file_read(), workspace_system_file_read(), blender::ui::string_search::write_recent_searches_file(), blender::asset_system::AssetCatalogDefinitionFile::write_to_disk(), and DocumentImporter::writeImage().
| bool BLI_file_alias_target | ( | const char * | filepath, |
| char * | r_targetpath ) |
Referenced by filelist_readjob_list_dir().
| eFileAttributes BLI_file_attributes | ( | const char * | path | ) |
Definition at line 226 of file storage.cc.
References ARRAY_SIZE, BLI_assert_msg, BLI_path_extension_check(), conv_utf_8_to_16(), error(), FILE_ATTR_ALIAS, FILE_ATTR_ARCHIVE, FILE_ATTR_COMPRESSED, FILE_ATTR_ENCRYPTED, FILE_ATTR_HIDDEN, FILE_ATTR_OFFLINE, FILE_ATTR_READONLY, FILE_ATTR_REPARSE_POINT, FILE_ATTR_SPARSE_FILE, FILE_ATTR_SYSTEM, FILE_ATTR_TEMPORARY, FILE_MAXDIR, ret, test_file_is_offline(), and UNUSED_VARS.
Referenced by blender::compositor::DebugInfo::delete_operation_exports(), filelist_readjob_list_dir(), IMB_thumb_manage(), seq_disk_cache_get_files(), and uiTemplateRecentFiles_tooltip_func().
| size_t BLI_file_descriptor_size | ( | int | file | ) |
Returns the file size of an opened file descriptor or size_t(-1) on failure.
Definition at line 206 of file storage.cc.
References BLI_fstat().
Referenced by BKE_packedfile_new(), buffer_from_filepath(), prefetch_read_file_to_memory(), and proxy_thread_next_frame().
| bool BLI_file_ensure_parent_dir_exists | ( | const char * | filepath | ) |
Ensures that the parent directory of filepath exists.
Definition at line 429 of file fileops_c.cc.
References BLI_dir_create_recursive(), BLI_path_split_dir_part(), and FILE_MAX.
Referenced by blender::ed::object::bake_simulation::bake_geometry_nodes_startjob(), BKE_image_render_write_exr(), BKE_imbuf_write(), BKE_packedfile_write_to_file(), dynamicPaint_outputSurfaceImage(), blender::ed::asset::index::AssetIndexFile::ensure_parent_path_exists(), blender::compositor::DebugInfo::export_operation(), IMB_index_builder_create(), movieclip_build_proxy_ibuf(), blender::io::path_reference_copy(), ptcache_file_open(), RE_RenderAnim(), seq_disk_cache_create_version_file(), seq_disk_cache_read_file(), seq_disk_cache_write_file(), seq_proxy_build_frame(), sequencer_export_subtitles_exec(), blender::bke::bake::unpack_bake_to_disk(), blender::bke::bake::DiskBlobWriter::write(), and blender::bke::bake::DiskBlobWriter::write_as_stream().
| bool BLI_file_external_operation_execute | ( | const char * | filepath, |
| FileExternalOperation | operation ) |
Definition at line 157 of file fileops_c.cc.
References BLI_windows_external_operation_execute(), BLI_windows_external_operation_supported(), and UNUSED_VARS.
Referenced by file_external_operation_exec().
| bool BLI_file_external_operation_supported | ( | const char * | filepath, |
| FileExternalOperation | operation ) |
Definition at line 146 of file fileops_c.cc.
References BLI_windows_external_operation_supported(), and UNUSED_VARS.
Referenced by file_os_operations_menu_item().
| void BLI_file_free_lines | ( | struct LinkNode * | lines | ) |
Frees memory from a previous call to BLI_file_read_as_lines.
Definition at line 600 of file storage.cc.
References BLI_linklist_freeN().
Referenced by make(), studiolight_load_solid_light(), wm_history_file_read(), and wm_platform_support_check_approval().
| bool BLI_file_is_writable | ( | const char * | filepath | ) |
Returns true if the file with the specified name can be written. This implementation uses access(2), which makes the check according to the real UID and GID of the process, not its effective UID and GID. This shouldn't matter for Blender, which is not going to run privileged anyway.
Definition at line 291 of file fileops_c.cc.
References BLI_access(), BLI_path_split_dir_part(), and FILE_MAX.
Referenced by blender::bke::asset_link_id(), image_save_exec(), sequencer_export_subtitles_exec(), txt_write_file(), and wm_file_write().
| bool BLI_file_magic_is_gzip | ( | const char | header[4] | ) |
Definition at line 257 of file fileops_c.cc.
Referenced by blendthumb_create_thumb_from_file(), blo_filedata_from_file_descriptor(), blo_filedata_from_memory(), and wm_read_exotic().
| bool BLI_file_magic_is_zstd | ( | const char | header[4] | ) |
Definition at line 264 of file fileops_c.cc.
References magic().
Referenced by blendthumb_create_thumb_from_file(), blo_filedata_from_file_descriptor(), blo_filedata_from_memory(), inflate_file_to_imbuf(), and wm_read_exotic().
| bool BLI_file_older | ( | const char * | file1, |
| const char * | file2 ) |
Compare if one was last modified before the other.
file1 older than file2. Definition at line 605 of file storage.cc.
References BLI_stat().
Referenced by IMB_thumb_manage(), and blender::ed::asset::index::AssetIndexFile::is_older_than().
| struct LinkNode * BLI_file_read_as_lines | ( | const char * | filepath | ) |
Reads the contents of a text file.
Definition at line 554 of file storage.cc.
References BLI_fopen(), BLI_fseek(), BLI_ftell(), BLI_linklist_append(), BLI_strdupn(), LinkNodePair::list, MEM_freeN(), size(), and UNLIKELY.
Referenced by make(), studiolight_load_solid_light(), wm_history_file_read(), and wm_platform_support_check_approval().
| void * BLI_file_read_binary_as_mem | ( | const char * | filepath, |
| size_t | pad_bytes, | ||
| size_t * | r_size ) |
Definition at line 513 of file storage.cc.
References BLI_file_read_data_as_mem_from_handle(), and BLI_fopen().
Referenced by BKE_icon_geom_from_file().
| void * BLI_file_read_data_as_mem_from_handle | ( | FILE * | fp, |
| bool | read_size_exact, | ||
| size_t | pad_bytes, | ||
| size_t * | r_size ) |
Read the contents of fp, returning the result as a buffer or null when it can't be read.
| r_size | The size of the file contents read into the buffer (excluding pad_bytes). |
Use for both text and binary file reading.
Definition at line 447 of file storage.cc.
References BLI_fseek(), BLI_fstat(), BLI_ftell(), L, MEM_freeN(), MEM_mallocN, MEM_reallocN, and S_ISDIR.
Referenced by BLI_file_read_binary_as_mem(), BLI_file_read_text_as_mem(), and python_compat_wrapper_PyRun_FileExFlags().
| void * BLI_file_read_text_as_mem | ( | const char * | filepath, |
| size_t | pad_bytes, | ||
| size_t * | r_size ) |
Definition at line 502 of file storage.cc.
References BLI_file_read_data_as_mem_from_handle(), and BLI_fopen().
Referenced by BKE_text_load_ex(), BKE_text_reload(), BLI_file_read_text_as_mem_with_newline_as_nil(), blender::io::obj::MTLParser::parse_and_store(), paste_from_file(), blender::io::stl::read_stl_ascii(), blender::io::obj::read_temp_file_in_string(), blender::io::ply::read_temp_file_in_string(), blender::io::stl::read_temp_file_in_string(), and read_text_corpus().
| void * BLI_file_read_text_as_mem_with_newline_as_nil | ( | const char * | filepath, |
| bool | trim_trailing_space, | ||
| size_t | pad_bytes, | ||
| size_t * | r_size ) |
Return the text file data with:
This is an alternative to using BLI_file_read_as_lines, allowing us to loop over lines without converting it into a linked list with individual allocations.
| trim_trailing_space | Replace trailing spaces & tabs with nil. This arguments prevents the caller from counting blank lines (if that's important). |
| pad_bytes | When this is non-zero, the first byte is set to nil, to simplify parsing the file. It's recommended to pass in 1, so all text is nil terminated. |
| r_size | The size of the file contents read into the buffer (excluding pad_bytes). |
Example looping over lines:
Definition at line 524 of file storage.cc.
References BLI_file_read_text_as_mem(), and ELEM.
| size_t BLI_file_size | ( | const char * | path | ) |
Returns the size of a file or size_t(-1) on failure..
Definition at line 215 of file storage.cc.
References BLI_stat().
Referenced by blender::ed::asset::index::AbstractFile::get_file_size(), IMB_exr_begin_read(), imb_load_filepath_thumbnail_openexr(), IMB_thumb_load_image(), RE_RenderAnim(), blender::io::stl::read_stl_file(), and blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib().
| bool BLI_file_touch | ( | const char * | filepath | ) |
Creates the file with nothing in it, or updates its last-modified date if it already exists. Returns true if successful (like the unix touch command).
Definition at line 316 of file fileops_c.cc.
References BLI_fopen().
Referenced by RE_RenderAnim(), blender::gpu::VKPipelinePool::read_from_disk(), blender::gpu::read_spirv_from_disk(), blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), seq_disk_cache_read_file(), sequencer_export_subtitles_exec(), and blender::tests::TEST_F().
| size_t BLI_file_unzstd_to_mem_at_pos | ( | void * | buf, |
| size_t | len, | ||
| FILE * | file, | ||
| size_t | file_offset ) |
Definition at line 220 of file fileops_c.cc.
References len, MEM_freeN(), MEM_mallocN, and ret.
Referenced by inflate_file_to_imbuf().
| size_t BLI_file_zstd_from_mem_at_pos | ( | void * | buf, |
| size_t | len, | ||
| FILE * | file, | ||
| size_t | file_offset, | ||
| int | compression_level ) |
Definition at line 173 of file fileops_c.cc.
References len, MEM_freeN(), MEM_mallocN, and ret.
Referenced by deflate_imbuf_to_file().
Scans the contents of the directory named dirname, and allocates and fills in an array of entries describing them in r_filelist.
r_filelist array. Definition at line 227 of file BLI_filelist.cc.
References bli_builddir(), dirname(), BuildDirCtx::files, BuildDirCtx::files_num, and MEM_mallocN.
Referenced by BKE_appdir_app_templates(), BKE_image_get_tile_info(), BKE_image_tile_filepath_exists(), blf_load_datafiles_dir(), blender::gpu::VKShaderCompiler::cache_dir_clear_old(), blender::ed::asset::index::AssetLibraryIndex::collect_preexisting_file_indices(), blender::compositor::DebugInfo::delete_operation_exports(), blender::bke::bake::directory_is_empty(), filelist_readjob_list_dir(), blender::bke::bake::find_sorted_meta_files(), fsmenu_read_system(), blender::bke::bake::pack_files_from_directory(), blender::io::usd::process_usdz_textures(), seq_disk_cache_get_files(), and studiolight_add_files_from_datafolder().
| void BLI_filelist_duplicate | ( | struct direntry ** | dest_filelist, |
| struct direntry *const | src_filelist, | ||
| unsigned int | nrentries ) |
Deep-duplicate of a direntry array including the array itself.
Definition at line 416 of file BLI_filelist.cc.
References BLI_filelist_entry_duplicate(), and MEM_mallocN.
| void BLI_filelist_entry_datetime_to_string | ( | const struct stat * | st, |
| int64_t | ts, | ||
| bool | compact, | ||
| char | r_time[FILELIST_DIRENTRY_TIME_LEN], | ||
| char | r_date[FILELIST_DIRENTRY_DATE_LEN], | ||
| bool * | r_is_today, | ||
| bool * | r_is_yesterday ) |
Convert given entry's time into human-readable strings.
| r_is_today | optional, returns true if the date matches today's. |
| r_is_yesterday | optional, returns true if the date matches yesterday's. |
Definition at line 343 of file BLI_filelist.cc.
References FILELIST_DIRENTRY_DATE_LEN, FILELIST_DIRENTRY_TIME_LEN, and time.
Referenced by file_draw_tooltip_custom_func(), filelist_get_details_column_string(), uiTemplateRecentFiles_tooltip_func(), and wm_open_mainfile_get_description().
Deep-duplicate of a single direntry.
| void BLI_filelist_entry_free | ( | struct direntry * | entry | ) |
Frees storage for a single direntry, not the direntry itself.
Definition at line 431 of file BLI_filelist.cc.
References MEM_freeN(), direntry::path, and direntry::relname.
Referenced by BLI_filelist_free().
| void BLI_filelist_entry_mode_to_string | ( | const struct stat * | st, |
| bool | compact, | ||
| char | r_mode1[FILELIST_DIRENTRY_MODE_LEN], | ||
| char | r_mode2[FILELIST_DIRENTRY_MODE_LEN], | ||
| char | r_mode3[FILELIST_DIRENTRY_MODE_LEN] ) |
Convert given entry's modes into human-readable strings.
Definition at line 276 of file BLI_filelist.cc.
References BLI_strncpy(), FILELIST_DIRENTRY_MODE_LEN, and UNUSED_VARS.
| void BLI_filelist_entry_owner_to_string | ( | const struct stat * | st, |
| bool | compact, | ||
| char | r_owner[FILELIST_DIRENTRY_OWNER_LEN] ) |
Convert given entry's owner into human-readable strings.
Definition at line 324 of file BLI_filelist.cc.
References BLI_snprintf(), BLI_strncpy(), FILELIST_DIRENTRY_OWNER_LEN, and UNUSED_VARS.
| void BLI_filelist_entry_size_to_string | ( | const struct stat * | st, |
| uint64_t | st_size_fallback, | ||
| bool | compact, | ||
| char | r_size[FILELIST_DIRENTRY_SIZE_LEN] ) |
Convert given entry's size into human-readable strings.
Definition at line 248 of file BLI_filelist.cc.
References BLI_str_format_byte_unit(), BLI_str_format_byte_unit_compact(), and double().
Referenced by file_draw_tooltip_custom_func(), filelist_get_details_column_string(), uiTemplateRecentFiles_tooltip_func(), and wm_open_mainfile_get_description().
Frees storage for an array of direntry, including the array itself.
Definition at line 441 of file BLI_filelist.cc.
References BLI_filelist_entry_free(), and MEM_freeN().
Referenced by BKE_appdir_app_templates(), BKE_image_get_tile_info(), BKE_image_tile_filepath_exists(), blf_load_datafiles_dir(), blender::gpu::VKShaderCompiler::cache_dir_clear_old(), blender::ed::asset::index::AssetLibraryIndex::collect_preexisting_file_indices(), blender::compositor::DebugInfo::delete_operation_exports(), blender::bke::bake::directory_is_empty(), filelist_readjob_list_dir(), blender::bke::bake::find_sorted_meta_files(), fsmenu_read_system(), blender::bke::bake::pack_files_from_directory(), blender::io::usd::process_usdz_textures(), seq_disk_cache_get_files(), and studiolight_add_files_from_datafolder().
| FILE * BLI_fopen | ( | const char * | filepath, |
| const char * | mode ) |
Definition at line 1161 of file fileops_c.cc.
References BLI_assert, and BLI_path_is_rel().
Referenced by arg_handle_log_file_set(), BKE_report_write_file(), BLI_file_read_as_lines(), BLI_file_read_binary_as_mem(), BLI_file_read_text_as_mem(), BLI_file_touch(), cdf_read_open(), cdf_write_open(), blender::io::obj::OBJMTLParserTest::check_string(), cineonCreate(), cineonOpen(), dpxCreate(), dpxOpen(), blender::io::ply::FileBuffer::FileBuffer(), blender::io::stl::FileWriter::FileWriter(), fsmenu_read_bookmarks(), fsmenu_write_file(), fsmenu_xdg_user_dirs_parse(), blender::compositor::DebugInfo::graphviz(), IMB_index_builder_create(), IMB_indexer_open(), imb_savewebp(), imb_thumbnail_jpeg(), logImageOpenFromFile(), make(), MOD_meshcache_read_mdd_times(), MOD_meshcache_read_pc2_times(), blender::io::obj::MTLWriter::MTLWriter(), blender::io::obj::OBJParser::OBJParser(), blender::io::obj::OBJWriter::OBJWriter(), opj_stream_create_from_file(), output_iris(), blender::io::ply::PlyReadBuffer::PlyReadBuffer(), ptcache_file_open(), python_script_exec(), blender::io::stl::read_stl_file(), save_stdjpeg(), seq_disk_cache_create_version_file(), seq_disk_cache_handle_versioning(), seq_disk_cache_read_file(), seq_disk_cache_write_file(), sequencer_export_subtitles_exec(), sig_handle_crash(), studiolight_write_solid_light(), txt_write_file(), wm_history_file_write(), and wm_platform_support_check_approval().
Definition at line 188 of file storage.cc.
Referenced by BLI_file_read_as_lines(), BLI_file_read_data_as_mem_from_handle(), cdf_read_header(), cdf_read_layer(), MOD_meshcache_read_mdd_frame(), MOD_meshcache_read_mdd_index(), MOD_meshcache_read_pc2_frame(), MOD_meshcache_read_pc2_index(), ptcache_file_header_begin_read(), seq_disk_cache_read_header(), and seq_disk_cache_write_header().
| int BLI_fstat | ( | int | fd, |
| BLI_stat_t * | buffer ) |
Referenced by python_script_exec().
| int64_t BLI_ftell | ( | FILE * | stream | ) |
Definition at line 179 of file storage.cc.
Referenced by BLI_file_read_as_lines(), and BLI_file_read_data_as_mem_from_handle().
| void * BLI_gzopen | ( | const char * | filepath, |
| const char * | mode ) |
Definition at line 1168 of file fileops_c.cc.
References BLI_assert, and BLI_path_is_rel().
Referenced by MANTA::readConfiguration(), and MANTA::writeConfiguration().
| bool BLI_is_dir | ( | const char * | path | ) |
Does the specified path point to a directory?
fileops.cc except that it needs stat.h so add here. Definition at line 433 of file storage.cc.
References BLI_exists(), and S_ISDIR.
Referenced by blender::asset_system::all_valid_asset_library_refs(), blender::ed::object::bake_simulation::bake_directory_has_data(), BKE_appdir_app_template_id_search(), BKE_appdir_folder_caches(), BKE_appdir_folder_documents(), BKE_blendfile_library_path_explode(), BKE_tempdir_session_purge(), BLI_change_working_dir(), BLI_rename_overwrite(), BLI_temp_directory_path_copy_if_valid(), bookmark_cleanup_exec(), blender::ed::asset::index::AssetLibraryIndex::collect_preexisting_file_indices(), blender::asset_system::AssetCatalogDefinitionFile::ensure_directory_exists(), file_browse_exec(), file_sfile_filepath_set(), filelist_checkdir_dir(), filelist_checkdir_lib(), filelist_readjob_list_dir(), filelist_readjob_recursive_dir_add_items(), blender::bke::bake::find_sorted_meta_files(), fsmenu_entry_refresh_valid(), fsmenu_read_system(), blender::io::usd::load_image(), blender::io::usd::USDMaterialReader::load_tex_image(), blender::bke::bake::pack_files_from_directory(), blender::io::usd::parent_dir_exists_on_file_system(), path_destination_ensure_filename(), preferences_extension_repo_remove_exec(), blender::io::usd::process_usdz_textures(), seq_disk_cache_get_files(), seq_disk_cache_handle_versioning(), tempdir_session_create(), blender::tests::TEST(), test_env_path(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and test_path().
| bool BLI_is_file | ( | const char * | path | ) |
Does the specified path point to a non-directory?
Definition at line 438 of file storage.cc.
References BLI_exists(), and S_ISDIR.
Referenced by blender::bke::asset_blendfile_path_for_save(), BKE_blendfile_library_path_explode(), BKE_preferences_asset_library_path_set(), blender::ed::sculpt_paint::brush_asset_load_preview_exec(), blender::io::usd::copy_asset_to_directory(), blender::compositor::DebugInfo::delete_operation_exports(), file_directory_enter_handle(), file_draw_check_exists(), filelist_checkdir_lib(), blender::io::usd::get_relative_path(), lib_id_load_custom_preview_exec(), blender::asset_system::AssetCatalogService::reload_catalogs(), blender::io::usd::should_import_asset(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and ui_but_menu_add_path_operators().
Definition at line 197 of file storage.cc.
Referenced by BLI_mmap_open(), and file_seek().
Definition at line 1175 of file fileops_c.cc.
References BLI_assert, BLI_path_is_rel(), and oflag.
Referenced by BKE_image_load_in_lib(), BKE_movieclip_file_add(), BKE_packedfile_compare_to_file(), BKE_packedfile_new(), BKE_packedfile_write_to_file(), blo_filedata_from_file_open(), buffer_from_filepath(), extract_png_from_blend_file(), image_update_views_format(), imb_ispic_read_header_from_filepath(), imb_load_filepath_thumbnail_webp(), IMB_loadiffname(), IMB_testiffname(), imbuf_load_impl(), IMMapStream::IMMapStream(), RawWriteWrap::open(), prefetch_read_file_to_memory(), proxy_thread_next_frame(), blender::tests::TEST_F(), and wm_read_exotic().
| int BLI_path_move | ( | const char * | path_src, |
| const char * | path_dst ) |
When path_src points to a directory, moves all its contents into path_dst, else rename path_src itself to path_dst.
Definition at line 1485 of file fileops_c.cc.
References delete_callback_post(), delete_single_file(), move_callback_pre(), move_single_file(), recursive_operation(), and ret.
Referenced by blender::io::usd::perform_usdz_conversion().
A version of read with the following differences:
size_t bytes instead of int on WIN32. Definition at line 96 of file fileops_c.cc.
References BLI_assert_unreachable, and UNLIKELY.
Referenced by BKE_packedfile_compare_to_file(), BKE_packedfile_new(), buffer_from_filepath(), file_read(), imb_ispic_read_header_from_filepath(), prefetch_read_file_to_memory(), and proxy_thread_next_frame().
| int BLI_rename | ( | const char * | from, |
| const char * | to ) |
Rename a file or directory, unless to already exists.
rename logic, not Unix one. It does not allow to replace an existing target. Use BLI_rename_overwrite instead if existing file should be replaced.| from | The path to rename from (return failure if it does not exist). |
| to | The destination path. |
Definition at line 438 of file fileops_c.cc.
References BLI_exists(), ret, and urename().
Referenced by IMB_index_builder_finish(), renamebutton_cb(), and blender::tests::TEST_F().
| int BLI_rename_overwrite | ( | const char * | from, |
| const char * | to ) |
Rename a file or directory, replacing target to path if it exists.
rename logic. It does allow to replace an existing target. Use BLI_rename instead if existing file should never be replaced. However, if to is an existing, non-empty directory, the operation will fail.to exists and is opened by some process in the system:from and to are not the same directory. Since to is being deleted to make room for from, this will result in from being deleted as well.See BLI_path_move to move directories.
| from | The path to rename from (return failure if it does not exist). |
| to | The destination path. This will be deleted if it already exists, unless it's a directory which will fail. |
Definition at line 505 of file fileops_c.cc.
References BLI_delete(), BLI_exists(), BLI_is_dir(), and urename().
Referenced by BKE_packedfile_write_to_file(), BKE_ptcache_disk_cache_rename(), BLO_write_file_impl(), do_history(), DocumentExporter::exportCurrentScene(), blender::tests::TEST_F(), thumb_create_ex(), wm_autosave_delete(), and blender::asset_system::AssetCatalogDefinitionFile::write_to_disk().
| int BLI_stat | ( | const char * | path, |
| BLI_stat_t * | buffer ) |
Referenced by autocomplete_directory(), BKE_packedfile_compare_to_file(), BKE_text_file_modified_check(), BKE_text_file_modified_ignore(), BKE_text_load_ex(), BKE_text_reload(), bli_builddir(), imb_ispic_read_header_from_filepath(), IMB_thumb_manage(), blender::asset_system::AssetCatalogService::load_from_disk(), missing_files_find__recursive(), blender::ed::asset::index::AssetLibraryIndex::remove_broken_index_files(), seq_disk_cache_update_file(), thumb_create_ex(), txt_write_file(), uiTemplateRecentFiles_tooltip_func(), and wm_open_mainfile_get_description().
| ENUM_OPERATORS | ( | eFileAttributes | , |
| FILE_ATTR_HARDLINK | ) |