Changeset View
Changeset View
Standalone View
Standalone View
source/blender/asset_system/intern/asset_catalog.cc
- This file was moved from source/blender/blenkernel/intern/asset_catalog.cc.
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup bke | * \ingroup asset_system | ||||
| */ | */ | ||||
| #include <fstream> | #include <fstream> | ||||
| #include <set> | #include <set> | ||||
| #include "BKE_asset_catalog.hh" | #include "AS_asset_catalog.hh" | ||||
| #include "BKE_asset_library.h" | #include "AS_asset_library.h" | ||||
| #include "BKE_asset_library.hh" | #include "AS_asset_library.hh" | ||||
| #include "BLI_fileops.hh" | #include "BLI_fileops.hh" | ||||
| #include "BLI_path_util.h" | #include "BLI_path_util.h" | ||||
| /* For S_ISREG() and S_ISDIR() on Windows. */ | /* For S_ISREG() and S_ISDIR() on Windows. */ | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| # include "BLI_winstuff.h" | # include "BLI_winstuff.h" | ||||
| #endif | #endif | ||||
| #include "CLG_log.h" | #include "CLG_log.h" | ||||
| static CLG_LogRef LOG = {"bke.asset_service"}; | static CLG_LogRef LOG = {"asset_system.asset_catalog_service"}; | ||||
| namespace blender::bke { | namespace blender::asset_system { | ||||
| const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt"; | const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt"; | ||||
| const int AssetCatalogDefinitionFile::SUPPORTED_VERSION = 1; | const int AssetCatalogDefinitionFile::SUPPORTED_VERSION = 1; | ||||
| const std::string AssetCatalogDefinitionFile::VERSION_MARKER = "VERSION "; | const std::string AssetCatalogDefinitionFile::VERSION_MARKER = "VERSION "; | ||||
| const std::string AssetCatalogDefinitionFile::HEADER = | const std::string AssetCatalogDefinitionFile::HEADER = | ||||
| "# This is an Asset Catalog Definition file for Blender.\n" | "# This is an Asset Catalog Definition file for Blender.\n" | ||||
| ▲ Show 20 Lines • Show All 468 Lines • ▼ Show 20 Lines | |||||
| CatalogFilePath AssetCatalogService::find_suitable_cdf_path_for_writing( | CatalogFilePath AssetCatalogService::find_suitable_cdf_path_for_writing( | ||||
| const CatalogFilePath &blend_file_path) | const CatalogFilePath &blend_file_path) | ||||
| { | { | ||||
| BLI_assert_msg(!blend_file_path.empty(), | BLI_assert_msg(!blend_file_path.empty(), | ||||
| "A non-empty .blend file path is required to be able to determine where the " | "A non-empty .blend file path is required to be able to determine where the " | ||||
| "catalog definition file should be put"); | "catalog definition file should be put"); | ||||
| /* Ask the asset library API for an appropriate location. */ | /* Ask the asset library API for an appropriate location. */ | ||||
| const std::string suitable_root_path = BKE_asset_library_find_suitable_root_path_from_path( | const std::string suitable_root_path = AS_asset_library_find_suitable_root_path_from_path( | ||||
| blend_file_path); | blend_file_path); | ||||
| if (!suitable_root_path.empty()) { | if (!suitable_root_path.empty()) { | ||||
| char asset_lib_cdf_path[PATH_MAX]; | char asset_lib_cdf_path[PATH_MAX]; | ||||
| BLI_path_join(asset_lib_cdf_path, | BLI_path_join(asset_lib_cdf_path, | ||||
| sizeof(asset_lib_cdf_path), | sizeof(asset_lib_cdf_path), | ||||
| suitable_root_path.c_str(), | suitable_root_path.c_str(), | ||||
| DEFAULT_CATALOG_FILENAME.c_str()); | DEFAULT_CATALOG_FILENAME.c_str()); | ||||
| return asset_lib_cdf_path; | return asset_lib_cdf_path; | ||||
| ▲ Show 20 Lines • Show All 607 Lines • ▼ Show 20 Lines | |||||
| bool AssetCatalogFilter::is_known(const CatalogID asset_catalog_id) const | bool AssetCatalogFilter::is_known(const CatalogID asset_catalog_id) const | ||||
| { | { | ||||
| if (BLI_uuid_is_nil(asset_catalog_id)) { | if (BLI_uuid_is_nil(asset_catalog_id)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return known_catalog_ids.contains(asset_catalog_id); | return known_catalog_ids.contains(asset_catalog_id); | ||||
| } | } | ||||
| } // namespace blender::bke | } // namespace blender::asset_system | ||||