Blender  V2.93
rna_packedfile.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdlib.h>
22 
23 #include "BLI_utildefines.h"
24 
25 #include "DNA_packedFile_types.h"
26 
27 #include "RNA_define.h"
28 #include "RNA_enum_types.h"
29 
30 #include "BKE_packedFile.h"
31 
32 #include "rna_internal.h"
33 
35  {PF_REMOVE, "REMOVE", 0, "Remove Pack", ""},
36  {PF_USE_LOCAL, "USE_LOCAL", 0, "Use Local File", ""},
37  {PF_WRITE_LOCAL, "WRITE_LOCAL", 0, "Write Local File (overwrite existing)", ""},
38  {PF_USE_ORIGINAL, "USE_ORIGINAL", 0, "Use Original File", ""},
39  {PF_WRITE_ORIGINAL, "WRITE_ORIGINAL", 0, "Write Original File (overwrite existing)", ""},
40  {0, NULL, 0, NULL, NULL},
41 };
42 
43 #ifdef RNA_RUNTIME
44 
45 static void rna_PackedImage_data_get(PointerRNA *ptr, char *value)
46 {
48  memcpy(value, pf->data, (size_t)pf->size);
49  value[pf->size] = '\0';
50 }
51 
52 static int rna_PackedImage_data_len(PointerRNA *ptr)
53 {
55  return pf->size; /* No need to include trailing NULL char here! */
56 }
57 
58 #else
59 
61 {
62  StructRNA *srna;
63  PropertyRNA *prop;
64 
65  srna = RNA_def_struct(brna, "PackedFile", NULL);
66  RNA_def_struct_ui_text(srna, "Packed File", "External file packed into the .blend file");
67 
68  prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
70  RNA_def_property_ui_text(prop, "Size", "Size of packed file in bytes");
71 
72  prop = RNA_def_property(srna, "data", PROP_STRING, PROP_BYTESTRING);
74  prop, "rna_PackedImage_data_get", "rna_PackedImage_data_len", NULL);
75  RNA_def_property_ui_text(prop, "Data", "Raw data (bytes, exact content of the embedded file)");
77 }
78 
79 #endif
@ PF_USE_ORIGINAL
@ PF_USE_LOCAL
@ PF_REMOVE
@ PF_WRITE_ORIGINAL
@ PF_WRITE_LOCAL
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_BYTESTRING
Definition: RNA_types.h:120
@ PROP_NONE
Definition: RNA_types.h:113
#define pf(_x, _i)
Prefetch 64.
Definition: gim_memory.h:48
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3312
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_packedfile(BlenderRNA *brna)
const EnumPropertyItem rna_enum_unpack_method_items[]
void * data
Definition: RNA_types.h:52
PointerRNA * ptr
Definition: wm_files.c:3157