Blender V5.3
rna_packedfile.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "BKE_packedFile.hh"
15
16#include "rna_internal.hh"
17
18namespace blender {
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, nullptr, 0, nullptr, nullptr},
27};
28
29}
30
31#ifdef RNA_RUNTIME
32
33# include "DNA_packedFile_types.h"
34
35namespace blender {
36
37static void rna_PackedImage_data_get(PointerRNA *ptr, char *value)
38{
39 PackedFile *pf = static_cast<PackedFile *>(ptr->data);
40 memcpy(value, pf->data, size_t(pf->size));
41 value[pf->size] = '\0';
42}
43
44static int rna_PackedImage_data_len(PointerRNA *ptr)
45{
46 PackedFile *pf = static_cast<PackedFile *>(ptr->data);
47 return pf->size; /* No need to include trailing null char here! */
48}
49
50} // namespace blender
51
52#else
53
54namespace blender {
55
57{
58 StructRNA *srna;
59 PropertyRNA *prop;
60
61 srna = RNA_def_struct(brna, "PackedFile", nullptr);
62 RNA_def_struct_ui_text(srna, "Packed File", "External file packed into the .blend file");
63
64 prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
66 RNA_def_property_ui_text(prop, "Size", "Size of packed file in bytes");
67
68 prop = RNA_def_property(srna, "data", PROP_STRING, PROP_BYTESTRING);
70 prop, "rna_PackedImage_data_get", "rna_PackedImage_data_len", nullptr);
71 RNA_def_property_ui_text(prop, "Data", "Raw data (bytes, exact content of the embedded file)");
73}
74
75} // namespace blender
76
77#endif
#define pf(_x, _i)
Prefetch 64.
Definition gim_memory.h:48
BMesh Iterators.
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
@ PROP_STRING
Definition RNA_types.hh:213
const EnumPropertyItem rna_enum_unpack_method_items[]
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ PROP_EDITABLE
Definition RNA_types.hh:376
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
@ PROP_BYTESTRING
Definition RNA_types.hh:295
void RNA_def_packedfile(BlenderRNA *brna)