Blender
V3.3
|
#include <sys/stat.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include "MEM_guardedalloc.h"
#include "DNA_brush_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_fluid_types.h"
#include "DNA_freestyle_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_node_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_pointcache_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_sound_types.h"
#include "DNA_text_types.h"
#include "DNA_texture_types.h"
#include "DNA_vfont_types.h"
#include "DNA_volume_types.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BKE_idtype.h"
#include "BKE_image.h"
#include "BKE_lib_id.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_vfont.h"
#include "BKE_bpath.h"
#include "CLG_log.h"
#include "SEQ_iterator.h"
#include "BLI_strict_flags.h"
Go to the source code of this file.
Classes | |
struct | BPathFind_Data |
struct | BPathRebase_Data |
struct | BPathRemap_Data |
struct | PathStore |
Variables | |
static CLG_LogRef | LOG = {"bke.bpath"} |
Find Missing Files | |
#define | MAX_DIR_RECURSE 16 |
#define | FILESIZE_INVALID_DIRECTORY -1 |
typedef struct BPathFind_Data | BPathFind_Data |
static bool | missing_files_find__recursive (const char *search_directory, const char *filename_src, char r_filename_new[FILE_MAX], int64_t *r_filesize, int *r_recurse_depth) |
static bool | missing_files_find_foreach_path_cb (BPathForeachPathData *bpath_data, char *path_dst, const char *path_src) |
void | BKE_bpath_missing_files_find (Main *bmain, const char *searchpath, ReportList *reports, const bool find_all) |
Rebase Relative Paths | |
typedef struct BPathRebase_Data | BPathRebase_Data |
static bool | relative_rebase_foreach_path_cb (BPathForeachPathData *bpath_data, char *path_dst, const char *path_src) |
void | BKE_bpath_relative_rebase (Main *bmain, const char *basedir_src, const char *basedir_dst, ReportList *reports) |
Make Paths Relative Or Absolute | |
typedef struct BPathRemap_Data | BPathRemap_Data |
static bool | relative_convert_foreach_path_cb (BPathForeachPathData *bpath_data, char *path_dst, const char *path_src) |
static bool | absolute_convert_foreach_path_cb (BPathForeachPathData *bpath_data, char *path_dst, const char *path_src) |
static void | bpath_absolute_relative_convert (Main *bmain, const char *basedir, ReportList *reports, BPathForeachPathFunctionCallback callback_function) |
void | BKE_bpath_relative_convert (Main *bmain, const char *basedir, ReportList *reports) |
void | BKE_bpath_absolute_convert (Main *bmain, const char *basedir, ReportList *reports) |
typedef struct BPathFind_Data BPathFind_Data |
typedef struct BPathRebase_Data BPathRebase_Data |
typedef struct BPathRemap_Data BPathRemap_Data |
|
static |
Definition at line 507 of file bpath.c.
References BKE_reportf(), BLI_path_abs(), BLI_path_is_rel(), BLI_strncpy(), data, if(), RPT_WARNING, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_absolute_convert().
void BKE_bpath_absolute_convert | ( | struct Main * | bmain, |
const char * | basedir, | ||
struct ReportList * | reports | ||
) |
Make all relative file paths in given bmain absolute, using given basedir as root.
Definition at line 564 of file bpath.c.
References absolute_convert_foreach_path_cb(), and bpath_absolute_relative_convert().
Referenced by BLO_write_file(), make_paths_absolute_exec(), and blender::bke::tests::TEST_F().
bool BKE_bpath_foreach_path_allocated_process | ( | struct BPathForeachPathData * | bpath_data, |
char ** | path | ||
) |
Run the callback on a path, replacing the content of the string as needed.
path | A pointer to a MEM-allocated string. If modified, it will be freed and replaced by a new allocated string. |
Definition at line 175 of file bpath.c.
References BPathForeachPathData::absolute_base_path, BLI_path_abs(), BLI_strdup(), BLI_strncpy(), BPathForeachPathData::callback_function, FILE_MAX, and MEM_freeN.
Referenced by text_foreach_path().
bool BKE_bpath_foreach_path_dirfile_fixed_process | ( | struct BPathForeachPathData * | bpath_data, |
char * | path_dir, | ||
char * | path_file | ||
) |
Run the callback on a (directory + file) path, replacing the content of the two strings as needed.
path_dir | A fixed, FILE_MAXDIR-sized char buffer. |
path_file | A fixed, FILE_MAXFILE-sized char buffer. |
Definition at line 149 of file bpath.c.
References BPathForeachPathData::absolute_base_path, BLI_join_dirfile(), BLI_path_abs(), BLI_split_dirfile(), BLI_strncpy(), BPathForeachPathData::callback_function, FILE_MAX, FILE_MAXDIR, and FILE_MAXFILE.
Referenced by seq_foreach_path_callback().
bool BKE_bpath_foreach_path_fixed_process | ( | struct BPathForeachPathData * | bpath_data, |
char * | path | ||
) |
Run the callback on a path, replacing the content of the string as needed.
path | A fixed, FILE_MAX-sized char buffer. |
Definition at line 121 of file bpath.c.
References BPathForeachPathData::absolute_base_path, BLI_path_abs(), BLI_strncpy(), BPathForeachPathData::callback_function, and FILE_MAX.
Referenced by BKE_bpath_foreach_path_id(), brush_foreach_path(), cache_file_foreach_path(), image_foreach_path(), library_foreach_path(), mesh_foreach_path(), movie_clip_foreach_path(), node_foreach_path(), object_foreach_path(), object_foreach_path_pointcache(), seq_foreach_path_callback(), sound_foreach_path(), vfont_foreach_path(), and volume_foreach_path().
void BKE_bpath_foreach_path_id | ( | BPathForeachPathData * | bpath_data, |
struct ID * | id | ||
) |
Run bpath_data.callback_function
on all paths contained in id
.
Definition at line 80 of file bpath.c.
References BPathForeachPathData::absolute_base_path, BKE_BPATH_FOREACH_PATH_ABSOLUTE, BKE_bpath_foreach_path_fixed_process(), BKE_bpath_foreach_path_id(), BKE_BPATH_FOREACH_PATH_SKIP_LINKED, BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES, BKE_idtype_get_info_from_id(), BLI_assert, BPathForeachPathData::bmain, BPathForeachPathData::flag, IDTypeInfo::foreach_path, id, bNodeTree::id, ID_BLEND_PATH, ID_IS_LINKED, LibraryWeakReference::library_filepath, ID::library_weak_reference, ntreeFromID(), and NULL.
Referenced by BKE_bpath_foreach_path_id(), BKE_bpath_foreach_path_main(), and lib_id_library_local_paths().
void BKE_bpath_foreach_path_main | ( | BPathForeachPathData * | bpath_data | ) |
Run bpath_data.callback_function
on all paths of all IDs in bmain
.
Definition at line 112 of file bpath.c.
References BKE_bpath_foreach_path_id(), BPathForeachPathData::bmain, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, and id.
Referenced by BKE_bpath_list_backup(), BKE_bpath_list_restore(), BKE_bpath_missing_files_check(), BKE_bpath_missing_files_find(), BKE_bpath_relative_rebase(), bpath_absolute_relative_convert(), bpy_blend_paths(), clean_paths(), and has_external_files().
void* BKE_bpath_list_backup | ( | struct Main * | bmain, |
eBPathForeachFlag | flag | ||
) |
Temp backup of paths from all IDs in given bmain.
Definition at line 619 of file bpath.c.
References BKE_bpath_foreach_path_main(), bpath_list_append(), and MEM_callocN.
Referenced by BKE_blendfile_write_partial(), BLO_write_file(), and blender::bke::tests::TEST_F().
Free the temp backup of paths in path_list_handle.
Definition at line 641 of file bpath.c.
References BLI_assert, BLI_freelistN(), BLI_listbase_is_empty(), and MEM_freeN.
Referenced by BKE_blendfile_write_partial(), BLO_write_file(), and blender::bke::tests::TEST_F().
void BKE_bpath_list_restore | ( | struct Main * | bmain, |
eBPathForeachFlag | flag, | ||
void * | path_list_handle | ||
) |
Restore the temp backup of paths from path_list_handle into all IDs in given bmain.
Definition at line 631 of file bpath.c.
References BKE_bpath_foreach_path_main(), and bpath_list_restore().
Referenced by BKE_blendfile_write_partial(), BLO_write_file(), and blender::bke::tests::TEST_F().
void BKE_bpath_missing_files_check | ( | struct Main * | bmain, |
struct ReportList * | reports | ||
) |
Check for missing files.
Definition at line 220 of file bpath.c.
References BKE_BPATH_FOREACH_PATH_ABSOLUTE, BKE_bpath_foreach_path_main(), BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN, BKE_BPATH_FOREACH_PATH_SKIP_PACKED, BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES, and check_missing_files_foreach_path_cb().
Referenced by report_missing_files_exec().
void BKE_bpath_missing_files_find | ( | struct Main * | bmain, |
const char * | searchpath, | ||
struct ReportList * | reports, | ||
bool | find_all | ||
) |
Recursively search into given search directory, for all file paths of all IDs in given bmain, and replace existing paths as needed.
searchpath | The root directory in which the new filepaths should be searched for. |
find_all | If true , also search for files which current path is still valid, if false skip those still valid paths. |
Definition at line 368 of file bpath.c.
References BKE_BPATH_FOREACH_PATH_ABSOLUTE, BKE_bpath_foreach_path_main(), BKE_BPATH_FOREACH_PATH_RELOAD_EDITED, BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN, BKE_main_blendfile_path(), data, BPathFind_Data::find_all, missing_files_find_foreach_path_cb(), NULL, and BPathFind_Data::reports.
Referenced by find_missing_files_exec().
void BKE_bpath_relative_convert | ( | struct Main * | bmain, |
const char * | basedir, | ||
struct ReportList * | reports | ||
) |
Make all absolute file paths in given bmain relative to given basedir.
Definition at line 559 of file bpath.c.
References bpath_absolute_relative_convert(), and relative_convert_foreach_path_cb().
Referenced by BLO_write_file(), make_paths_relative_exec(), and blender::bke::tests::TEST_F().
void BKE_bpath_relative_rebase | ( | struct Main * | bmain, |
const char * | basedir_src, | ||
const char * | basedir_dst, | ||
struct ReportList * | reports | ||
) |
Rebase all relative file paths in given bmain from basedir_src to basedir_dst.
Definition at line 439 of file bpath.c.
References BKE_bpath_foreach_path_main(), BKE_BPATH_FOREACH_PATH_SKIP_LINKED, BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE, BKE_reportf(), BLI_assert, data, NULL, relative_rebase_foreach_path_cb(), RPT_INFO, and RPT_WARNING.
Referenced by BLO_write_file(), and blender::bke::tests::TEST_F().
|
static |
Definition at line 531 of file bpath.c.
References BKE_bpath_foreach_path_main(), BKE_BPATH_FOREACH_PATH_SKIP_LINKED, BKE_reportf(), BLI_assert, CLOG_ERROR, data, LOG, NULL, RPT_INFO, and RPT_WARNING.
Referenced by BKE_bpath_absolute_convert(), and BKE_bpath_relative_convert().
|
static |
Definition at line 580 of file bpath.c.
References BLI_addtail(), BLI_strncpy(), MEM_mallocN, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_list_backup().
|
static |
Definition at line 596 of file bpath.c.
References BLI_assert, BLI_freelinkN(), BLI_listbase_is_empty(), BLI_strncpy(), FILE_MAX, ListBase::first, STREQ, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_list_restore().
|
static |
Definition at line 207 of file bpath.c.
References BKE_reportf(), BLI_exists(), if(), RPT_WARNING, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_missing_files_check().
|
static |
Find the given filename recursively in the given search directory and its sub-directories.
search_directory | Directory to search in. |
filename_src | Search for this filename. |
r_filename_new | The path of the new found file will be copied here, caller must initialize as empty string. |
r_filesize | Size of the file, FILESIZE_INVALID_DIRECTORY if search directory could not be opened. |
r_recurse_depth | Current recursion depth. |
Definition at line 253 of file bpath.c.
References BLI_join_dirfile(), BLI_path_ncmp, BLI_stat(), BLI_strncpy(), CLOG_WARN, closedir(), FILE_MAX, FILENAME_IS_CURRPAR, FILESIZE_INVALID_DIRECTORY, LOG, MAX_DIR_RECURSE, NULL, opendir(), readdir(), S_ISDIR, S_ISREG, and size().
Referenced by missing_files_find_foreach_path_cb().
|
static |
Definition at line 320 of file bpath.c.
References BKE_reportf(), BLI_exists(), BLI_path_basename(), BLI_path_is_rel(), BLI_path_rel(), BLI_strncpy(), data, FILE_MAX, FILESIZE_INVALID_DIRECTORY, if(), missing_files_find__recursive(), RPT_WARNING, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_missing_files_find().
|
static |
Definition at line 483 of file bpath.c.
References BKE_reportf(), BLI_path_is_rel(), BLI_path_rel(), BLI_strncpy(), data, FILE_MAX, if(), RPT_WARNING, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_relative_convert().
|
static |
Definition at line 408 of file bpath.c.
References BKE_reportf(), BLI_path_abs(), BLI_path_is_rel(), BLI_path_normalize(), BLI_path_rel(), BLI_strncpy(), data, FILE_MAX, FILE_MAXDIR, FILE_MAXFILE, if(), NULL, RPT_WARNING, and BPathForeachPathData::user_data.
Referenced by BKE_bpath_relative_rebase().
|
static |
Definition at line 74 of file bpath.c.
Referenced by bpath_absolute_relative_convert(), and missing_files_find__recursive().