diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-05-22 15:55:52 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-05-22 15:57:35 +0400 |
commit | 1dd977272b22cb4a20746c369b67c3ca68f3227c (patch) | |
tree | a7c4e9e504308a3263e443030bdf276762da88ac /source/blender/makesrna/intern/rna_packedfile.c | |
parent | cd14dcbe914662ae950c9178f52a63912809fb53 (diff) |
PackedFiles: add (readonly for now) access to packed raw data (most useful for exporters).
Diffstat (limited to 'source/blender/makesrna/intern/rna_packedfile.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_packedfile.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_packedfile.c b/source/blender/makesrna/intern/rna_packedfile.c index 365ad5fdb9a..ac4db49fd06 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 |