|
Blender
V2.93
|
#include <stdlib.h>#include <string.h>#include <fcntl.h>#include <sys/stat.h>#include <sys/types.h>#include <errno.h>#include "zlib.h"#include <dirent.h>#include <sys/param.h>#include <sys/wait.h>#include <unistd.h>#include "MEM_guardedalloc.h"#include "BLI_fileops.h"#include "BLI_path_util.h"#include "BLI_string.h"#include "BLI_sys_types.h"#include "BLI_utildefines.h"Go to the source code of this file.
Macros | |
| #define | CHUNK (256 * 1024) |
Typedefs | |
| typedef int(* | RecursiveOp_Callback) (const char *from, const char *to) |
Enumerations | |
| enum | { RecursiveOp_Callback_OK = 0 , RecursiveOp_Callback_StopRecurs = 1 , RecursiveOp_Callback_Error = 2 } |
Functions | |
| char * | BLI_file_ungzip_to_mem (const char *from_file, int *r_size) |
| size_t | BLI_gzip_mem_to_file_at_pos (void *buf, size_t len, FILE *file, size_t gz_stream_offset, int compression_level) |
| size_t | BLI_ungzip_file_to_mem_at_pos (void *buf, size_t len, FILE *file, size_t gz_stream_offset) |
| bool | BLI_file_is_writable (const char *filename) |
| bool | BLI_file_touch (const char *file) |
| static void | join_dirfile_alloc (char **dst, size_t *alloc_len, const char *dir, const char *file) |
| static char * | strip_last_slash (const char *dir) |
| static int | recursive_operation (const char *startfrom, const char *startto, RecursiveOp_Callback callback_dir_pre, RecursiveOp_Callback callback_file, RecursiveOp_Callback callback_dir_post) |
| static int | delete_callback_post (const char *from, const char *UNUSED(to)) |
| static int | delete_single_file (const char *from, const char *UNUSED(to)) |
| static int | delete_soft (const char *file, const char **error_message) |
| FILE * | BLI_fopen (const char *filename, const char *mode) |
| void * | BLI_gzopen (const char *filename, const char *mode) |
| int | BLI_open (const char *filename, int oflag, int pmode) |
| int | BLI_access (const char *filename, int mode) |
| int | BLI_delete (const char *file, bool dir, bool recursive) |
| int | BLI_delete_soft (const char *file, const char **error_message) |
| static bool | check_the_same (const char *path_a, const char *path_b) |
| static int | set_permissions (const char *file, const struct stat *st) |
| static int | copy_callback_pre (const char *from, const char *to) |
| static int | copy_single_file (const char *from, const char *to) |
| static const char * | check_destination (const char *file, const char *to) |
| int | BLI_copy (const char *file, const char *to) |
| bool | BLI_dir_create_recursive (const char *dirname) |
| int | BLI_rename (const char *from, const char *to) |
| typedef int(* RecursiveOp_Callback) (const char *from, const char *to) |
| anonymous enum |
| int BLI_access | ( | const char * | filename, |
| int | mode | ||
| ) |
Definition at line 1024 of file fileops.c.
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(), and wm_homefile_read_exec().
| int BLI_copy | ( | const char * | file, |
| const char * | to | ||
| ) |
Definition at line 1307 of file fileops.c.
References check_destination(), copy_callback_pre(), copy_single_file(), file, MEM_freeN, NULL, recursive_operation(), and ret.
Referenced by BKE_packedfile_compare_to_file(), and DocumentExporter::exportCurrentScene().
| int BLI_delete | ( | const char * | file, |
| bool | dir, | ||
| bool | recursive | ||
| ) |
Deletes the specified file or directory (depending on dir), optionally doing recursive delete of directory contents.
Definition at line 1037 of file fileops.c.
References BLI_assert, BLI_path_is_rel(), delete_callback_post(), delete_single_file(), file, NULL, and recursive_operation().
Referenced by BKE_packedfile_compare_to_file(), BKE_ptcache_id_clear(), BKE_ptcache_remove(), BKE_tempdir_session_purge(), BLI_rename(), cdf_remove(), blender::io::alembic::AlembicExportTest::deleteArchive(), blender::io::alembic::export_endjob(), blender::io::usd::export_endjob(), DocumentExporter::exportCurrentScene(), IMB_thumb_delete(), IMB_thumb_manage(), RE_RenderAnim(), seq_disk_cache_delete_file(), seq_disk_cache_handle_versioning(), and wm_autosave_delete().
| int BLI_delete_soft | ( | const char * | file, |
| const char ** | 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 1056 of file fileops.c.
References BLI_assert, BLI_path_is_rel(), delete_soft(), and file.
Referenced by file_delete_single().
| bool BLI_dir_create_recursive | ( | const char * | dirname | ) |
Definition at line 1329 of file fileops.c.
References BLI_dir_create_recursive(), BLI_exists(), BLI_is_dir(), BLI_path_slash_rfind(), BLI_path_slash_rstrip(), BLI_strncpy(), dirname(), MAXPATHLEN, MEM_callocN, MEM_freeN, ret, and size().
Referenced by BKE_appdir_folder_id_create(), BLI_dir_create_recursive(), BLI_make_existing_file(), MANTA::exportLiquidScript(), MANTA::exportSmokeScript(), file_directory_new_exec(), fluid_bake_startjob(), fluid_validatepaths(), IMB_thumb_makedirs(), tempdir_session_create(), and MANTA::writeConfiguration().
| bool BLI_file_is_writable | ( | const char * | filename | ) |
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 265 of file fileops.c.
References BLI_access(), BLI_split_dirfile(), FILE_MAX, and NULL.
Referenced by image_save_exec(), RE_is_rendering_allowed(), sequencer_export_subtitles_exec(), txt_write_file(), and wm_file_write().
| bool BLI_file_touch | ( | const char * | file | ) |
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 294 of file fileops.c.
References BLI_fopen(), Freestyle::c, file, and NULL.
Referenced by RE_RenderAnim(), seq_disk_cache_read_file(), and sequencer_export_subtitles_exec().
| char* BLI_file_ungzip_to_mem | ( | const char * | from_file, |
| int * | r_size | ||
| ) |
Definition at line 117 of file fileops.c.
References BLI_gzopen(), MEM_callocN, MEM_freeN, MEM_reallocN, NULL, and size().
| FILE* BLI_fopen | ( | const char * | filename, |
| const char * | mode | ||
| ) |
Definition at line 1003 of file fileops.c.
References BLI_assert, and BLI_path_is_rel().
Referenced by arg_handle_log_file_set(), AVI_is_avi(), AVI_open_compress(), AVI_open_movie(), 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(), cineonCreate(), cineonOpen(), dpxCreate(), dpxOpen(), EEVEE_lut_update_ggx_brdf(), EEVEE_lut_update_ggx_btdf(), fsmenu_read_bookmarks(), fsmenu_write_file(), fsmenu_xdg_user_dirs_parse(), IMB_index_builder_create(), IMB_indexer_open(), imb_savebmp(), imb_savehdr(), imb_savepng(), imb_savetarga(), logImageOpenFromFile(), make(), MOD_meshcache_read_mdd_times(), MOD_meshcache_read_pc2_times(), opj_stream_create_from_file(), output_iris(), ptcache_file_open(), python_script_exec(), 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_calculate_diffuse_light(), studiolight_load_spherical_harmonics_coefficients(), studiolight_write_solid_light(), txt_write_file(), wm_history_file_write(), and wm_platform_support_check_approval().
| size_t BLI_gzip_mem_to_file_at_pos | ( | void * | buf, |
| size_t | len, | ||
| FILE * | file, | ||
| size_t | gz_stream_offset, | ||
| int | compression_level | ||
| ) |
| void* BLI_gzopen | ( | const char * | filename, |
| const char * | mode | ||
| ) |
Definition at line 1010 of file fileops.c.
References BLI_assert, and BLI_path_is_rel().
Referenced by BLI_file_ungzip_to_mem(), blo_filedata_from_file_descriptor(), MANTA::readConfiguration(), wm_read_exotic(), MANTA::writeConfiguration(), and ww_open_zlib().
| int BLI_open | ( | const char * | filename, |
| int | oflag, | ||
| int | pmode | ||
| ) |
Definition at line 1017 of file fileops.c.
References BLI_assert, BLI_path_is_rel(), and oflag.
Referenced by BKE_image_load(), BKE_movieclip_file_add(), BKE_packedfile_compare_to_file(), BKE_packedfile_new(), blo_filedata_from_file_open(), BLO_memfile_write_file(), build_pict_list_ex(), image_update_views_format(), imb_ispic_read_header_from_filepath(), IMB_loadiffname(), imb_loadtile(), IMB_testiffname(), M_imbuf_load(), prefetch_read_file_to_memory(), proxy_thread_next_frame(), and ww_open_none().
| int BLI_rename | ( | const char * | from, |
| const char * | to | ||
| ) |
Definition at line 1381 of file fileops.c.
References BLI_delete(), BLI_exists(), and from.
Referenced by BKE_packedfile_compare_to_file(), BKE_ptcache_disk_cache_rename(), BLO_write_file(), do_history(), DocumentExporter::exportCurrentScene(), IMB_index_builder_finish(), renamebutton_cb(), thumb_create_ex(), and wm_autosave_delete().
| size_t BLI_ungzip_file_to_mem_at_pos | ( | void * | buf, |
| size_t | len, | ||
| FILE * | file, | ||
| size_t | gz_stream_offset | ||
| ) |
|
static |
Definition at line 1273 of file fileops.c.
References BLI_join_dirfile(), BLI_path_slash_rfind(), file, len, MEM_callocN, MEM_freeN, S_ISDIR, str, and strip_last_slash().
Referenced by BLI_copy().
|
static |
Do the two paths denote the same file-system object?
Definition at line 1066 of file fileops.c.
Referenced by copy_callback_pre(), and copy_single_file().
|
static |
Definition at line 1101 of file fileops.c.
References check_the_same(), from, RecursiveOp_Callback_Error, and RecursiveOp_Callback_OK.
Referenced by BLI_copy().
|
static |
Definition at line 1130 of file fileops.c.
References check_the_same(), from, len, MEM_callocN, MEM_freeN, RecursiveOp_Callback_Error, RecursiveOp_Callback_OK, S_ISREG, and set_permissions().
Referenced by BLI_copy().
|
static |
Definition at line 887 of file fileops.c.
References from, RecursiveOp_Callback_Error, and RecursiveOp_Callback_OK.
Referenced by BLI_delete().
|
static |
Definition at line 898 of file fileops.c.
References from, RecursiveOp_Callback_Error, and RecursiveOp_Callback_OK.
Referenced by BLI_delete().
|
static |
|
static |
Definition at line 714 of file fileops.c.
References BLI_join_dirfile(), file, len, MEM_mallocN, MEM_reallocN, and NULL.
Referenced by recursive_operation().
|
static |
Scans startfrom, generating a corresponding destination name for each item found by prefixing it with startto, recursively scanning subdirectories, and invoking the specified callbacks for files and subdirectories found as appropriate.
| startfrom | Top-level source path. |
| startto | Top-level destination path. |
| callback_dir_pre | Optional, to be invoked before entering a subdirectory, can return RecursiveOp_Callback_StopRecurs to skip the subdirectory. |
| callback_file | Optional, to be invoked on each file found. |
| callback_dir_post | optional, to be invoked after leaving a subdirectory. |
Definition at line 751 of file fileops.c.
References BLI_path_join(), dirent::d_name, FILE_MAX, FILENAME_IS_CURRPAR, free(), from, join_dirfile_alloc(), MEM_freeN, NULL, RecursiveOp_Callback_OK, RecursiveOp_Callback_StopRecurs, ret, S_ISDIR, and strip_last_slash().
Referenced by BLI_copy(), and BLI_delete().
|
static |
Sets the mode and ownership of file to the values from st.
Definition at line 1084 of file fileops.c.
References file.
Referenced by copy_single_file().
|
static |
Definition at line 730 of file fileops.c.
References BLI_path_slash_rstrip(), BLI_strdup(), and result.
Referenced by check_destination(), and recursive_operation().