Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-09-29 14:18:44 +0300
committerJulian Eisel <julian@blender.org>2021-09-29 14:18:44 +0300
commitadaf4f56e1ed2d8ff55be4681838c9705da022ad (patch)
tree45e3551e250709edad62e220f1c3b41075ae4856 /source/blender/blenkernel/BKE_asset_library.h
parent78b9a8c7b993991c22ac2bd1ffbfaf1d896e4431 (diff)
Support loading catalogs in the Current File asset library
When the Asset Browser shows the "Current File" asset library, now it also attempts to load an asset catalog definition file from location of the current .blend file. This happens as follows: * First, see if the file is inside of an asset library that is "mounted" in the Preferences. Load the catalogs from there if so. * Otherwise, if the file is saved, load the catalogs from the directory the file is saved in. * If the file is not saved, no catalogs will be loaded. Unit tests are being worked on in D12689. Creating catalogs from the "Current File" asset library still doesn't work, as the asset catalog service doesn't construct an in-memory catalog definition file in that case yet. Differential Revision: https://developer.blender.org/D12675
Diffstat (limited to 'source/blender/blenkernel/BKE_asset_library.h')
-rw-r--r--source/blender/blenkernel/BKE_asset_library.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_asset_library.h b/source/blender/blenkernel/BKE_asset_library.h
index 709b915f9ff..04486a7c132 100644
--- a/source/blender/blenkernel/BKE_asset_library.h
+++ b/source/blender/blenkernel/BKE_asset_library.h
@@ -20,6 +20,8 @@
#pragma once
+struct Main;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -31,6 +33,41 @@ typedef struct AssetLibrary AssetLibrary;
struct AssetLibrary *BKE_asset_library_load(const char *library_path);
void BKE_asset_library_free(struct AssetLibrary *asset_library);
+/**
+ * Try to find an appropriate location for an asset library root from a file or directory path.
+ * Does not check if \a input_path exists.
+ *
+ * The design is made to find an appropriate asset library path from a .blend file path, but
+ * technically works with any file or directory as \a input_path.
+ * Design is:
+ * * If \a input_path lies within a known asset library path (i.e. an asset library registered in
+ * the Preferences), return the asset library path.
+ * * Otherwise, if \a input_path has a parent path, return the parent path (e.g. to use the
+ * directory a .blend file is in as asset library root).
+ * * If \a input_path is empty or doesn't have a parent path (e.g. because a .blend wasn't saved
+ * yet), there is no suitable path. The caller has to decide how to handle this case.
+ *
+ * \param r_library_path: The returned asset library path with a trailing slash, or an empty string
+ * if no suitable path is found. Assumed to be a buffer of at least
+ * #FILE_MAXDIR bytes.
+ *
+ * \return True if the function could find a valid, that is, a non-empty path to return in \a
+ * r_library_path.
+ */
+bool BKE_asset_library_find_suitable_root_path_from_path(
+ const char *input_path, char r_library_path[768 /* FILE_MAXDIR */]);
+/**
+ * Uses the current location on disk of the file represented by \a bmain as input to
+ * #BKE_asset_library_find_suitable_root_path_from_path(). Refer to it for a design
+ * description.
+ *
+ * \return True if the function could find a valid, that is, a non-empty path to return in \a
+ * r_library_path. If \a bmain wasn't saved into a file yet, the return value will be
+ * false.
+ */
+bool BKE_asset_library_find_suitable_root_path_from_main(
+ const struct Main *bmain, char r_library_path[768 /* FILE_MAXDIR */]);
+
#ifdef __cplusplus
}
#endif