Blender  V3.3
rna_packedfile.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdlib.h>
8 
9 #include "BLI_utildefines.h"
10 
11 #include "DNA_packedFile_types.h"
12 
13 #include "RNA_define.h"
14 #include "RNA_enum_types.h"
15 
16 #include "BKE_packedFile.h"
17 
18 #include "rna_internal.h"
19 
21  {PF_REMOVE, "REMOVE", 0, "Remove Pack", ""},
22  {PF_USE_LOCAL, "USE_LOCAL", 0, "Use Local File", ""},
23  {PF_WRITE_LOCAL, "WRITE_LOCAL", 0, "Write Local File (overwrite existing)", ""},
24  {PF_USE_ORIGINAL, "USE_ORIGINAL", 0, "Use Original File", ""},
25  {PF_WRITE_ORIGINAL, "WRITE_ORIGINAL", 0, "Write Original File (overwrite existing)", ""},
26  {0, NULL, 0, NULL, NULL},
27 };
28 
29 #ifdef RNA_RUNTIME
30 
31 static void rna_PackedImage_data_get(PointerRNA *ptr, char *value)
32 {
34  memcpy(value, pf->data, (size_t)pf->size);
35  value[pf->size] = '\0';
36 }
37 
38 static int rna_PackedImage_data_len(PointerRNA *ptr)
39 {
41  return pf->size; /* No need to include trailing NULL char here! */
42 }
43 
44 #else
45 
47 {
48  StructRNA *srna;
49  PropertyRNA *prop;
50 
51  srna = RNA_def_struct(brna, "PackedFile", NULL);
52  RNA_def_struct_ui_text(srna, "Packed File", "External file packed into the .blend file");
53 
54  prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
56  RNA_def_property_ui_text(prop, "Size", "Size of packed file in bytes");
57 
58  prop = RNA_def_property(srna, "data", PROP_STRING, PROP_BYTESTRING);
60  prop, "rna_PackedImage_data_get", "rna_PackedImage_data_len", NULL);
61  RNA_def_property_ui_text(prop, "Data", "Raw data (bytes, exact content of the embedded file)");
63 }
64 
65 #endif
@ PF_USE_ORIGINAL
@ PF_USE_LOCAL
@ PF_REMOVE
@ PF_WRITE_ORIGINAL
@ PF_WRITE_LOCAL
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_BYTESTRING
Definition: RNA_types.h:133
@ PROP_NONE
Definition: RNA_types.h:126
#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:3285
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_def_packedfile(BlenderRNA *brna)
const EnumPropertyItem rna_enum_unpack_method_items[]
void * data
Definition: RNA_types.h:38
PointerRNA * ptr
Definition: wm_files.c:3480