Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/asset_library.cc
| Show All 15 Lines | |||||
| /** \file | /** \file | ||||
| * \ingroup bke | * \ingroup bke | ||||
| */ | */ | ||||
| #include "BKE_asset_library.hh" | #include "BKE_asset_library.hh" | ||||
| #include "BKE_callbacks.h" | #include "BKE_callbacks.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_preferences.h" | |||||
| #include "BLI_path_util.h" | |||||
| #include "DNA_userdef_types.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include <memory> | #include <memory> | ||||
| /** | /** | ||||
| * Loading an asset library at this point only means loading the catalogs. Later on this should | * Loading an asset library at this point only means loading the catalogs. Later on this should | ||||
| * invoke reading of asset representations too. | * invoke reading of asset representations too. | ||||
| */ | */ | ||||
| struct AssetLibrary *BKE_asset_library_load(const char *library_path) | struct AssetLibrary *BKE_asset_library_load(const char *library_path) | ||||
| { | { | ||||
| blender::bke::AssetLibrary *lib = new blender::bke::AssetLibrary(); | blender::bke::AssetLibrary *lib = new blender::bke::AssetLibrary(); | ||||
| lib->on_save_handler_register(); | lib->on_save_handler_register(); | ||||
| lib->load(library_path); | lib->load(library_path); | ||||
| return reinterpret_cast<struct AssetLibrary *>(lib); | return reinterpret_cast<struct AssetLibrary *>(lib); | ||||
| } | } | ||||
| void BKE_asset_library_free(struct AssetLibrary *asset_library) | void BKE_asset_library_free(struct AssetLibrary *asset_library) | ||||
| { | { | ||||
| blender::bke::AssetLibrary *lib = reinterpret_cast<blender::bke::AssetLibrary *>(asset_library); | blender::bke::AssetLibrary *lib = reinterpret_cast<blender::bke::AssetLibrary *>(asset_library); | ||||
| lib->on_save_handler_unregister(); | lib->on_save_handler_unregister(); | ||||
| delete lib; | delete lib; | ||||
| } | } | ||||
| bool BKE_asset_library_find_suitable_root_path_from_path(const char *input_path, | |||||
| char *r_library_path) | |||||
| { | |||||
| if (bUserAssetLibrary *preferences_lib = BKE_preferences_asset_library_containing_path( | |||||
| &U, input_path)) { | |||||
| BLI_strncpy(r_library_path, preferences_lib->path, FILE_MAXDIR); | |||||
| return true; | |||||
| } | |||||
| BLI_split_dir_part(input_path, r_library_path, FILE_MAXDIR); | |||||
sybren: There is no `bmain` in this function; this part of the comment should go with the one below. | |||||
| return r_library_path[0] != '\0'; | |||||
| } | |||||
Done Inline ActionsDocument whether this returns a path with a trailing slash or not. BLI_split_dir_part produces a trailing slash on the returned directory. sybren: Document whether this returns a path with a trailing slash or not. `BLI_split_dir_part`… | |||||
| bool BKE_asset_library_find_suitable_root_path_from_main(const Main *bmain, char *r_library_path) | |||||
| { | |||||
| return BKE_asset_library_find_suitable_root_path_from_path(bmain->name, r_library_path); | |||||
| } | |||||
| namespace blender::bke { | namespace blender::bke { | ||||
| void AssetLibrary::load(StringRefNull library_root_directory) | void AssetLibrary::load(StringRefNull library_root_directory) | ||||
| { | { | ||||
| auto catalog_service = std::make_unique<AssetCatalogService>(library_root_directory); | auto catalog_service = std::make_unique<AssetCatalogService>(library_root_directory); | ||||
| catalog_service->load_from_disk(); | catalog_service->load_from_disk(); | ||||
| this->catalog_service = std::move(catalog_service); | this->catalog_service = std::move(catalog_service); | ||||
| } | } | ||||
| Show All 40 Lines | |||||
There is no bmain in this function; this part of the comment should go with the one below.