Blender V5.3
asset_system/intern/asset_catalog.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <iostream>
10#include <set>
11
12#include "AS_asset_catalog.hh"
14#include "AS_asset_library.hh"
18
19#include "BLI_fileops.hh"
20#include "BLI_path_utils.hh"
21
22/* For S_ISREG() and S_ISDIR() on Windows. */
23#ifdef WIN32
24# include "BLI_winstuff.hh"
25#endif
26
28
29#include "CLG_log.h"
30
31namespace blender {
32
33static CLG_LogRef LOG = {"asset.catalog"};
34
35namespace asset_system {
36
38
40 std::optional<read_only_tag> read_only_tag)
41 : catalog_collection_(std::make_unique<AssetCatalogCollection>()),
42 asset_library_root_(asset_library_root),
43 is_read_only_(read_only_tag ? true : false)
44{
45}
46
48{
49 const_cast<bool &>(is_read_only_) = true;
50}
51
53
55{
56 BLI_assert(!is_read_only_);
57
58 if (edited_catalog) {
59 edited_catalog->flags.has_unsaved_changes = true;
60 }
61 BLI_assert(catalog_collection_);
62 catalog_collection_->has_unsaved_changes_ = true;
63}
64
66{
67 BLI_assert(catalog_collection_);
68 catalog_collection_->has_unsaved_changes_ = false;
69
70 /* TODO(Sybren): refactor; this is more like "post-write cleanup" than "remove a tag" code. */
71
72 /* Forget about any deleted catalogs. */
73 if (catalog_collection_->catalog_definition_file_) {
74 for (CatalogID catalog_id : catalog_collection_->deleted_catalogs_.keys()) {
75 catalog_collection_->catalog_definition_file_->forget(catalog_id);
76 }
77 }
78 catalog_collection_->deleted_catalogs_.clear();
79
80 /* Mark all remaining catalogs as "without unsaved changes". */
81 for (auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
82 catalog_uptr->flags.has_unsaved_changes = false;
83 }
84}
85
87{
88 BLI_assert(catalog_collection_);
89 return catalog_collection_->has_unsaved_changes_;
90}
91
93{
94 return is_read_only_;
95}
96
98{
99 for (auto &catalog : catalog_collection_->catalogs_.values()) {
100 catalog->flags.has_unsaved_changes = true;
101 }
102 catalog_collection_->has_unsaved_changes_ = true;
103}
104
106{
107 BLI_assert(catalog_collection_);
108 return catalog_collection_->catalogs_.is_empty();
109}
110
112{
113 return catalog_collection_->catalogs_;
114}
116{
117 return catalog_collection_->deleted_catalogs_;
118}
119
121{
122 return catalog_collection_->catalog_definition_file_.get();
123}
124
126{
127 const std::unique_ptr<AssetCatalog> *catalog_uptr_ptr =
128 catalog_collection_->catalogs_.lookup_ptr(catalog_id);
129 if (catalog_uptr_ptr == nullptr) {
130 return nullptr;
131 }
132 return catalog_uptr_ptr->get();
133}
134
136{
137 /* Use an AssetCatalogOrderedSet to find the 'best' catalog for this path. This will be the first
138 * one loaded from disk, or if that does not exist the one with the lowest UUID. This ensures
139 * stable, predictable results. */
140 MutableAssetCatalogOrderedSet ordered_catalogs;
141
142 for (const auto &catalog : catalog_collection_->catalogs_.values()) {
143 if (catalog->path == path) {
144 ordered_catalogs.insert(catalog.get());
145 }
146 }
147
148 if (ordered_catalogs.empty()) {
149 return nullptr;
150 }
151
152 MutableAssetCatalogOrderedSet::iterator best_choice_it = ordered_catalogs.begin();
153 return *best_choice_it;
154}
155
157{
158 BLI_assert(catalog_collection_);
159 return catalog_collection_->catalogs_.contains(catalog_id);
160}
161
163 const CatalogID active_catalog_id) const
164{
165 Set<CatalogID> matching_catalog_ids;
166 Set<CatalogID> known_catalog_ids;
167 matching_catalog_ids.add(active_catalog_id);
168
169 const AssetCatalog *active_catalog = this->find_catalog(active_catalog_id);
170
171 /* This cannot just iterate over tree items to get all the required data, because tree items only
172 * represent single UUIDs. It could be used to get the main UUIDs of the children, though, and
173 * then only do an exact match on the path (instead of the more complex `is_contained_in()`
174 * call). Without an extra indexed-by-path acceleration structure, this is still going to require
175 * a linear search, though. */
176 for (const auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
177 if (active_catalog && catalog_uptr->path.is_contained_in(active_catalog->path)) {
178 matching_catalog_ids.add(catalog_uptr->catalog_id);
179 }
180 known_catalog_ids.add(catalog_uptr->catalog_id);
181 }
182
183 return AssetCatalogFilter(std::move(matching_catalog_ids), std::move(known_catalog_ids));
184}
185
187{
188 std::unique_ptr<AssetCatalog> *catalog_uptr_ptr = catalog_collection_->catalogs_.lookup_ptr(
189 catalog_id);
190 if (catalog_uptr_ptr == nullptr) {
191 /* Catalog cannot be found, which is fine. */
192 return;
193 }
194
195 /* Mark the catalog as deleted. */
196 AssetCatalog *catalog = catalog_uptr_ptr->get();
197 catalog->flags.is_deleted = true;
198
199 /* Move ownership from catalog_collection_->catalogs_ to catalog_collection_->deleted_catalogs_.
200 */
201 catalog_collection_->deleted_catalogs_.add(catalog_id, std::move(*catalog_uptr_ptr));
202
203 /* The catalog can now be removed from the map without freeing the actual AssetCatalog. */
204 catalog_collection_->catalogs_.remove(catalog_id);
205}
206
208{
209 catalog_collection_->catalogs_.remove(catalog_id);
210 catalog_collection_->deleted_catalogs_.remove(catalog_id);
211
212 /* TODO(@sybren): adjust this when supporting multiple CDFs. */
213 catalog_collection_->catalog_definition_file_->forget(catalog_id);
214}
215
217{
218 /* Build a collection of catalog IDs to delete. */
219 Set<CatalogID> catalogs_to_delete;
220 for (const auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
221 const AssetCatalog *cat = catalog_uptr.get();
222 if (cat->path.is_contained_in(path)) {
223 catalogs_to_delete.add(cat->catalog_id);
224 }
225 }
226
227 /* Delete the catalogs. */
228 for (const CatalogID cat_id : catalogs_to_delete) {
229 this->delete_catalog_by_id_soft(cat_id);
230 }
231
234}
235
237{
238 const AssetCatalog *catalog = find_catalog(catalog_id);
239 BLI_assert_msg(catalog, "trying to prune asset catalogs by the path of a non-existent catalog");
240 if (!catalog) {
241 return;
242 }
243 this->prune_catalogs_by_path(catalog->path);
244}
245
247 const AssetCatalogPath &new_catalog_path)
248{
249 AssetCatalog *renamed_cat = this->find_catalog(catalog_id);
250 const AssetCatalogPath old_cat_path = renamed_cat->path;
251
252 for (auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
253 AssetCatalog *cat = catalog_uptr.get();
254
255 const AssetCatalogPath new_path = cat->path.rebase(old_cat_path, new_catalog_path);
256 if (!new_path) {
257 continue;
258 }
259 cat->path = new_path;
260 cat->simple_name_refresh();
261 this->tag_has_unsaved_changes(cat);
262
263 /* TODO(Sybren): go over all assets that are assigned to this catalog, defined in the current
264 * blend file, and update the catalog simple name stored there. */
265 }
266
270}
271
273{
274 std::unique_ptr<AssetCatalog> catalog = AssetCatalog::from_path(catalog_path);
275 catalog->flags.has_unsaved_changes = true;
276
277 /* So we can std::move(catalog) and still use the non-owning pointer: */
278 AssetCatalog *const catalog_ptr = catalog.get();
279
280 /* TODO(@sybren): move the `AssetCatalog::from_path()` function to another place, that can reuse
281 * catalogs when a catalog with the given path is already known, and avoid duplicate catalog IDs.
282 */
283 BLI_assert_msg(!catalog_collection_->catalogs_.contains(catalog->catalog_id),
284 "duplicate catalog ID not supported");
285 catalog_collection_->catalogs_.add_new(catalog->catalog_id, std::move(catalog));
286
287 if (catalog_collection_->catalog_definition_file_) {
288 /* Ensure the new catalog gets written to disk at some point. If there is no CDF in memory yet,
289 * it's enough to have the catalog known to the service as it'll be saved to a new file. */
290 catalog_collection_->catalog_definition_file_->add_new(catalog_ptr);
291 }
292
295
296 return catalog_ptr;
297}
298
299static std::string asset_definition_default_file_path_from_dir(StringRef asset_library_root)
300{
301 char file_path[PATH_MAX];
302 BLI_path_join(file_path,
303 sizeof(file_path),
304 asset_library_root.data(),
306 return file_path;
307}
308
310{
311 this->load_from_disk(asset_library_root_);
312}
313
314void AssetCatalogService::load_from_disk(const CatalogFilePath &file_or_directory_path)
315{
316 BLI_stat_t status;
317 if (BLI_stat(file_or_directory_path.data(), &status) == -1) {
318 /* It's fine if the catalogs file doesn't exist, it just means there are no catalogs. */
319 CLOG_DEBUG(&LOG, "path not found: %s", file_or_directory_path.data());
320 return;
321 }
322
323 if (S_ISREG(status.st_mode)) {
324 this->load_single_file(file_or_directory_path);
325 }
326 else if (S_ISDIR(status.st_mode)) {
327 this->load_directory_recursive(file_or_directory_path);
328 }
329 else {
330 /* TODO(@sybren): throw an appropriate exception. */
331 }
332
333 /* TODO: Should there be a sanitize step? E.g. to remove catalogs with identical paths? */
334
337}
338
340 const AssetCatalogService &other_service,
342{
343 catalog_collection_->add_catalogs_from_existing(*other_service.catalog_collection_,
344 on_duplicate_items);
345}
346
348{
349 /* TODO(@sybren): implement proper multi-file support. For now, just load
350 * the default file if it is there. */
352
353 if (!BLI_exists(file_path.data())) {
354 /* No file to be loaded is perfectly fine. */
355 CLOG_DEBUG(&LOG, "path not found: %s", file_path.data());
356 return;
357 }
358
359 this->load_single_file(file_path);
360}
361
362void AssetCatalogService::load_single_file(const CatalogFilePath &catalog_definition_file_path)
363{
364 /* TODO(@sybren): check that #catalog_definition_file_path is contained in #asset_library_root_,
365 * otherwise some assumptions may fail. */
366 std::unique_ptr<AssetCatalogDefinitionFile> cdf = parse_catalog_file(
367 catalog_definition_file_path);
368
369 BLI_assert_msg(!catalog_collection_->catalog_definition_file_,
370 "Only loading of a single catalog definition file is supported.");
371 catalog_collection_->catalog_definition_file_ = std::move(cdf);
372}
373
374std::unique_ptr<AssetCatalogDefinitionFile> AssetCatalogService::parse_catalog_file(
375 const CatalogFilePath &catalog_definition_file_path)
376{
377 auto cdf = std::make_unique<AssetCatalogDefinitionFile>(catalog_definition_file_path);
378
379 /* TODO(Sybren): this might have to move to a higher level when supporting multiple CDFs. */
380 Set<AssetCatalogPath> seen_paths;
381
382 auto catalog_parsed_callback = [this, catalog_definition_file_path, &seen_paths](
383 std::unique_ptr<AssetCatalog> catalog) {
384 if (skip_experimental_asset_catalog(catalog->catalog_id)) {
385 return false;
386 }
387
388 if (catalog_collection_->catalogs_.contains(catalog->catalog_id)) {
389 /* TODO(@sybren): apparently another CDF was already loaded. This is not supported yet. */
390 std::cerr << catalog_definition_file_path << ": multiple definitions of catalog "
391 << catalog->catalog_id << " in multiple files, ignoring this one." << std::endl;
392 /* Don't store 'catalog'; unique_ptr will free its memory. */
393 return false;
394 }
395
396 catalog->flags.is_first_loaded = seen_paths.add(catalog->path);
397
398 /* The AssetCatalog pointer is now owned by the AssetCatalogService. */
399 catalog_collection_->catalogs_.add_new(catalog->catalog_id, std::move(catalog));
400 return true;
401 };
402
403 cdf->parse_catalog_file(cdf->file_path, catalog_parsed_callback);
404
405 return cdf;
406}
407
409{
410 /* TODO(Sybren): expand to support multiple CDFs. */
411 AssetCatalogDefinitionFile *const cdf = catalog_collection_->catalog_definition_file_.get();
412 if (!cdf || cdf->file_path.empty() || !BLI_is_file(cdf->file_path.c_str())) {
413 return;
414 }
415
416 /* Keeps track of the catalog IDs that are seen in the CDF, so that we also know what was deleted
417 * from the file on disk. */
418 Set<CatalogID> cats_in_file;
419
420 auto catalog_parsed_callback = [this, &cats_in_file](std::unique_ptr<AssetCatalog> catalog) {
421 if (skip_experimental_asset_catalog(catalog->catalog_id)) {
422 return false;
423 }
424
425 const CatalogID catalog_id = catalog->catalog_id;
426 cats_in_file.add(catalog_id);
427
428 const bool should_skip = this->is_catalog_known_with_unsaved_changes(catalog_id);
429 if (should_skip) {
430 /* Do not overwrite unsaved local changes. */
431 return false;
432 }
433
434 /* This is either a new catalog, or we can just replace the in-memory one with the newly loaded
435 * one. */
436 catalog_collection_->catalogs_.add_overwrite(catalog_id, std::move(catalog));
437 return true;
438 };
439
440 cdf->parse_catalog_file(cdf->file_path, catalog_parsed_callback);
441 this->purge_catalogs_not_listed(cats_in_file);
444}
445
447{
448 Set<CatalogID> cats_to_remove;
449 for (CatalogID cat_id : this->catalog_collection_->catalogs_.keys()) {
450 if (catalogs_to_keep.contains(cat_id)) {
451 continue;
452 }
453 if (this->is_catalog_known_with_unsaved_changes(cat_id)) {
454 continue;
455 }
456 /* This catalog is not on disk, but also not modified, so get rid of it. */
457 cats_to_remove.add(cat_id);
458 }
459
460 for (CatalogID cat_id : cats_to_remove) {
461 this->delete_catalog_by_id_hard(cat_id);
462 }
463}
464
466{
467 if (catalog_collection_->deleted_catalogs_.contains(catalog_id)) {
468 /* Deleted catalogs are always considered modified, by definition. */
469 return true;
470 }
471
472 const std::unique_ptr<AssetCatalog> *catalog_uptr_ptr =
473 catalog_collection_->catalogs_.lookup_ptr(catalog_id);
474 if (!catalog_uptr_ptr) {
475 /* Catalog is unknown. */
476 return false;
477 }
478
479 const bool has_unsaved_changes = (*catalog_uptr_ptr)->flags.has_unsaved_changes;
480 return has_unsaved_changes;
481}
482
484{
485 /* The caller should probably check this somewhat earlier and properly disable whatever operation
486 * triggers the writing. */
487 BLI_assert(!is_read_only_);
488 if (is_read_only_) {
489 return false;
490 }
491
492 if (!this->write_to_disk_ex(blend_file_path)) {
493 return false;
494 }
495
498 return true;
499}
500
502{
503 /* TODO(Sybren): expand to support multiple CDFs. */
504
505 /* - Already loaded a CDF from disk? -> Only write to that file when there were actual changes.
506 * This prevents touching the file, which can cause issues when multiple Blender instances are
507 * accessing the same file (like on shared storage, Sync-thing, etc.). See #111576.
508 */
509 if (catalog_collection_->catalog_definition_file_) {
510 /* Always sync with what's on disk. */
511 this->reload_catalogs();
512
513 if (!this->has_unsaved_changes() &&
514 catalog_collection_->catalog_definition_file_->exists_on_disk())
515 {
516 return true;
517 }
518 return catalog_collection_->catalog_definition_file_->write_to_disk();
519 }
520
521 if (catalog_collection_->is_empty()) {
522 /* Avoid saving anything, when there is nothing to save. */
523 return true; /* Writing nothing when there is nothing to write is still a success. */
524 }
525
526 const CatalogFilePath cdf_path_to_write = find_suitable_cdf_path_for_writing(blend_file_path);
527 catalog_collection_->catalog_definition_file_ = construct_cdf_in_memory(cdf_path_to_write);
528 this->reload_catalogs();
529 return catalog_collection_->catalog_definition_file_->write_to_disk();
530}
531
533{
534 /* TODO(Sybren): expand to support multiple CDFs. */
535
536 if (!catalog_collection_->catalog_definition_file_) {
537 /* There is no CDF connected, so it's a no-op. */
538 return;
539 }
540
541 /* Remove any association with the CDF, so that a new location will be chosen
542 * when the blend file is saved. */
543 catalog_collection_->catalog_definition_file_.reset();
544
545 /* Mark all in-memory catalogs as "dirty", to force them to be kept around on
546 * the next "load-merge-write" cycle. */
548}
549
551 const CatalogFilePath &blend_file_path)
552{
553 BLI_assert_msg(!blend_file_path.empty(),
554 "A non-empty .blend file path is required to be able to determine where the "
555 "catalog definition file should be put");
556
557 /* Ask the asset library API for an appropriate location. */
558 const std::string suitable_root_path = AS_asset_library_find_suitable_root_path_from_path(
559 blend_file_path);
560 if (!suitable_root_path.empty()) {
561 char asset_lib_cdf_path[PATH_MAX];
562 BLI_path_join(asset_lib_cdf_path,
563 sizeof(asset_lib_cdf_path),
564 suitable_root_path.c_str(),
566 return asset_lib_cdf_path;
567 }
568
569 /* Determine the default CDF path in the same directory of the blend file. */
570 char blend_dir_path[PATH_MAX];
571 BLI_path_split_dir_part(blend_file_path.c_str(), blend_dir_path, sizeof(blend_dir_path));
573 blend_dir_path);
574 return cdf_path_next_to_blend;
575}
576
577std::unique_ptr<AssetCatalogDefinitionFile> AssetCatalogService::construct_cdf_in_memory(
578 const CatalogFilePath &file_path) const
579{
580 auto cdf = std::make_unique<AssetCatalogDefinitionFile>(file_path);
581
582 for (auto &catalog : catalog_collection_->catalogs_.values()) {
583 cdf->add_new(catalog.get());
584 }
585
586 return cdf;
587}
588
589std::unique_ptr<AssetCatalogTree> AssetCatalogService::read_into_tree() const
590{
591 auto tree = std::make_unique<AssetCatalogTree>();
592
593 /* Go through the catalogs, insert each path component into the tree where needed. */
594 for (auto &catalog : catalog_collection_->catalogs_.values()) {
595 tree->insert_item(*catalog);
596 }
597
598 return tree;
599}
600
602{
603 std::lock_guard lock{catalog_tree_mutex_};
604 this->catalog_tree_ = nullptr;
605}
606
607std::shared_ptr<const AssetCatalogTree> AssetCatalogService::catalog_tree()
608{
609 std::lock_guard lock{catalog_tree_mutex_};
610 if (!catalog_tree_) {
611 /* Ensure all catalog paths lead to valid catalogs. This is important for the catalog tree to
612 * be usable, e.g. it makes sure every item in the tree maps to an actual catalog. */
614
615 catalog_tree_ = read_into_tree();
616 }
617 return catalog_tree_;
618}
619
621{
622 /* Construct an ordered set of paths to check, so that parents are ordered before children. */
623 std::set<AssetCatalogPath> paths_to_check;
624 for (auto &catalog : catalog_collection_->catalogs_.values()) {
625 paths_to_check.insert(catalog->path);
626 }
627
628 std::set<AssetCatalogPath> seen_paths;
629 /* The empty parent should never be created, so always be considered "seen". */
630 seen_paths.insert(AssetCatalogPath(""));
631
632 /* Find and create missing direct parents (so ignoring parents-of-parents). */
633 while (!paths_to_check.empty()) {
634 /* Pop the first path of the queue. */
635 const AssetCatalogPath path = *paths_to_check.begin();
636 paths_to_check.erase(paths_to_check.begin());
637
638 if (seen_paths.contains(path)) {
639 /* This path has been seen already, so it can be ignored. */
640 continue;
641 }
642 seen_paths.insert(path);
643
644 const AssetCatalogPath parent_path = path.parent();
645 if (seen_paths.contains(parent_path)) {
646 /* The parent exists, continue to the next path. */
647 continue;
648 }
649
650 /* The parent doesn't exist, so create it and queue it up for checking its parent. */
651 AssetCatalog *parent_catalog = this->create_catalog(parent_path);
652 parent_catalog->flags.has_unsaved_changes = true;
653
654 paths_to_check.insert(parent_path);
655 }
656
657 /* TODO(Sybren): bind the newly created catalogs to a CDF, if we know about it. */
658}
659
661{
662 return !undo_snapshots_.is_empty();
663}
664
666{
667 return !redo_snapshots_.is_empty();
668}
669
671{
672 BLI_assert_msg(is_undo_possbile(), "Undo stack is empty");
673
674 redo_snapshots_.append(std::move(catalog_collection_));
675 catalog_collection_ = undo_snapshots_.pop_last();
679}
680
682{
683 BLI_assert(!is_read_only_);
684 BLI_assert_msg(is_redo_possbile(), "Redo stack is empty");
685
686 undo_snapshots_.append(std::move(catalog_collection_));
687 catalog_collection_ = redo_snapshots_.pop_last();
691}
692
694{
695 BLI_assert(!is_read_only_);
696 std::unique_ptr<AssetCatalogCollection> snapshot = catalog_collection_->deep_copy();
697 undo_snapshots_.append(std::move(snapshot));
698 redo_snapshots_.clear();
699}
700
701/* ---------------------------------------------------------------------- */
702
709
710std::unique_ptr<AssetCatalog> AssetCatalog::from_path(const AssetCatalogPath &path)
711{
712 const AssetCatalogPath clean_path = path.cleanup();
713 const CatalogID cat_id = BLI_uuid_generate_random();
714 const std::string simple_name = sensible_simple_name_for_path(clean_path);
715 auto catalog = std::make_unique<AssetCatalog>(cat_id, clean_path, simple_name);
716 return catalog;
717}
718
723
725{
726 std::string name = path.str();
727 std::replace(name.begin(), name.end(), AssetCatalogPath::SEPARATOR, '-');
728 if (name.length() < MAX_NAME - 1) {
729 return name;
730 }
731
732 /* Trim off the start of the path, as that's the most generic part and thus contains the least
733 * information. */
734 return "..." + name.substr(name.length() - 60);
735}
736
737/* ---------------------------------------------------------------------- */
738
740 Set<CatalogID> &&known_catalog_ids)
741 : matching_catalog_ids_(std::move(matching_catalog_ids)),
742 known_catalog_ids_(std::move(known_catalog_ids))
743{
744}
745
746bool AssetCatalogFilter::contains(const CatalogID asset_catalog_id) const
747{
748 return matching_catalog_ids_.contains(asset_catalog_id);
749}
750
751bool AssetCatalogFilter::is_known(const CatalogID asset_catalog_id) const
752{
753 if (BLI_uuid_is_nil(asset_catalog_id)) {
754 return false;
755 }
756 return known_catalog_ids_.contains(asset_catalog_id);
757}
758
759} // namespace asset_system
760
761} // namespace blender
File and directory operations.
#define PATH_MAX
#define BLI_path_join(...)
Compatibility-like things for windows.
#define S_ISDIR(x)
#define S_ISREG(x)
#define CLOG_DEBUG(clg_ref,...)
Definition CLG_log.h:191
#define MAX_NAME
Definition DNA_defs.h:63
volatile int lock
#define BLI_assert_msg(a, msg)
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
FunctionRef< void(const AssetCatalog &existing, const AssetCatalog &to_be_ignored)> OnDuplicateCatalogIdFn
void parse_catalog_file(const CatalogFilePath &catalog_definition_file_path, AssetCatalogParsedFn catalog_loaded_callback)
AssetCatalogFilter(Set< CatalogID > &&matching_catalog_ids, Set< CatalogID > &&known_catalog_ids)
AssetCatalogPath rebase(const AssetCatalogPath &from_path, const AssetCatalogPath &to_path) const
bool is_contained_in(const AssetCatalogPath &other_path) const
void load_single_file(const CatalogFilePath &catalog_definition_file_path)
AssetCatalogFilter create_catalog_filter(CatalogID active_catalog_id) const
AssetCatalog * find_catalog_by_path(const AssetCatalogPath &path) const
AssetCatalog * find_catalog(CatalogID catalog_id) const
std::shared_ptr< const AssetCatalogTree > catalog_tree()
bool write_to_disk(const CatalogFilePath &blend_file_path)
std::unique_ptr< AssetCatalogTree > read_into_tree() const
void purge_catalogs_not_listed(const Set< CatalogID > &catalogs_to_keep)
std::unique_ptr< AssetCatalogDefinitionFile > parse_catalog_file(const CatalogFilePath &catalog_definition_file_path)
std::unique_ptr< AssetCatalogDefinitionFile > construct_cdf_in_memory(const CatalogFilePath &file_path) const
AssetCatalog * create_catalog(const AssetCatalogPath &catalog_path)
void update_catalog_path(CatalogID catalog_id, const AssetCatalogPath &new_catalog_path)
void add_from_existing(const AssetCatalogService &other_service, FunctionRef< void(const AssetCatalog &existing, const AssetCatalog &to_be_ignored)> on_duplicate_items)
static CatalogFilePath find_suitable_cdf_path_for_writing(const CatalogFilePath &blend_file_path)
bool write_to_disk_ex(const CatalogFilePath &blend_file_path)
void load_directory_recursive(const CatalogFilePath &directory_path)
bool is_catalog_known_with_unsaved_changes(CatalogID catalog_id) const
void tag_has_unsaved_changes(AssetCatalog *edited_catalog=nullptr)
static const CatalogFilePath DEFAULT_CATALOG_FILENAME
AssetCatalogService(const CatalogFilePath &asset_library_root={}, std::optional< read_only_tag > read_only_tag=std::nullopt)
const AssetCatalogDefinitionFile * get_catalog_definition_file() const
static std::unique_ptr< AssetCatalog > from_path(const AssetCatalogPath &path)
static std::string sensible_simple_name_for_path(const AssetCatalogPath &path)
struct blender::asset_system::AssetCatalog::Flags flags
constexpr const char * data() const
bool skip_experimental_asset_catalog(const UUID &catalog_id)
std::set< AssetCatalog *, AssetCatalogLessThan > MutableAssetCatalogOrderedSet
Map< CatalogID, std::unique_ptr< AssetCatalog > > OwningAssetCatalogMap
static std::string asset_definition_default_file_path_from_dir(StringRef asset_library_root)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
std::string AS_asset_library_find_suitable_root_path_from_path(StringRefNull input_path)
bool BLI_uuid_is_nil(bUUID uuid)
Definition uuid.cc:72
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bUUID BLI_uuid_generate_random()
Definition uuid.cc:26
static CLG_LogRef LOG
Definition logging.cpp:12
struct stat BLI_stat_t
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:469