Blender  V2.93
BLO_readfile.h
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  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 #pragma once
20 
21 #include "BLI_listbase.h"
22 #include "BLI_sys_types.h"
23 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct BHead;
34 struct BlendThumbnail;
35 struct FileData;
36 struct LinkNode;
37 struct ListBase;
38 struct Main;
39 struct MemFile;
40 struct ReportList;
41 struct Scene;
42 struct UserDef;
43 struct View3D;
44 struct ViewLayer;
45 struct WorkSpace;
46 struct bScreen;
47 struct wmWindowManager;
48 
49 typedef struct BlendHandle BlendHandle;
50 
51 typedef struct WorkspaceConfigFileData {
52  struct Main *main; /* has to be freed when done reading file data */
53 
54  struct ListBase workspaces;
56 
57 /* -------------------------------------------------------------------- */
63 typedef enum eBlenFileType {
65  /* BLENFILETYPE_PUB = 2, */ /* UNUSED */
66  /* BLENFILETYPE_RUNTIME = 3, */ /* UNUSED */
68 
69 typedef struct BlendFileData {
70  struct Main *main;
71  struct UserDef *user;
72 
73  int fileflags;
74  int globalf;
75  char filename[1024]; /* 1024 = FILE_MAX */
76 
77  struct bScreen *curscreen; /* TODO think this isn't needed anymore? */
78  struct Scene *curscene;
79  struct ViewLayer *cur_view_layer; /* layer to activate in workspaces when reading without UI */
80 
83 
85  uint skip_flags : 3; /* eBLOReadSkip */
87 
89  int undo_direction; /* eUndoStepDir */
90 };
91 
92 /* skip reading some data-block types (may want to skip screen data too). */
93 typedef enum eBLOReadSkip {
96  BLO_READ_SKIP_DATA = (1 << 1),
100 #define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
101 
102 BlendFileData *BLO_read_from_file(const char *filepath,
103  eBLOReadSkip skip_flags,
104  struct ReportList *reports);
105 BlendFileData *BLO_read_from_memory(const void *mem,
106  int memsize,
107  eBLOReadSkip skip_flags,
108  struct ReportList *reports);
109 BlendFileData *BLO_read_from_memfile(struct Main *oldmain,
110  const char *filename,
111  struct MemFile *memfile,
112  const struct BlendFileReadParams *params,
113  struct ReportList *reports);
114 
116 
119 /* -------------------------------------------------------------------- */
124  char name[64]; /* MAX_NAME */
126 };
127 
128 BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct ReportList *reports);
129 BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize);
130 
132  int ofblocktype,
133 
134  const bool use_assets_only,
135  int *r_tot_names);
137  int ofblocktype,
138  int *r_tot_info_items);
139 struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev);
141 
143 
146 #define BLO_GROUP_MAX 32
147 #define BLO_EMBEDDED_STARTUP_BLEND "<startup.blend>"
148 
149 bool BLO_has_bfile_extension(const char *str);
150 bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name);
151 
152 /* -------------------------------------------------------------------- */
161 typedef enum eBLOLibLinkFlags {
175 
183  struct Main *bmain;
185  int flag;
189  struct {
191  struct Scene *scene;
195  const struct View3D *v3d;
197 };
198 
200  struct Main *bmain,
201  const int flag,
202  const int id_tag_extra);
204  struct Main *bmain,
205  const int flag,
206  const int id_tag_extra,
207  struct Scene *scene,
208  struct ViewLayer *view_layer,
209  const struct View3D *v3d);
210 
212  const char *filepath,
213  const struct LibraryLink_Params *params);
214 struct ID *BLO_library_link_named_part(struct Main *mainl,
215  BlendHandle **bh,
216  const short idcode,
217  const char *name,
218  const struct LibraryLink_Params *params);
219 void BLO_library_link_end(struct Main *mainl,
220  BlendHandle **bh,
221  const struct LibraryLink_Params *params);
222 
223 int BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh, const uint64_t id_types_mask);
224 
228 typedef struct TempLibraryContext {
230  struct Main *bmain_lib;
232  struct Main *bmain_base;
235  struct Library *lib;
236 
237  /* The ID datablock that was loaded. Is NULL if loading failed. */
238  struct ID *temp_id;
240 
242  const char *blend_file_path,
243  const short idcode,
244  const char *idname,
245  struct ReportList *reports);
246 void BLO_library_temp_free(TempLibraryContext *temp_lib_ctx);
247 
250 void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
251 
252 /* internal function but we need to expose it */
253 void blo_lib_link_restore(struct Main *oldmain,
254  struct Main *newmain,
255  struct wmWindowManager *curwm,
256  struct Scene *curscene,
257  struct ViewLayer *cur_view_layer);
258 
259 typedef void (*BLOExpandDoitCallback)(void *fdhandle, struct Main *mainvar, void *idv);
260 
261 void BLO_main_expander(BLOExpandDoitCallback expand_doit_func);
262 void BLO_expand_main(void *fdhandle, struct Main *mainvar);
263 
268 void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template);
269 void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template);
270 
271 /* Disable unwanted experimental feature settings on startup. */
273 
274 struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath);
275 
276 /* datafiles (generated theme) */
277 extern const struct bTheme U_theme_default;
278 extern const struct UserDef U_default;
279 
280 #ifdef __cplusplus
281 }
282 #endif
unsigned int uint
Definition: BLI_sys_types.h:83
const struct UserDef U_default
struct TempLibraryContext TempLibraryContext
void(* BLOExpandDoitCallback)(void *fdhandle, struct Main *mainvar, void *idv)
Definition: BLO_readfile.h:259
void BLO_sanitize_experimental_features_userpref_blend(struct UserDef *userdef)
int BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh, const uint64_t id_types_mask)
Definition: readfile.c:4941
void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template)
void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template)
struct LinkNode * BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev)
void BLO_library_link_params_init(struct LibraryLink_Params *params, struct Main *bmain, const int flag, const int id_tag_extra)
Definition: readfile.c:5069
struct ID * BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const short idcode, const char *name, const struct LibraryLink_Params *params)
Definition: readfile.c:4989
eBLOLibLinkFlags
Definition: BLO_readfile.h:161
@ BLO_LIBLINK_USE_PLACEHOLDERS
Definition: BLO_readfile.h:163
@ BLO_LIBLINK_NEEDS_ID_TAG_DOIT
Definition: BLO_readfile.h:173
@ BLO_LIBLINK_FORCE_INDIRECT
Definition: BLO_readfile.h:165
void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params, struct Main *bmain, const int flag, const int id_tag_extra, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d)
Definition: readfile.c:5080
eBLOReadSkip
Definition: BLO_readfile.h:93
@ BLO_READ_SKIP_DATA
Definition: BLO_readfile.h:96
@ BLO_READ_SKIP_USERDEF
Definition: BLO_readfile.h:95
@ BLO_READ_SKIP_UNDO_OLD_MAIN
Definition: BLO_readfile.h:98
@ BLO_READ_SKIP_NONE
Definition: BLO_readfile.h:94
struct BlendHandle BlendHandle
Definition: BLO_readfile.h:49
void BLO_main_expander(BLOExpandDoitCallback expand_doit_func)
Definition: readfile.c:4575
struct Main * BLO_library_link_begin(BlendHandle **bh, const char *filepath, const struct LibraryLink_Params *params)
Definition: readfile.c:5109
void BLO_library_temp_free(TempLibraryContext *temp_lib_ctx)
BlendFileData * BLO_read_from_memfile(struct Main *oldmain, const char *filename, struct MemFile *memfile, const struct BlendFileReadParams *params, struct ReportList *reports)
TempLibraryContext * BLO_library_temp_load_id(struct Main *real_main, const char *blend_file_path, const short idcode, const char *idname, struct ReportList *reports)
void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
Definition: readfile.c:5258
struct LinkNode * BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, const bool use_assets_only, int *r_tot_names)
void BLO_expand_main(void *fdhandle, struct Main *mainvar)
Definition: readfile.c:4587
struct WorkspaceConfigFileData WorkspaceConfigFileData
BlendHandle * BLO_blendhandle_from_memory(const void *mem, int memsize)
Definition: readblenentry.c:87
BlendHandle * BLO_blendhandle_from_file(const char *filepath, struct ReportList *reports)
Definition: readblenentry.c:71
void blo_lib_link_restore(struct Main *oldmain, struct Main *newmain, struct wmWindowManager *curwm, struct Scene *curscene, struct ViewLayer *cur_view_layer)
Definition: readfile.c:3030
struct LinkNode * BLO_blendhandle_get_datablock_info(BlendHandle *bh, int ofblocktype, int *r_tot_info_items)
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
Definition: readfile.c:1701
bool BLO_has_bfile_extension(const char *str)
Definition: readfile.c:1684
BlendFileData * BLO_read_from_file(const char *filepath, eBLOReadSkip skip_flags, struct ReportList *reports)
struct LinkNode * BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
void * BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname)
Definition: readfile.c:5271
const struct bTheme U_theme_default
void BLO_blendhandle_close(BlendHandle *bh)
struct BlendThumbnail * BLO_thumbnail_from_file(const char *filepath)
Definition: readfile.c:1769
BlendFileData * BLO_read_from_memory(const void *mem, int memsize, eBLOReadSkip skip_flags, struct ReportList *reports)
eBlenFileType
Definition: BLO_readfile.h:63
@ BLENFILETYPE_BLEND
Definition: BLO_readfile.h:64
void BLO_blendfiledata_free(BlendFileData *bfd)
struct BlendFileData BlendFileData
Scene scene
#define str(s)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
unsigned __int64 uint64_t
Definition: stdint.h:93
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
struct AssetMetaData * asset_data
Definition: BLO_readfile.h:125
struct bScreen * curscreen
Definition: BLO_readfile.h:77
eBlenFileType type
Definition: BLO_readfile.h:81
struct Scene * curscene
Definition: BLO_readfile.h:78
struct ViewLayer * cur_view_layer
Definition: BLO_readfile.h:79
struct Main * main
Definition: BLO_readfile.h:70
struct UserDef * user
Definition: BLO_readfile.h:71
char filename[1024]
Definition: BLO_readfile.h:75
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
Definition: BKE_main.h:116
struct Main * bmain_lib
Definition: BLO_readfile.h:230
struct ID * temp_id
Definition: BLO_readfile.h:238
struct LibraryLink_Params liblink_params
Definition: BLO_readfile.h:234
struct Main * bmain_base
Definition: BLO_readfile.h:232
struct Library * lib
Definition: BLO_readfile.h:235
struct BlendHandle * blendhandle
Definition: BLO_readfile.h:233
struct ListBase workspaces
Definition: BLO_readfile.h:54
char app_template[64]
Definition: wm_files.c:853