diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-11-19 18:04:24 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-11-19 18:08:55 +0300 |
commit | 06ead314b63f068ae9deaed369021b01aa5f1029 (patch) | |
tree | ffcc3a555f79b11de214c38f0e565df87204454a /source/blender/blenkernel/intern/preferences.c | |
parent | 33c5e7bcd5e5b790ee95caaa0c4d917996341266 (diff) |
Asset Preferences: disallow single file as asset library
Asset libraries should be directories on disk. By manually entering a
file path it was possible to have a single blend file as asset library,
but that was not a designed-for situation, and it doesn't play well
with the asset catalog system.
Diffstat (limited to 'source/blender/blenkernel/intern/preferences.c')
-rw-r--r-- | source/blender/blenkernel/intern/preferences.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/preferences.c b/source/blender/blenkernel/intern/preferences.c index 0a10601f751..41046563f98 100644 --- a/source/blender/blenkernel/intern/preferences.c +++ b/source/blender/blenkernel/intern/preferences.c @@ -24,6 +24,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -83,6 +84,18 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef, sizeof(library->name)); } +/* Set the library path, ensuring it is pointing to a directory. + * Single blend files can only act as "Current File" library; libraries on disk + * should always be directories. If the path does not exist, that's fine; it can + * created as directory if necessary later. */ +void BKE_preferences_asset_library_path_set(bUserAssetLibrary *library, const char *path) +{ + BLI_strncpy_utf8(library->path, path, sizeof(library->path)); + if (BLI_is_file(library->path)) { + BLI_path_parent_dir(library->path); + } +} + bUserAssetLibrary *BKE_preferences_asset_library_find_from_index(const UserDef *userdef, int index) { return BLI_findlink(&userdef->asset_libraries, index); |