42#define U BLI_STATIC_ASSERT(false, "Global 'U' not allowed, only use arguments passed in!")
48namespace bke::preferences {
53 if (!cfgdir.has_value()) {
94 std::optional<UUID> uuid)
104 MEM_delete(
library->auth_token);
105 MEM_delete(
library->invalid_uuid);
151 return &asset_lib_pref;
169 if (
library->extension_id[0]) {
173 if (repo ==
nullptr) {
185 const bool check_directory_exists)
195 if (is_remote_library && skip_remote_libraries) {
198 if (is_remote_library && !
library->remote_url[0]) {
229 library->dirpath,
sizeof(
library->dirpath), documents_path,
N_(
"Blender"),
N_(
"Assets"));
258 const char *remote_url,
259 const char *auth_token)
272 if (auth_token && auth_token[0]) {
282 const char *remote_url,
283 const char *auth_token)
286 userdef, name, remote_url, auth_token);
296 if (
library->extension_id[0]) {
308 char *sep = strchr(module,
'.');
309 if (sep ==
nullptr) {
326 if (
len > 0 &&
str[
len - 1] !=
'/' &&
len + 1 < str_maxncpy) {
341 if (!ends_in_top_meta_file) {
346 const std::string library_dirpath =
375 const size_t dst_len_max = dst_maxncpy - 1;
377 size_t i_src = 0, i_dst = 0;
378 while (src[i_src] && (i_dst < dst_len_max)) {
379 const char c = src[i_src++];
380 const bool is_alpha = (c >=
'a' && c <=
'z') || (c >=
'A' && c <=
'Z');
382 if (i_dst == 0 && !is_alpha) {
385 const bool is_num = (is_alpha ==
false) && ((c >=
'0' && c <=
'9') || c ==
'_');
386 if (!(is_alpha || is_num)) {
398 const char *custom_dirpath)
417 if (repo == &repo_iter) {
440 userdef,
"extensions.blender.org",
"blender_org",
"");
452 userdef,
"User Default",
"user_default",
"");
476 name =
"User Repository";
510 if (module_len == 0) {
526 const int dirpath_maxncpy)
532 std::optional<std::string> path = std::nullopt;
560 const int dirpath_maxncpy)
565 return BLI_path_join(dirpath, dirpath_maxncpy, path.value().c_str(),
".user", repo->
module);
585 if (ch >= 32 && ch <= 44) {
589 if (ch >= 58 && ch <= 64) {
592 if (
ELEM(ch,
'/',
'\\')) {
599 const UserDef *userdef,
const char *remote_url_full,
const bool only_enabled)
601 const int path_full_len = strlen(remote_url_full);
619 const char *path_test = remote_url_full;
620 int path_test_len = path_full_len;
624 if (path_full_offset) {
626 if (path_repo_offset) {
627 path_repo += path_repo_offset;
628 path_test += path_full_offset;
629 path_test_len -= path_full_offset;
634 int path_repo_len = strlen(path_repo);
635 while (path_repo_len &&
ELEM(path_repo[path_repo_len - 1],
'/',
'\\')) {
639 if (path_test_len <= path_repo_len) {
642 if (memcmp(path_repo, path_test, path_repo_len) != 0) {
685 const char *scheme_check[] = {
690 for (
int i = 0; i <
ARRAY_SIZE(scheme_check); i++) {
691 const char *scheme = scheme_check[i];
692 int scheme_len = strlen(scheme);
693 if (strncmp(url, scheme, scheme_len) == 0) {
694 return scheme_len - 3;
703 const bool is_win32 =
true;
705 const bool is_win32 =
false;
707 const bool is_file =
STRPREFIX(remote_url,
"file://");
711 remote_url += (offset + 3);
717 if (remote_url[0] ==
'/' && isalpha(remote_url[1]) && (remote_url[2] ==
':')) {
729 if (remote_url[0] ==
'\0') [[unlikely]] {
733 const char *c = remote_url;
775 const char *shelf_idname)
785 const char *shelf_idname)
796 const char *shelf_idname)
805 const char *shelf_idname,
806 const char *catalog_path)
817 const char *shelf_idname,
818 const char *catalog_path)
821 userdef, shelf_idname, catalog_path))
832 const char *shelf_idname,
833 const char *catalog_path)
852 if (use_developer_ui && is_alpha) {
864 if (is_alpha ==
false) {
869 if (use_developer_ui ==
false) {
#define BLENDER_USERPREF_FILE
#define BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME
File and directory operations.
#define BLI_path_join(...)
#define STRNCPY_UTF8(dst, src)
#define USER_EXPERIMENTAL_TEST(userdef, member)
#define BLI_assert_msg(a, msg)
constexpr StringRef trim() const
constexpr int64_t size() const
void copy_bytes_truncated(char *dst, int64_t dst_size) const
constexpr const char * data() const
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
StringRefNull online_essentials_cache_directory_path()
bool is_online_essentials_url(StringRef url)
bool remote_library_url_ends_with_top_meta_file_name(const StringRef url)
std::string remote_library_cache_directory_path_from_url(StringRef remote_url)
bUserExtensionRepo * BKE_preferences_extension_repo_add_default_system(UserDef *userdef)
bool BKE_preferences_extension_repo_module_is_valid(const bUserExtensionRepo *repo)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
size_t BKE_preferences_extension_repo_user_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, const int dirpath_maxncpy)
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_preferences_asset_library_default_add(struct UserDef *userdef) ATTR_NONNULL()
bUserExtensionRepo * BKE_preferences_extension_repo_find_by_remote_url_prefix(const UserDef *userdef, const char *remote_url_full, const bool only_enabled)
int BKE_preferences_asset_library_get_index(const struct UserDef *userdef, const struct bUserAssetLibrary *library) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BKE_preferences_extension_repo_custom_dirpath_set(bUserExtensionRepo *repo, const char *path)
bool BKE_asset_catalog_path_list_has_path(const ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
static bUserAssetShelfSettings * asset_shelf_settings_ensure(UserDef *userdef, const char *shelf_idname)
const EnumPropertyItem * BKE_preferences_active_section_itemf(const UserDef *userdef, bool *r_free)
@ ASSET_LIBRARY_USE_AUTH_TOKEN
@ ASSET_LIBRARY_PROJECT_DEFINED
@ ASSET_LIBRARY_USE_REMOTE_URL
void BKE_preferences_extension_repo_module_set(UserDef *userdef, bUserExtensionRepo *repo, const char *module)
int BKE_preferences_extension_repo_get_index(const UserDef *userdef, const bUserExtensionRepo *repo)
struct bUserAssetLibrary * BKE_preferences_asset_library_add(struct UserDef *userdef, const char *name, const char *dirpath) ATTR_NONNULL(1)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BKE_preferences_remote_scheme_end(const char *url)
bUserExtensionRepo * BKE_preferences_extension_repo_add_default_user(UserDef *userdef)
struct bUserAssetLibrary * BKE_preferences_remote_asset_library_add(struct UserDef *userdef, const char *name, const char *remote_url, const char *auth_token) ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void BKE_preferences_asset_library_remove(struct UserDef *userdef, struct bUserAssetLibrary *library) ATTR_NONNULL()
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BKE_blender_version_is_alpha()
void BKE_preferences_extension_repo_name_set(UserDef *userdef, bUserExtensionRepo *repo, const char *name)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_index(const struct UserDef *userdef, int index) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BKE_preferences_extension_repo_read_data(struct BlendDataReader *reader, bUserExtensionRepo *repo)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BKE_preferences_asset_shelf_settings_ensure_catalog_path_enabled(UserDef *userdef, const char *shelf_idname, const char *catalog_path)
bool BKE_preferences_asset_library_is_valid(const UserDef *userdef, const struct bUserAssetLibrary *library, const bool check_directory_exists) ATTR_NONNULL()
void BLI_path_slash_native(char *path) ATTR_NONNULL(1)
bUserExtensionRepo * BKE_preferences_extension_repo_find_by_module(const UserDef *userdef, const char *module)
void BKE_preferences_extension_repo_write_data(struct BlendWriter *writer, const bUserExtensionRepo *repo)
bUserAssetShelfSettings * BKE_preferences_asset_shelf_settings_get(const UserDef *userdef, const char *shelf_idname)
static bUserAssetShelfSettings * asset_shelf_settings_new(UserDef *userdef, const char *shelf_idname)
struct bUserAssetLibrary * BKE_preferences_project_asset_library_add(struct UserDef *userdef, const char *name, const char *dirpath, std::optional< UUID > uuid=std::nullopt) ATTR_NONNULL(1)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_uniquename(const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_preferences_remote_to_name(const char *remote_url, char name[64])
std::optional< std::string > BKE_appdir_folder_id(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
@ USER_SECTION_EXPERIMENTAL
@ USER_SECTION_DEVELOPER_TOOLS
void BKE_preferences_asset_library_write_data(struct BlendWriter *writer, const struct bUserAssetLibrary *library)
std::string AS_asset_library_resolve_path(StringRef path)
@ ASSET_IMPORT_APPEND_REUSE
static size_t strncpy_py_module(char *dst, const char *src, const size_t dst_maxncpy)
bUserExtensionRepo * BKE_preferences_extension_repo_add_default_remote(UserDef *userdef)
struct bUserExtensionRepo * BKE_preferences_extension_asset_library_repo_get(const struct UserDef *userdef, const struct bUserAssetLibrary *library) ATTR_NONNULL()
@ USER_EXTENSION_REPO_SOURCE_SYSTEM
@ USER_EXTENSION_REPO_SOURCE_USER
bUserAssetLibraryOwner BKE_preferences_asset_library_owner_get(const struct bUserAssetLibrary *library) ATTR_NONNULL()
char char size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
struct bUserAssetLibrary bUserAssetLibrary * BKE_preferences_project_remote_asset_library_add(UserDef *userdef, const char *name, const char *remote_url, const char *auth_token) ATTR_NONNULL(1
void BKE_preferences_remote_asset_library_auth_token_set(bUserAssetLibrary *library, StringRef auth_token)
Update the remote URL authentication token.
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_by_name(const struct UserDef *userdef, const char *name) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BKE_appdir_folder_documents(char *dir) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
bUserExtensionRepo * BKE_preferences_extension_repo_find_index(const UserDef *userdef, int index)
bool BKE_preferences_asset_shelf_settings_disable_catalog_path(UserDef *userdef, const char *shelf_idname, const char *catalog_path)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void BKE_preferences_extension_repo_remove(UserDef *userdef, bUserExtensionRepo *repo)
bUUID BLI_uuid_generate_random()
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
std::optional< std::string > BKE_appdir_folder_id_user_notest(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
void BKE_preferences_extension_repo_add_defaults_all(UserDef *userdef)
@ USER_EXTENSION_REPO_FLAG_DISABLED
@ USER_EXTENSION_REPO_FLAG_USE_REMOTE_URL
@ USER_EXTENSION_REPO_FLAG_SYNC_ON_STARTUP
@ USER_EXTENSION_REPO_FLAG_USE_CUSTOM_DIRECTORY
bool BKE_preferences_asset_library_is_available(const struct UserDef *userdef, const struct bUserAssetLibrary *library) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_path_parent_dir(char *path) ATTR_NONNULL(1)
const EnumPropertyItem rna_enum_preference_section_items[]
void BKE_preferences_asset_library_name_set(struct UserDef *userdef, struct bUserAssetLibrary *library, const char *name) ATTR_NONNULL()
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BKE_preferences_remote_asset_library_url_set(bUserAssetLibrary *library, StringRef remote_url)
Update the remote URL and the cache directory derived from the URL.
bool BKE_asset_catalog_path_list_remove_path(ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
bUserExtensionRepo * BKE_preferences_extension_repo_add(UserDef *userdef, const char *name, const char *module, const char *custom_dirpath)
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
bool BLI_path_contains(const char *container_path, const char *containee_path) ATTR_NONNULL(1
void BKE_preferences_asset_library_path_set(struct bUserAssetLibrary *library, const char *path) ATTR_NONNULL()
bool BKE_preferences_asset_shelf_settings_is_catalog_path_enabled(const UserDef *userdef, const char *shelf_idname, const char *catalog_path)
@ BLENDER_SYSTEM_EXTENSIONS
@ BLENDER_USER_EXTENSIONS
void BKE_asset_catalog_path_list_add_path(ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
static void url_ensure_trailing_slash(char *str, const size_t str_maxncpy)
void BKE_preferences_asset_library_read_data(struct BlendDataReader *reader, struct bUserAssetLibrary *library)
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
static bool url_char_is_delimiter(const char ch)
struct bUserAssetLibrary * BKE_preferences_asset_library_containing_path(const struct UserDef *userdef, const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
size_t BKE_preferences_extension_repo_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, int dirpath_maxncpy)
void write_string(const char *data)
char no_data_block_packing
ListBaseT< bUserExtensionRepo > extension_repos
ListBaseT< bUserAssetLibrary > asset_libraries
ListBaseT< bUserAssetShelfSettings > asset_shelves_settings
UserDef_Experimental experimental
char resolved_dirpath[1024]
ListBaseT< AssetCatalogPathLink > enabled_catalog_paths
eUserExtensionRepo_Flag flag
eUserExtensionRepo_Source source
char custom_dirpath[1024]