[Bf-blender-cvs] [1dd9772] master: PackedFiles: add (readonly for now) access to packed raw data (most useful for exporters).
Bastien Montagne
noreply at git.blender.org
Thu May 22 14:01:35 CEST 2014
Commit: 1dd977272b22cb4a20746c369b67c3ca68f3227c
Author: Bastien Montagne
Date: Thu May 22 13:55:52 2014 +0200
https://developer.blender.org/rB1dd977272b22cb4a20746c369b67c3ca68f3227c
PackedFiles: add (readonly for now) access to packed raw data (most useful for exporters).
===================================================================
M source/blender/makesrna/intern/rna_packedfile.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_packedfile.c b/source/blender/makesrna/intern/rna_packedfile.c
index 365ad5f..ac4db49 100644
--- a/source/blender/makesrna/intern/rna_packedfile.c
+++ b/source/blender/makesrna/intern/rna_packedfile.c
@@ -44,6 +44,20 @@ EnumPropertyItem unpack_method_items[] = {
};
#ifdef RNA_RUNTIME
+
+void rna_PackedImage_data_get(PointerRNA *ptr, char *value)
+{
+ PackedFile *pf = (PackedFile *)ptr->data;
+ memcpy(value, pf->data, (size_t)pf->size);
+ value[pf->size + 1] = '\0';
+}
+
+int rna_PackedImage_data_len(PointerRNA *ptr)
+{
+ PackedFile *pf = (PackedFile *)ptr->data;
+ return pf->size; /* No need to include trailing NULL char here! */
+}
+
#else
void RNA_def_packedfile(BlenderRNA *brna)
@@ -58,6 +72,10 @@ void RNA_def_packedfile(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Size", "Size of packed file in bytes");
+ prop = RNA_def_property(srna, "data", PROP_STRING, PROP_BYTESTRING);
+ RNA_def_property_string_funcs(prop, "rna_PackedImage_data_get", "rna_PackedImage_data_len", NULL);
+ RNA_def_property_ui_text(prop, "Data", "Raw data (bytes, exact content of the embedded file)");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
#endif
More information about the Bf-blender-cvs
mailing list