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/packedFile.c')
-rw-r--r--source/blender/blenkernel/intern/packedFile.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 6793f5e1169..ac3686a021b 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -51,6 +51,8 @@
#include "BKE_sound.h"
#include "BKE_volume.h"
+#include "BLO_read_write.h"
+
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
{
int oldseek = -1, seek = 0;
@@ -852,3 +854,29 @@ void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF
break;
}
}
+
+void BKE_packedfile_blend_write(BlendWriter *writer, PackedFile *pf)
+{
+ if (pf == NULL) {
+ return;
+ }
+ BLO_write_struct(writer, PackedFile, pf);
+ BLO_write_raw(writer, pf->size, pf->data);
+}
+
+void BKE_packedfile_blend_read(BlendDataReader *reader, PackedFile **pf_p)
+{
+ BLO_read_packed_address(reader, pf_p);
+ PackedFile *pf = *pf_p;
+ if (pf == NULL) {
+ return;
+ }
+
+ BLO_read_packed_address(reader, &pf->data);
+ if (pf->data == NULL) {
+ /* We cannot allow a PackedFile with a NULL data field,
+ * the whole code assumes this is not possible. See T70315. */
+ printf("%s: NULL packedfile data, cleaning up...\n", __func__);
+ MEM_SAFE_FREE(pf);
+ }
+}