Blender V5.0
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
19 {PF_REMOVE, "REMOVE", 0, "Remove Pack", ""},
20 {PF_USE_LOCAL, "USE_LOCAL", 0, "Use Local File", ""},
21 {PF_WRITE_LOCAL, "WRITE_LOCAL", 0, "Write Local File (overwrite existing)", ""},
22 {PF_USE_ORIGINAL, "USE_ORIGINAL", 0, "Use Original File", ""},
23 {PF_WRITE_ORIGINAL, "WRITE_ORIGINAL", 0, "Write Original File (overwrite existing)", ""},
24 {0, nullptr, 0, nullptr, nullptr},
25};
26
27#ifdef RNA_RUNTIME
28
29# include "DNA_packedFile_types.h"
30
31static void rna_PackedImage_data_get(PointerRNA *ptr, char *value)
32{
33 PackedFile *pf = (PackedFile *)ptr->data;
34 memcpy(value, pf->data, size_t(pf->size));
35 value[pf->size] = '\0';
36}
37
38static int rna_PackedImage_data_len(PointerRNA *ptr)
39{
40 PackedFile *pf = (PackedFile *)ptr->data;
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", nullptr);
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", nullptr);
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.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_BYTESTRING
Definition RNA_types.hh:240
@ PROP_NONE
Definition RNA_types.hh:233
#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[]
PointerRNA * ptr
Definition wm_files.cc:4238