Blender V4.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
9#include <cstdlib>
10
11#include "BLI_utildefines.h"
12
14
15#include "RNA_define.hh"
16#include "RNA_enum_types.hh"
17
18#include "BKE_packedFile.hh"
19
20#include "rna_internal.hh"
21
23 {PF_REMOVE, "REMOVE", 0, "Remove Pack", ""},
24 {PF_USE_LOCAL, "USE_LOCAL", 0, "Use Local File", ""},
25 {PF_WRITE_LOCAL, "WRITE_LOCAL", 0, "Write Local File (overwrite existing)", ""},
26 {PF_USE_ORIGINAL, "USE_ORIGINAL", 0, "Use Original File", ""},
27 {PF_WRITE_ORIGINAL, "WRITE_ORIGINAL", 0, "Write Original File (overwrite existing)", ""},
28 {0, nullptr, 0, nullptr, nullptr},
29};
30
31#ifdef RNA_RUNTIME
32
33static void rna_PackedImage_data_get(PointerRNA *ptr, char *value)
34{
36 memcpy(value, pf->data, size_t(pf->size));
37 value[pf->size] = '\0';
38}
39
40static int rna_PackedImage_data_len(PointerRNA *ptr)
41{
43 return pf->size; /* No need to include trailing nullptr char here! */
44}
45
46#else
47
49{
50 StructRNA *srna;
51 PropertyRNA *prop;
52
53 srna = RNA_def_struct(brna, "PackedFile", nullptr);
54 RNA_def_struct_ui_text(srna, "Packed File", "External file packed into the .blend file");
55
56 prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
58 RNA_def_property_ui_text(prop, "Size", "Size of packed file in bytes");
59
60 prop = RNA_def_property(srna, "data", PROP_STRING, PROP_BYTESTRING);
62 prop, "rna_PackedImage_data_get", "rna_PackedImage_data_len", nullptr);
63 RNA_def_property_ui_text(prop, "Data", "Raw data (bytes, exact content of the embedded file)");
65}
66
67#endif
@ PF_USE_ORIGINAL
@ PF_USE_LOCAL
@ PF_REMOVE
@ PF_WRITE_ORIGINAL
@ PF_WRITE_LOCAL
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_BYTESTRING
Definition RNA_types.hh:143
@ PROP_NONE
Definition RNA_types.hh:136
#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)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_packedfile(BlenderRNA *brna)
const EnumPropertyItem rna_enum_unpack_method_items[]
void * data
Definition RNA_types.hh:42
PointerRNA * ptr
Definition wm_files.cc:4126