Blender V5.0
preferences_on_disk_library.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_fileops.h"
10#include "BLI_listbase.h"
11#include "BLI_path_utils.hh"
12
13#include "DNA_userdef_types.h"
14
16
17namespace blender::asset_system {
18
23
24std::optional<AssetLibraryReference> PreferencesOnDiskAssetLibrary::library_reference() const
25{
26 int i;
27 LISTBASE_FOREACH_INDEX (const bUserAssetLibrary *, asset_library, &U.asset_libraries, i) {
28 if (!BLI_is_dir(asset_library->dirpath)) {
29 continue;
30 }
31
32 if (BLI_path_cmp_normalized(asset_library->dirpath, this->root_path().c_str()) == 0) {
33 AssetLibraryReference library_ref{};
34 library_ref.type = ASSET_LIBRARY_CUSTOM;
35 library_ref.custom_library_index = i;
36 return library_ref;
37 }
38 }
39
40 return {};
41}
42
43} // namespace blender::asset_system
File and directory operations.
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:443
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
@ ASSET_LIBRARY_CUSTOM
#define U
OnDiskAssetLibrary(eAssetLibraryType library_type, StringRef name="", StringRef root_path="")
PreferencesOnDiskAssetLibrary(StringRef name="", StringRef root_path="")
std::optional< AssetLibraryReference > library_reference() const override
i
Definition text_draw.cc:230