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:
Diffstat (limited to 'source/blender/blenkernel/intern/blender_copybuffer.c')
-rw-r--r--source/blender/blenkernel/intern/blender_copybuffer.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index ad01fac2144..a4c28121040 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -85,6 +85,31 @@ bool BKE_copybuffer_save(Main *bmain_src, const char *filename, ReportList *repo
return retval;
}
+bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports)
+{
+ BlendHandle *bh = BLO_blendhandle_from_file(libname, reports);
+ if (bh == NULL) {
+ /* Error reports will have been made by BLO_blendhandle_from_file(). */
+ return false;
+ }
+ /* Here appending/linking starts. */
+ Main *mainl = BLO_library_link_begin(bmain_dst, &bh, libname);
+ BLO_library_link_copypaste(mainl, bh);
+ BLO_library_link_end(mainl, &bh, 0, NULL, NULL);
+ /* Mark all library linked objects to be updated. */
+ BKE_main_lib_objects_recalc_all(bmain_dst);
+ IMB_colormanagement_check_file_config(bmain_dst);
+ /* Append, rather than linking. */
+ Library *lib = BLI_findstring(&bmain_dst->library, libname, offsetof(Library, filepath));
+ BKE_library_make_local(bmain_dst, lib, true, false);
+ /* Important we unset, otherwise these object wont
+ * link into other scenes from this blend file.
+ */
+ BKE_main_id_tag_all(bmain_dst, LIB_TAG_PRE_EXISTING, false);
+ BLO_blendhandle_close(bh);
+ return true;
+}
+
/**
* \return Success.
*/