[Bf-blender-cvs] [a1e7fb79871] temp-asset-browser-catalogs-ui: Remove .orig file from merge conflict
Julian Eisel
noreply at git.blender.org
Thu Sep 23 17:23:50 CEST 2021
Commit: a1e7fb798718dccb3aa058de5bde9e8d0558ab4d
Author: Julian Eisel
Date: Thu Sep 23 17:23:30 2021 +0200
Branches: temp-asset-browser-catalogs-ui
https://developer.blender.org/rBa1e7fb798718dccb3aa058de5bde9e8d0558ab4d
Remove .orig file from merge conflict
===================================================================
D source/blender/blenkernel/intern/asset_catalog.cc.orig
===================================================================
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc.orig b/source/blender/blenkernel/intern/asset_catalog.cc.orig
deleted file mode 100644
index 6669c6746bc..00000000000
--- a/source/blender/blenkernel/intern/asset_catalog.cc.orig
+++ /dev/null
@@ -1,919 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup bke
- */
-
-#include "BKE_asset_catalog.hh"
-
-#include "BLI_fileops.h"
-#include "BLI_path_util.h"
-#include "BLI_string_ref.hh"
-
-<<<<<<< HEAD
-=======
-/* For S_ISREG() and S_ISDIR() on Windows. */
-#ifdef WIN32
-# include "BLI_winstuff.h"
-#endif
-
->>>>>>> master
-#include <fstream>
-
-namespace blender::bke {
-
-const char AssetCatalogService::PATH_SEPARATOR = '/';
-const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt";
-
-AssetCatalogService::AssetCatalogService(const CatalogFilePath &asset_library_root)
- : asset_library_root_(asset_library_root)
-{
-}
-
-bool AssetCatalogService::is_empty() const
-{
- return catalogs_.is_empty();
-}
-
-AssetCatalog *AssetCatalogService::find_catalog(CatalogID catalog_id)
-{
- std::unique_ptr<AssetCatalog> *catalog_uptr_ptr = this->catalogs_.lookup_ptr(catalog_id);
- if (catalog_uptr_ptr == nullptr) {
- return nullptr;
- }
- return catalog_uptr_ptr->get();
-}
-
-<<<<<<< HEAD
-AssetCatalog *AssetCatalogService::find_catalog_from_path(const CatalogPath &path) const
-{
- for (auto &catalog : catalogs_.values()) {
- if (catalog->path == path) {
- return catalog.get();
- }
- }
-
- return nullptr;
-}
-
-=======
->>>>>>> master
-void AssetCatalogService::delete_catalog(CatalogID catalog_id)
-{
- std::unique_ptr<AssetCatalog> *catalog_uptr_ptr = this->catalogs_.lookup_ptr(catalog_id);
- if (catalog_uptr_ptr == nullptr) {
- /* Catalog cannot be found, which is fine. */
- return;
- }
-
- /* Mark the catalog as deleted. */
- AssetCatalog *catalog = catalog_uptr_ptr->get();
- catalog->flags.is_deleted = true;
-
- /* Move ownership from this->catalogs_ to this->deleted_catalogs_. */
- this->deleted_catalogs_.add(catalog_id, std::move(*catalog_uptr_ptr));
-
- /* The catalog can now be removed from the map without freeing the actual AssetCatalog. */
- this->catalogs_.remove(catalog_id);
-
- this->rebuild_tree();
-}
-
-AssetCatalog *AssetCatalogService::create_catalog(const CatalogPath &catalog_path)
-{
- std::unique_ptr<AssetCatalog> catalog = AssetCatalog::from_path(catalog_path);
-
- /* So we can std::move(catalog) and still use the non-owning pointer: */
- AssetCatalog *const catalog_ptr = catalog.get();
-
-<<<<<<< HEAD
- BLI_assert_msg(find_catalog_from_path(catalog_path) == nullptr,
- "duplicate catalog path not supported");
-=======
->>>>>>> master
- /* TODO(@sybren): move the `AssetCatalog::from_path()` function to another place, that can reuse
- * catalogs when a catalog with the given path is already known, and avoid duplicate catalog IDs.
- */
- BLI_assert_msg(!catalogs_.contains(catalog->catalog_id), "duplicate catalog ID not supported");
- catalogs_.add_new(catalog->catalog_id, std::move(catalog));
-
-<<<<<<< HEAD
- /* Ensure the new catalog gets written to disk. */
- this->ensure_asset_library_root();
- this->ensure_catalog_definition_file();
- catalog_definition_file_->add_new(catalog_ptr);
- catalog_definition_file_->write_to_disk();
-
- /* Null when the service only writes, but didn't load anything
- * (#AssetCatalogService::load_from_disk() not called). */
- if (catalog_tree_) {
- catalog_tree_->insert_item(*catalog_ptr);
-=======
- if (catalog_definition_file_) {
- /* Ensure the new catalog gets written to disk at some point. If there is no CDF in memory yet,
- * it's enough to have the catalog known to the service as it'll be saved to a new file. */
- catalog_definition_file_->add_new(catalog_ptr);
->>>>>>> master
- }
-
- return catalog_ptr;
-}
-
-static std::string asset_definition_default_file_path_from_dir(StringRef asset_library_root)
-{
- char file_path[PATH_MAX];
- BLI_join_dirfile(file_path,
- sizeof(file_path),
- asset_library_root.data(),
- AssetCatalogService::DEFAULT_CATALOG_FILENAME.data());
- return file_path;
-}
-
-<<<<<<< HEAD
-void AssetCatalogService::ensure_catalog_definition_file()
-{
- if (catalog_definition_file_) {
- return;
- }
-
- auto cdf = std::make_unique<AssetCatalogDefinitionFile>();
- cdf->file_path = asset_definition_default_file_path_from_dir(asset_library_root_);
- catalog_definition_file_ = std::move(cdf);
-}
-
-bool AssetCatalogService::ensure_asset_library_root()
-{
- /* TODO(@sybren): design a way to get such errors presented to users (or ensure that they never
- * occur). */
- if (asset_library_root_.empty()) {
- std::cerr
- << "AssetCatalogService: no asset library root configured, unable to ensure it exists."
- << std::endl;
- return false;
- }
-
- if (BLI_exists(asset_library_root_.data())) {
- if (!BLI_is_dir(asset_library_root_.data())) {
- std::cerr << "AssetCatalogService: " << asset_library_root_
- << " exists but is not a directory, this is not a supported situation."
- << std::endl;
- return false;
- }
-
- /* Root directory exists, work is done. */
- return true;
- }
-
- /* Ensure the root directory exists. */
- std::error_code err_code;
- if (!BLI_dir_create_recursive(asset_library_root_.data())) {
- std::cerr << "AssetCatalogService: error creating directory " << asset_library_root_ << ": "
- << err_code << std::endl;
- return false;
- }
-
- /* Root directory has been created, work is done. */
- return true;
-}
-
-=======
->>>>>>> master
-void AssetCatalogService::load_from_disk()
-{
- load_from_disk(asset_library_root_);
-}
-
-void AssetCatalogService::load_from_disk(const CatalogFilePath &file_or_directory_path)
-{
- BLI_stat_t status;
- if (BLI_stat(file_or_directory_path.data(), &status) == -1) {
- // TODO(@sybren): throw an appropriate exception.
- return;
- }
-
- if (S_ISREG(status.st_mode)) {
- load_single_file(file_or_directory_path);
- }
- else if (S_ISDIR(status.st_mode)) {
- load_directory_recursive(file_or_directory_path);
- }
- else {
- // TODO(@sybren): throw an appropriate exception.
- }
-
- /* TODO: Should there be a sanitize step? E.g. to remove catalogs with identical paths? */
-
- catalog_tree_ = read_into_tree();
-}
-
-void AssetCatalogService::load_directory_recursive(const CatalogFilePath &directory_path)
-{
- // TODO(@sybren): implement proper multi-file support. For now, just load
- // the default file if it is there.
- CatalogFilePath file_path = asset_definition_default_file_path_from_dir(directory_path);
-
- if (!BLI_exists(file_path.data())) {
- /* No file to be loaded is perfectly fine. */
- return;
- }
-
- this->load_single_file(file_path);
-}
-
-void AssetCatalogService::load_single_file(const CatalogFilePath &catalog_definition_file_path)
-{
- /* TODO(@sybren): check that #catalog_definition_file_path is contained in #asset_library_root_,
- * otherwise some assumptions may fail. */
- std::unique_ptr<AssetCatalogDefinitionFile> cdf = parse_catalog_file(
- catalog_definition_file_path);
-
- BLI_assert_msg(!this->catalog_definition_file_,
- "Only loading of a single catalog definition file is supported.");
- this->catalog_definition_file_ = std::move(cdf);
-}
-
-std::unique_ptr<AssetCatalogDefinitionFile> AssetCatalogService::parse_catalog_file(
- const CatalogFilePath &catalog_definition_file_path)
-{
- auto cdf = std::make_unique<AssetCatalogDefinitionFile>();
- cdf->file_path = catalog_definition_file_path;
-
- auto catalog_parsed_callback = [this, catalog_definition_file_path](
- std::unique_ptr<AssetCatalog> catalog) {
- if (this->catalogs_.contains(catalog->catalog_id)) {
- // TODO(@sybren): apparently another CDF was already loaded. This is not supported yet.
- std::cerr << catalog_definition_file_path << ": multiple definitions of catalog "
- << catalog->catalog_id << " in multiple files, ignoring this one." << std::endl;
- /* Don't store 'catalog'; unique_ptr will free its memory. */
- return false;
- }
-
- /* The AssetCatalog pointer is now owned by the AssetCatalogService. */
- this->catalogs_.add_new(catalog->catalog_id, std::move(catalog));
- return true;
- };
-
- cdf->parse_catalog_file(cdf->file_path, catalog_parsed_callback);
-
- return cdf;
-}
-
-void AssetCatalogService::merge_from_disk_before_writing()
-{
- /* TODO(Sybren): expand to support multiple CDFs. */
-
-<<<<<<< HEAD
- auto catalog_parsed_callback = [this](std::unique_ptr<AssetCatalog> catalog) {
- const UUID catalog_id = catalog->catalog_id;
-=======
- if (!catalog_definition_file_ || catalog_definition_file_->file_path.empty() ||
- !BLI_is_file(catalog_definition_file_->file_path.c_str())) {
- return;
- }
-
- auto catalog_parsed_callback = [this](std::unique_ptr<AssetCatalog> catalog) {
- const bUUID catalog_id = catalog->catalog_id;
->>>>>>> master
-
- /* The following two conditions could be or'ed together. Keeping them separated helps when
- * adding debug prints, breakpoints, etc. */
- if (this->catalogs_.contains(catalog_id)) {
- /* This catalog was already seen, so just ignore it. */
- return false;
- }
- if (this-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list