diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-09-30 18:30:30 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-09-30 18:34:58 +0300 |
commit | dd3391dd996e90fba3227c1cc2b50f4ef490ccdb (patch) | |
tree | 5a60f7589bb36be75f7bd1624925ef3f281bd927 /source/blender/blenkernel/intern/asset_catalog_path.cc | |
parent | 4389067929d9a57923b7a85ec29b8ca9633fef29 (diff) |
Asset Catalogs: create missing parent catalogs
For every known catalog, ensure its parent catalog also exists. This
ensures that assets can be assigned to parent catalogs, even when they
didn't exist in the Catalog Definition File yet.
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog_path.cc')
-rw-r--r-- | source/blender/blenkernel/intern/asset_catalog_path.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog_path.cc b/source/blender/blenkernel/intern/asset_catalog_path.cc index d8af7be4a02..cc6aceef8e7 100644 --- a/source/blender/blenkernel/intern/asset_catalog_path.cc +++ b/source/blender/blenkernel/intern/asset_catalog_path.cc @@ -172,6 +172,18 @@ bool AssetCatalogPath::is_contained_in(const AssetCatalogPath &other_path) const return prefix_ok && next_char == SEPARATOR; } +AssetCatalogPath AssetCatalogPath::parent() const +{ + if (!*this) { + return AssetCatalogPath(""); + } + std::string::size_type last_sep_index = this->path_.rfind(SEPARATOR); + if (last_sep_index == std::string::npos) { + return AssetCatalogPath(""); + } + return AssetCatalogPath(this->path_.substr(0, last_sep_index)); +} + void AssetCatalogPath::iterate_components(ComponentIteratorFn callback) const { const char *next_slash_ptr; |