Blender  V2.93
Functions
readblenentry.c File Reference
#include <stddef.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"
#include "BKE_icons.h"
#include "BKE_idtype.h"
#include "BKE_main.h"
#include "BLO_blend_defs.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "readfile.h"
#include "BLI_sys_types.h"

Go to the source code of this file.

Functions

void BLO_blendhandle_print_sizes (BlendHandle *bh, void *fp)
 
BlendHandleBLO_blendhandle_from_file (const char *filepath, ReportList *reports)
 
BlendHandleBLO_blendhandle_from_memory (const void *mem, int memsize)
 
LinkNodeBLO_blendhandle_get_datablock_names (BlendHandle *bh, int ofblocktype, const bool use_assets_only, int *r_tot_names)
 
LinkNodeBLO_blendhandle_get_datablock_info (BlendHandle *bh, int ofblocktype, int *r_tot_info_items)
 
LinkNodeBLO_blendhandle_get_previews (BlendHandle *bh, int ofblocktype, int *r_tot_prev)
 
LinkNodeBLO_blendhandle_get_linkable_groups (BlendHandle *bh)
 
void BLO_blendhandle_close (BlendHandle *bh)
 
BlendFileDataBLO_read_from_file (const char *filepath, eBLOReadSkip skip_flags, ReportList *reports)
 
BlendFileDataBLO_read_from_memory (const void *mem, int memsize, eBLOReadSkip skip_flags, ReportList *reports)
 
BlendFileDataBLO_read_from_memfile (Main *oldmain, const char *filename, MemFile *memfile, const struct BlendFileReadParams *params, ReportList *reports)
 
void BLO_blendfiledata_free (BlendFileData *bfd)
 

Function Documentation

◆ BLO_blendfiledata_free()

void BLO_blendfiledata_free ( BlendFileData bfd)

Frees a BlendFileData structure and all the data associated with it (the userdef data, and the main libblock data).

Parameters
bfdThe structure to free.

Definition at line 482 of file readblenentry.c.

References BKE_main_free(), BlendFileData::main, MEM_freeN, and BlendFileData::user.

Referenced by BKE_blendfile_read_setup_ex(), and BlendfileLoadingBaseTest::blendfile_free().

◆ BLO_blendhandle_close()

void BLO_blendhandle_close ( BlendHandle bh)

Close and free a blendhandle. The handle becomes invalid after this call.

Parameters
bhThe handle to close.

Definition at line 350 of file readblenentry.c.

References blo_filedata_free().

Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), BLO_library_temp_free(), BLO_main_validate_libraries(), bpy_lib_exit(), filelist_freelib(), filelist_readjob_list_lib(), IMB_thumb_load_blend(), and wm_link_do().

◆ BLO_blendhandle_from_file()

BlendHandle* BLO_blendhandle_from_file ( const char *  filepath,
ReportList reports 
)

Open a blendhandle from a file path.

Parameters
filepathThe file path to open.
reportsReport errors in opening the file (can be NULL).
Returns
A handle on success, or NULL on failure.

Definition at line 71 of file readblenentry.c.

References blo_filedata_from_file().

Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), BLO_library_temp_load_id(), BLO_main_validate_libraries(), bpy_lib_enter(), filelist_readjob_list_lib(), IMB_thumb_load_blend(), and wm_link_do().

◆ BLO_blendhandle_from_memory()

BlendHandle* BLO_blendhandle_from_memory ( const void *  mem,
int  memsize 
)

Open a blendhandle from memory.

Parameters
memThe data to load from.
memsizeThe size of the data.
Returns
A handle on success, or NULL on failure.

Definition at line 87 of file readblenentry.c.

References blo_filedata_from_memory(), and NULL.

Referenced by wm_link_do().

◆ BLO_blendhandle_get_datablock_info()

LinkNode* BLO_blendhandle_get_datablock_info ( BlendHandle bh,
int  ofblocktype,
int *  r_tot_info_items 
)

Gets the names and asset-data (if ID is an asset) of all the data-blocks in a file of a certain type (e.g. all the scene names in a file).

Parameters
bhThe blendhandle to access.
ofblocktypeThe type of names to get.
tot_info_itemsThe length of the returned list.
Returns
A BLI_linklist of BLODataBlockInfo *. The links and BLODataBlockInfo.asset_data should be freed with MEM_freeN.

Definition at line 180 of file readblenentry.c.

References BLODataBlockInfo::asset_data, BLI_linklist_prepend(), blo_bhead_first(), blo_bhead_id_asset_data_address(), blo_bhead_id_name(), blo_bhead_next(), blo_bhead_prev(), blo_read_asset_data_block(), BHead::code, ENDB, MEM_mallocN, BLODataBlockInfo::name, NULL, and STRNCPY.

Referenced by filelist_readjob_list_lib().

◆ BLO_blendhandle_get_datablock_names()

LinkNode* BLO_blendhandle_get_datablock_names ( BlendHandle bh,
int  ofblocktype,
const bool  use_assets_only,
int *  r_tot_names 
)

Gets the names of all the data-blocks in a file of a certain type (e.g. all the scene names in a file).

Parameters
bhThe blendhandle to access.
ofblocktypeThe type of names to get.
tot_namesThe length of the returned list.
use_assets_onlyOnly list IDs marked as assets.
Returns
A BLI_linklist of strings. The string links should be freed with MEM_freeN().

Definition at line 141 of file readblenentry.c.

References BLI_linklist_prepend(), BLI_strdup(), blo_bhead_first(), blo_bhead_id_asset_data_address(), blo_bhead_id_name(), blo_bhead_next(), BHead::code, ENDB, names, and NULL.

Referenced by _bpy_names(), BLO_main_validate_libraries(), and IMB_thumb_load_blend().

◆ BLO_blendhandle_get_linkable_groups()

LinkNode* BLO_blendhandle_get_linkable_groups ( BlendHandle bh)

Gets the names of all the linkable data-block types available in a file. (e.g. "Scene", "Mesh", "Light", etc.).

Parameters
bhThe blendhandle to access.
Returns
A BLI_linklist of strings. The string links should be freed with MEM_freeN().

Definition at line 318 of file readblenentry.c.

References BKE_idtype_idcode_is_linkable(), BKE_idtype_idcode_is_valid(), BKE_idtype_idcode_to_name(), BLI_gset_add(), BLI_gset_free(), BLI_gset_ptr_new(), BLI_linklist_prepend(), BLI_strdup(), blo_bhead_first(), blo_bhead_next(), BHead::code, ENDB, names, NULL, and str.

Referenced by filelist_readjob_list_lib().

◆ BLO_blendhandle_get_previews()

LinkNode* BLO_blendhandle_get_previews ( BlendHandle bh,
int  ofblocktype,
int *  r_tot_prev 
)

Gets the previews of all the data-blocks in a file of a certain type (e.g. all the scene previews in a file).

Parameters
bhThe blendhandle to access.
ofblocktypeThe type of names to get.
r_tot_prevThe length of the returned list.
Returns
A BLI_linklist of PreviewImage. The PreviewImage links should be freed with malloc.

Definition at line 226 of file readblenentry.c.

References BKE_previewimg_finish(), BLI_assert, BLI_linklist_prepend(), blo_bhead_first(), blo_bhead_id_name(), blo_bhead_next(), BLO_library_read_struct(), BHead::code, DATA, DNA_struct_find_nr(), ENDB, FileData::filesdna, GS, PreviewImage::h, ID_AC, ID_GR, ID_IM, ID_LA, ID_MA, ID_OB, ID_SCE, ID_TE, ID_WO, BHead::len, MEM_callocN, MEM_freeN, NULL, PreviewImage::rect, BHead::SDNAnr, and PreviewImage::w.

Referenced by IMB_thumb_load_blend().

◆ BLO_blendhandle_print_sizes()

void BLO_blendhandle_print_sizes ( BlendHandle bh,
void *  fp 
)

◆ BLO_read_from_file()

BlendFileData* BLO_read_from_file ( const char *  filepath,
eBLOReadSkip  skip_flags,
ReportList reports 
)

Open a blender file from a pathname. The function returns NULL and sets a report in the list if it cannot open the file.

Parameters
filepathThe path of the file to open.
reportsIf the return value is NULL, errors indicating the cause of the failure.
Returns
The data of the file.

Definition at line 367 of file readblenentry.c.

References blo_filedata_free(), blo_filedata_from_file(), blo_read_file_internal(), NULL, FileData::reports, and FileData::skip_flags.

Referenced by BKE_blendfile_read(), BKE_blendfile_userdef_read(), BKE_blendfile_workspace_config_read(), and BlendfileLoadingBaseTest::blendfile_load().

◆ BLO_read_from_memfile()

BlendFileData* BLO_read_from_memfile ( Main oldmain,
const char *  filename,
MemFile memfile,
const struct BlendFileReadParams params,
ReportList reports 
)

Used for undo/redo, skips part of libraries reading (assuming their data are already loaded & valid).

Parameters
oldmainold main, from which we will keep libraries and other data-blocks that should not have changed.
filenamecurrent file, only for retrieving library data.

Definition at line 421 of file readblenentry.c.

References BLI_assert, BLI_strncpy(), blo_add_library_pointer_map(), blo_cache_storage_init(), blo_cache_storage_old_bmain_clear(), blo_clear_proxy_pointers_from_lib(), blo_filedata_free(), blo_filedata_from_memfile(), blo_join_main(), blo_make_old_idmap_from_main(), blo_read_file_internal(), BLO_READ_SKIP_UNDO_OLD_MAIN, blo_split_main(), ListBase::first, NULL, params, FileData::relabase, FileData::reports, and FileData::skip_flags.

Referenced by BKE_blendfile_read_from_memfile(), and BLO_memfile_main_get().

◆ BLO_read_from_memory()

BlendFileData* BLO_read_from_memory ( const void *  mem,
int  memsize,
eBLOReadSkip  skip_flags,
ReportList reports 
)

Open a blender file from memory. The function returns NULL and sets a report in the list if it cannot open the file.

Parameters
memThe file data.
memsizeThe length of mem.
reportsIf the return value is NULL, errors indicating the cause of the failure.
Returns
The data of the file.

Definition at line 394 of file readblenentry.c.

References blo_filedata_free(), blo_filedata_from_memory(), blo_read_file_internal(), NULL, FileData::reports, and FileData::skip_flags.

Referenced by BKE_blendfile_read_from_memory(), BKE_blendfile_userdef_read_from_memory(), BKE_blendfile_workspace_config_read(), and load_main_from_memory().