50 const char *asset_name,
55 lapp_params.
bmain = &global_main;
62 lapp_context, asset_name, id_type,
nullptr);
79 if (local_asset && local_asset->
lib) {
110 return std::string(libpath) +
SEP +
"Saved" +
SEP + name;
130 std::min(
sizeof(base_name_filesafe),
size_t(base_name.
size() + 1)));
141 for (
int i = 1;; i++) {
142 const std::string filepath = root_path +
SEP + base_name_filesafe +
"_" + std::to_string(i++) +
154 ID *
id =
static_cast<ID *
>(vid);
190 id_remapper.
add(id_src, id_dst);
191 if (id_src == &id_asset) {
192 *id_asset_new = id_dst;
196 id_remapper.
add(id_src,
nullptr);
209 id_dst->
tag &= ~ID_TAG_NO_USER_REFCOUNT;
221 std::string &final_full_file_path,
224 ID &
id =
const_cast<ID &
>(id_const);
226 ID *new_id =
nullptr;
229 std::string new_name = name;
240 new_main, filepath.
c_str(), write_flags, &blend_file_write_params, &reports);
244 final_full_file_path = std::string(filepath) +
SEP + std::string(idtype->
name) +
SEP + name;
257 const std::string filepath =
id.lib->runtime.filepath_abs;
263 ID *new_id =
asset_link_id(global_main, id_type, filepath.c_str(), name.c_str(), reports);
275 const char *filepath)
282 char user_library_dirpath[
FILE_MAX];
287 STRNCPY(relative_filepath, filepath);
289 const char *asset_blend_path = relative_filepath + 2;
299 const char *filepath)
320 user_library, name,
GS(
id.name), reports);
322 std::string final_full_asset_filepath;
324 global_main,
id, name, filepath, final_full_asset_filepath, reports);
331 user_library,
GS(
id.name), name.c_str(), filepath.c_str());
335 return final_full_asset_filepath;
344 std::string final_full_asset_filepath;
348 id.
lib->runtime.filepath_abs,
349 final_full_asset_filepath,
372 if (
BLI_delete(
id.
lib->runtime.filepath_abs,
false,
false) != 0) {
391 char *asset_lib_path, *asset_group, *asset_name;
394 &weak_ref, asset_full_path_buffer, &asset_lib_path, &asset_group, &asset_name);
395 if (asset_lib_path ==
nullptr && asset_group ==
nullptr && asset_name ==
nullptr) {
400 if (asset_lib_path &&
STREQ(asset_lib_path, global_main.
filepath)) {
401 asset_lib_path =
nullptr;
408 &global_main, id_type, asset_name, asset_lib_path);
414 if (asset_lib_path ==
nullptr) {
418 return asset_link_id(global_main, id_type, asset_lib_path, asset_name);
439 &
U,
id.
lib->runtime.filepath_abs);
441 const short idcode =
GS(
id.name);
443 if (user_library && user_library->
dirpath[0]) {
445 *user_library, idcode,
id.name + 2,
id.
lib->runtime.filepath_abs);
void AS_asset_full_path_explode_from_weak_ref(const AssetWeakReference *asset_reference, char r_path_buffer[1090], char **r_dir, char **r_group, char **r_name)
#define BLENDER_ASSET_FILE_SUFFIX
void BKE_blendfile_link_append_context_finalize(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_blendfile_link_append_context_library_add(BlendfileLinkAppendContext *lapp_context, const char *libname, BlendHandle *blo_handle)
BlendfileLinkAppendContextItem * BKE_blendfile_link_append_context_item_add(BlendfileLinkAppendContext *lapp_context, const char *idname, short idcode, void *userdata)
void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_link_append_context_flag_set(BlendfileLinkAppendContext *lapp_context, int flag, bool do_set)
void BKE_blendfile_link_append_context_item_library_index_enable(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, int library_index)
BlendfileLinkAppendContext * BKE_blendfile_link_append_context_new(LibraryLink_Params *params)
void BKE_blendfile_link_append_context_init_done(BlendfileLinkAppendContext *lapp_context)
ID * BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
const IDTypeInfo * BKE_idtype_get_info_from_idcode(short id_code)
const char * BKE_idtype_idcode_to_name(short idcode)
const char * BKE_idtype_idcode_to_name_plural(short idcode)
void BKE_id_delete(Main *bmain, void *idv) ATTR_NONNULL()
@ LIB_ID_COPY_ASSET_METADATA
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_CREATE_NO_DEG_TAG
ID * BKE_libblock_find_name_and_library_filepath(Main *bmain, short type, const char *name, const char *lib_filepath_abs)
void id_fake_user_set(ID *id)
IDNewNameResult BKE_libblock_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
const char * BKE_id_name(const ID &id)
void BKE_main_id_refcount_recompute(Main *bmain, bool do_linked_only)
void BKE_libblock_remap_multiple_raw(Main *bmain, blender::bke::id::IDRemapper &mappings, const int remap_flags)
@ ID_REMAP_SKIP_USER_CLEAR
#define FOREACH_MAIN_ID_END
Main * BKE_main_new(void)
void BKE_main_free(Main *bmain)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
struct bUserAssetLibrary * BKE_preferences_asset_library_containing_path(const struct UserDef *userdef, const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
File and directory operations.
bool BLI_file_is_writable(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void BLI_path_slash_native(char *path) ATTR_NONNULL(1)
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
bool void BLI_path_rel(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
bool BLI_path_make_safe_filename(char *filename) ATTR_NONNULL(1)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
char BLI_toupper_ascii(const char c) ATTR_WARN_UNUSED_RESULT
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
external readfile function prototypes.
@ BLO_LIBLINK_FORCE_INDIRECT
void BLO_expand_main(void *fdhandle, Main *mainvar, BLOExpandDoitCallback callback)
external writefile.cc function prototypes.
bool BLO_write_file(Main *mainvar, const char *filepath, int write_flags, const BlendFileWriteParams *params, ReportList *reports)
@ BLO_WRITE_PATH_REMAP_RELATIVE
void DEG_relations_tag_update(Main *bmain)
#define ID_IS_LINKED(_id)
@ LIBRARY_IS_ASSET_EDIT_FILE
@ LIBRARY_ASSET_FILE_WRITABLE
@ ASSET_LIBRARY_ESSENTIALS
#define FILE_MAX_LIBEXTRA
Read Guarded memory(de)allocation.
constexpr int64_t size() const
constexpr const char * data() const
constexpr const char * c_str() const
void add(ID *old_id, ID *new_id)
ID * asset_edit_id_from_weak_reference(Main &global_main, ID_Type id_type, const AssetWeakReference &weak_ref)
static std::string asset_root_path_for_save(const bUserAssetLibrary &user_library, const ID_Type id_type)
static AssetWeakReference asset_weak_reference_for_user_library(const bUserAssetLibrary &user_library, const short idcode, const char *idname, const char *filepath)
std::optional< AssetWeakReference > asset_edit_weak_reference_from_id(const ID &id)
static AssetWeakReference asset_weak_reference_for_essentials(const short idcode, const char *idname, const char *filepath)
std::optional< std::string > asset_edit_id_save_as(Main &global_main, const ID &id, StringRefNull name, const bUserAssetLibrary &user_library, AssetWeakReference &r_weak_ref, ReportList &reports)
static void asset_main_create_expander(void *, Main *, void *vid)
static bool asset_write_in_library(Main &bmain, const ID &id_const, const StringRef name, const StringRefNull filepath, std::string &final_full_file_path, ReportList &reports)
static std::string asset_blendfile_path_for_save(const bUserAssetLibrary &user_library, const StringRef base_name, const ID_Type id_type, ReportList &reports)
ID * asset_edit_id_revert(Main &global_main, ID &id, ReportList &reports)
bool asset_edit_id_delete(Main &global_main, ID &id, ReportList &reports)
bool asset_edit_id_is_writable(const ID &id)
static ID * asset_reload(Main &global_main, ID &id, ReportList *reports)
static ID * asset_link_id(Main &global_main, const ID_Type id_type, const char *filepath, const char *asset_name, ReportList *reports=nullptr)
static Main * asset_main_create_from_ID(Main &bmain_src, ID &id_asset, ID **id_asset_new)
bool asset_edit_id_is_editable(const ID &id)
bool asset_edit_id_save(Main &global_main, const ID &id, ReportList &reports)
const char * relative_asset_identifier
const char * asset_library_identifier
eBLO_WritePathRemap remap_mode
struct Library_Runtime runtime
bool is_locked_for_linking
static DynamicLibrary lib