Blender
V3.3
|
#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.
.blend
file reading entry point.
Definition in file readblenentry.c.
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).
bfd | The structure to free. |
Definition at line 449 of file readblenentry.c.
References BKE_main_free(), BlendFileData::main, MEM_freeN, and BlendFileData::user.
Referenced by BKE_blendfile_read(), BKE_blendfile_read_from_memfile(), BKE_blendfile_read_from_memory(), BKE_blendfile_read_setup_ex(), and BlendfileLoadingBaseTest::blendfile_free().
void BLO_blendhandle_close | ( | BlendHandle * | bh | ) |
Close and free a blendhandle. The handle becomes invalid after this call.
bh | The handle to close. |
Definition at line 345 of file readblenentry.c.
References blo_filedata_free().
Referenced by BKE_blendfile_is_readable(), BLO_library_temp_free(), BLO_main_validate_libraries(), bpy_lib_exit(), filelist_freelib(), filelist_readjob_list_lib(), imb_thumb_load_from_blend_id(), and link_append_context_library_blohandle_release().
BlendHandle* BLO_blendhandle_from_file | ( | const char * | filepath, |
struct BlendFileReadReport * | reports | ||
) |
Open a blendhandle from a file path.
filepath | The file path to open. |
reports | Report errors in opening the file (can be NULL). |
Definition at line 48 of file readblenentry.c.
References blo_filedata_from_file().
Referenced by BKE_blendfile_is_readable(), BLO_library_temp_load_id(), BLO_main_validate_libraries(), bpy_lib_enter(), filelist_readjob_list_lib(), imb_thumb_load_from_blend_id(), and link_append_context_library_blohandle_ensure().
BlendHandle* BLO_blendhandle_from_memory | ( | const void * | mem, |
int | memsize, | ||
struct BlendFileReadReport * | reports | ||
) |
Open a blendhandle from memory.
mem | The data to load from. |
memsize | The size of the data. |
Definition at line 57 of file readblenentry.c.
References blo_filedata_from_memory().
Referenced by link_append_context_library_blohandle_ensure().
LinkNode* BLO_blendhandle_get_datablock_info | ( | BlendHandle * | bh, |
int | ofblocktype, | ||
bool | use_assets_only, | ||
int * | r_tot_info_items | ||
) |
Gets the names and asset-data (if ID is an asset) of data-blocks in a file of a certain type. The data-blocks can be limited to assets.
bh | The blendhandle to access. |
ofblocktype | The type of names to get. |
use_assets_only | Limit the result to assets only. |
r_tot_info_items | The length of the returned list. |
BLODataBlockInfo *
. The links and BLODataBlockInfo.asset_data should be freed with MEM_freeN. Definition at line 132 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().
LinkNode* BLO_blendhandle_get_datablock_names | ( | BlendHandle * | bh, |
int | ofblocktype, | ||
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).
bh | The blendhandle to access. |
ofblocktype | The type of names to get. |
use_assets_only | Only list IDs marked as assets. |
r_tot_names | The length of the returned list. |
Definition at line 103 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(), BKE_blendfile_link_append_context_item_idtypes_from_library_add(), and BLO_main_validate_libraries().
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.).
bh | The blendhandle to access. |
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().
PreviewImage* BLO_blendhandle_get_preview_for_id | ( | BlendHandle * | bh, |
int | ofblocktype, | ||
const char * | name | ||
) |
Get the PreviewImage of a single data block in a file. (e.g. all the scene previews in a file).
bh | The blendhandle to access. |
ofblocktype | The type of names to get. |
name | Name of the block without the ID_ prefix, to read the preview image from. |
Definition at line 219 of file readblenentry.c.
References blo_bhead_first(), blo_bhead_id_name(), blo_bhead_next(), blo_blendhandle_read_preview_rects(), BLO_library_read_struct(), DATA, DNA_struct_find_nr(), ENDB, FileData::filesdna, MEM_dupallocN, MEM_freeN, BLODataBlockInfo::name, NULL, result, and STREQ.
Referenced by imb_thumb_load_from_blend_id().
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).
bh | The blendhandle to access. |
ofblocktype | The type of names to get. |
r_tot_prev | The length of the returned list. |
Definition at line 258 of file readblenentry.c.
References BLI_linklist_prepend(), blo_bhead_first(), blo_bhead_id_name(), blo_bhead_next(), blo_blendhandle_read_preview_rects(), BLO_library_read_struct(), BHead::code, DATA, DNA_struct_find_nr(), ENDB, FileData::filesdna, GS, ID_AC, ID_GR, ID_IM, ID_LA, ID_MA, ID_NT, ID_OB, ID_SCE, ID_TE, ID_WO, MEM_callocN, MEM_freeN, NULL, and BHead::SDNAnr.
void BLO_blendhandle_print_sizes | ( | BlendHandle * | bh, |
void * | fp | ||
) |
Definition at line 68 of file readblenentry.c.
References blo_bhead_first(), blo_bhead_next(), BHead::code, ENDB, FileData::filesdna, BHead::len, BHead::nr, BHead::SDNAnr, SDNA::structs, SDNA_Struct::type, and SDNA::types.
|
static |
Read the preview rects and store in result
.
bhead
should point to the block that sourced the preview_from_file
parameter. bhead
parameter is consumed. The correct bhead pointing to the next bhead in the file after the preview rects is returned by this function.
fd | The filedata to read the data from. |
bhead | should point to the block that sourced the preview_from_file parameter . bhead is consumed. the new bhead is returned by this function. |
result | the Preview Image where the preview rect will be stored. |
preview_from_file | The read PreviewImage where the bhead points to. The rects of this |
Definition at line 191 of file readblenentry.c.
References BKE_previewimg_finish(), BLI_assert, blo_bhead_next(), BLO_library_read_struct(), PreviewImage::h, BHead::len, NULL, NUM_ICON_SIZES, PreviewImage::rect, result, and PreviewImage::w.
Referenced by BLO_blendhandle_get_preview_for_id(), and BLO_blendhandle_get_previews().
BlendFileData* BLO_read_from_file | ( | const char * | filepath, |
eBLOReadSkip | skip_flags, | ||
struct BlendFileReadReport * | 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.
filepath | The path of the file to open. |
reports | If the return value is NULL, errors indicating the cause of the failure. |
Definition at line 361 of file readblenentry.c.
References blo_filedata_free(), blo_filedata_from_file(), blo_read_file_internal(), NULL, and FileData::skip_flags.
Referenced by BKE_blendfile_read(), BKE_blendfile_userdef_read(), BKE_blendfile_workspace_config_read(), and BlendfileLoadingBaseTest::blendfile_load().
BlendFileData* BLO_read_from_memfile | ( | struct Main * | oldmain, |
const char * | filepath, | ||
struct MemFile * | memfile, | ||
const struct BlendFileReadParams * | params, | ||
struct ReportList * | reports | ||
) |
Used for undo/redo, skips part of libraries reading (assuming their data are already loaded & valid).
oldmain | old main, from which we will keep libraries and other data-blocks that should not have changed. |
filepath | current file, only for retrieving library data. Typically BKE_main_blendfile_path(oldmain) . |
Definition at line 397 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_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, BlendFileReadReport::reports, and FileData::skip_flags.
Referenced by BKE_blendfile_read_from_memfile(), and BLO_memfile_main_get().
BlendFileData* BLO_read_from_memory | ( | const void * | mem, |
int | memsize, | ||
eBLOReadSkip | skip_flags, | ||
struct 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.
mem | The file data. |
memsize | The length of mem. |
reports | If the return value is NULL, errors indicating the cause of the failure. |
Definition at line 378 of file readblenentry.c.
References blo_filedata_free(), blo_filedata_from_memory(), blo_read_file_internal(), NULL, BlendFileReadReport::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().
void BLO_read_invalidate_message | ( | BlendHandle * | bh, |
struct Main * | bmain, | ||
const char * | message | ||
) |
Mark the given Main (and the 'root' local one in case of lib-split Mains) as invalid, and generate an error report containing given message
.
Definition at line 352 of file readblenentry.c.
References blo_readfile_invalidate().