57 if (library_dirpath ==
nullptr || library_dirpath[0] ==
'\0') {
84 return preferences_lib->dirpath;
105 char r_path_buffer[1090 ],
111 std::optional<AssetLibraryService::ExplodedPath> exploded =
124 r_path_buffer[0] =
'\0';
128 BLI_assert(!exploded->group_component.is_empty());
129 BLI_assert(!exploded->name_component.is_empty());
131 BLI_strncpy(r_path_buffer, exploded->full_path->c_str(), 1090 );
133 if (!exploded->dir_component.is_empty()) {
134 r_path_buffer[exploded->dir_component.size()] =
'\0';
135 r_path_buffer[exploded->dir_component.size() + 1 + exploded->group_component.size()] =
'\0';
138 *r_dir = r_path_buffer;
141 *r_group = r_path_buffer + exploded->dir_component.size() + 1;
144 *r_name = r_path_buffer + exploded->dir_component.size() + 1 +
145 exploded->group_component.size() + 1;
149 r_path_buffer[exploded->group_component.size()] =
'\0';
155 *r_group = r_path_buffer;
158 *r_name = r_path_buffer + exploded->group_component.size() + 1;
166 : library_type_(library_type),
168 root_path_(std::make_shared<std::string>(
utils::normalize_directory_path(root_path))),
181 const bool include_all_library)
206 std::unique_ptr<AssetMetaData> metadata)
208 return asset_storage_.external_assets.lookup_key_or_add(std::make_shared<AssetRepresentation>(
209 relative_asset_path, name, id_type, std::move(metadata), *
this));
215 return asset_storage_.local_id_assets.lookup_key_or_add(
216 std::make_shared<AssetRepresentation>(relative_asset_path,
id, *
this));
221 if (asset_storage_.local_id_assets.remove_as(&asset)) {
224 return asset_storage_.external_assets.remove_as(&asset);
231 for (
auto &asset_ptr : asset_storage_.local_id_assets) {
240 removed_assets.
add(&asset);
250void asset_library_on_save_post(
Main *bmain,
252 const int num_pointers,
302 if (catalog ==
nullptr) {
312 return library_type_;
332 result.append(library_ref);
342 result.append(library_ref);
348 result.append(library_ref);
357 return all_library_ref;
Main runtime representation of an asset.
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
void BKE_callback_remove(bCallbackFuncStore *funcstore, eCbEvent evt)
@ ID_REMAP_RESULT_SOURCE_UNASSIGNED
struct bUserAssetLibrary * BKE_preferences_asset_library_containing_path(const struct UserDef *userdef, const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
File and directory operations.
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
#define STRNCPY(dst, src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
bool BLI_uuid_is_nil(bUUID uuid)
@ ASSET_LIBRARY_ESSENTIALS
void AS_asset_library_remap_ids(const bke::id::IDRemapper &mappings)
std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain)
void AS_asset_libraries_exit()
AssetLibrary * AS_asset_library_load(const Main *bmain, const AssetLibraryReference &library_reference)
std::string AS_asset_library_find_suitable_root_path_from_path(const blender::StringRefNull input_path)
std::string AS_asset_library_root_path_from_library_ref(const AssetLibraryReference &library_reference)
bool AS_asset_library_has_any_unsaved_catalogs()
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)
constexpr const char * c_str() const
AssetCatalog * find_catalog(CatalogID catalog_id) const
bool write_to_disk(const CatalogFilePath &blend_file_path)
void foreach_loaded_asset_library(FunctionRef< void(AssetLibrary &)> fn, bool include_all_library) const
AssetLibrary * get_asset_library(const Main *bmain, const AssetLibraryReference &library_reference)
AssetLibrary * get_asset_library_current_file()
void reload_all_library_catalogs_if_dirty()
std::optional< ExplodedPath > resolve_asset_weak_reference_to_exploded_path(const AssetWeakReference &asset_reference)
std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference)
static AssetLibraryService * get()
AssetLibrary * get_asset_library_on_disk_custom(StringRef name, StringRefNull root_path)
static std::string root_path_from_library_ref(const AssetLibraryReference &library_reference)
bool has_any_unsaved_catalogs() const
void on_blend_save_post(Main *bmain, PointerRNA **pointers, int num_pointers)
static bool save_catalogs_when_file_is_saved
eAssetLibraryType library_type() const
void on_blend_save_handler_register()
std::unique_ptr< AssetCatalogService > catalog_service_
void remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings)
std::weak_ptr< AssetRepresentation > add_local_id_asset(StringRef relative_asset_path, ID &id)
bCallbackFuncStore on_save_callback_store_
AssetCatalogService & catalog_service() const
static void foreach_loaded(FunctionRef< void(AssetLibrary &)> fn, bool include_all_library)
AssetLibrary(eAssetLibraryType library_type, StringRef name="", StringRef root_path="")
bool remove_asset(AssetRepresentation &asset)
void refresh_catalog_simplename(AssetMetaData *asset_data)
std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference)
StringRefNull name() const
StringRefNull root_path() const
virtual void refresh_catalogs()
std::weak_ptr< AssetRepresentation > add_external_asset(StringRef relative_asset_path, StringRef name, int id_type, std::unique_ptr< AssetMetaData > metadata)
void on_blend_save_handler_unregister()
std::mutex catalog_service_mutex_
IDRemapperApplyResult apply(ID **r_id_ptr, IDRemapperApplyOptions options, ID *id_self=nullptr) const
AssetLibraryReference all_library_reference()
void all_library_reload_catalogs_if_dirty()
Vector< AssetLibraryReference > all_valid_asset_library_refs()
void(* func)(Main *, PointerRNA **, int num_pointers, void *arg)
static DynamicLibrary lib