58 if (library_dirpath ==
nullptr || library_dirpath[0] ==
'\0') {
85 return preferences_lib->dirpath;
106 char r_path_buffer[1090 ],
112 std::optional<AssetLibraryService::ExplodedPath> exploded =
125 r_path_buffer[0] =
'\0';
129 BLI_assert(!exploded->group_component.is_empty());
130 BLI_assert(!exploded->name_component.is_empty());
132 BLI_strncpy(r_path_buffer, exploded->full_path->c_str(), 1090 );
134 if (!exploded->dir_component.is_empty()) {
135 r_path_buffer[exploded->dir_component.size()] =
'\0';
136 r_path_buffer[exploded->dir_component.size() + 1 + exploded->group_component.size()] =
'\0';
139 *r_dir = r_path_buffer;
142 *r_group = r_path_buffer + exploded->dir_component.size() + 1;
145 *r_name = r_path_buffer + exploded->dir_component.size() + 1 +
146 exploded->group_component.size() + 1;
150 r_path_buffer[exploded->group_component.size()] =
'\0';
156 *r_group = r_path_buffer;
159 *r_name = r_path_buffer + exploded->group_component.size() + 1;
169 root_path_(std::make_shared<std::string>(
utils::normalize_directory_path(
root_path))),
182 const bool include_all_library)
221 std::unique_ptr<AssetMetaData> metadata)
223 return asset_storage_.external_assets.lookup_key_or_add(std::make_shared<AssetRepresentation>(
224 relative_asset_path,
name, id_type, std::move(metadata), *
this));
230 return asset_storage_.local_id_assets.lookup_key_or_add(
231 std::make_shared<AssetRepresentation>(relative_asset_path,
id, *
this));
238 if (&asset.owner_asset_library_ !=
this) {
242 BLI_assert(asset_storage_.local_id_assets.contains_as(&asset) ||
243 asset_storage_.external_assets.contains_as(&asset));
245 if (asset_storage_.local_id_assets.remove_as(&asset)) {
248 return asset_storage_.external_assets.remove_as(&asset);
255 for (
const auto &asset_ptr : asset_storage_.local_id_assets) {
264 removed_assets.
add(&asset);
274void asset_library_on_save_post(
Main *bmain,
276 const int num_pointers,
289 on_disk_lib->catalog_service().undo_push();
344 if (catalog ==
nullptr) {
354 return library_type_;
374 result.append(library_ref);
384 result.append(library_ref);
390 result.append(library_ref);
399 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
char * STRNCPY(char(&dst)[N], const char *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)
AssetLibrary * AS_asset_library_load_from_directory(const char *name, const char *library_dirpath)
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 bool is_empty() const
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_on_disk_builtin(eAssetLibraryType type, StringRefNull root_path)
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)
static AssetLibrary * move_runtime_current_file_into_on_disk_library(const Main &bmain)
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)
void load_or_reload_catalogs()
static bool save_catalogs_when_file_is_saved
eAssetLibraryType library_type() const
void on_blend_save_handler_register()
std::unique_ptr< AssetCatalogService > catalog_service_
friend class AssetLibraryService
void remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings)
friend class AssetRepresentation
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)
Mutex catalog_service_mutex_
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()
IDRemapperApplyResult apply(ID **r_id_ptr, IDRemapperApplyOptions options, ID *id_self=nullptr) const
AssetLibraryReference all_library_reference()
AssetLibraryReference current_file_library_reference()
void all_library_reload_catalogs_if_dirty()
Vector< AssetLibraryReference > all_valid_asset_library_refs()
static DynamicLibrary lib