Blender  V2.93
Classes | Macros | Typedefs | Functions
readfile.c File Reference
#include "zlib.h"
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include "BLI_utildefines.h"
#include <unistd.h>
#include "DNA_anim_types.h"
#include "DNA_asset_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_collection_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_genfile.h"
#include "DNA_key_types.h"
#include "DNA_layer_types.h"
#include "DNA_node_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sound_types.h"
#include "DNA_vfont_types.h"
#include "DNA_volume_types.h"
#include "DNA_workspace_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_endian_switch.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_mempool.h"
#include "BLI_mmap.h"
#include "BLI_threads.h"
#include "BLT_translation.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_asset.h"
#include "BKE_collection.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_main_idmap.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_undo_system.h"
#include "BKE_workspace.h"
#include "DRW_engine.h"
#include "DEG_depsgraph.h"
#include "BLO_blend_defs.h"
#include "BLO_blend_validate.h"
#include "BLO_read_write.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "SEQ_clipboard.h"
#include "SEQ_iterator.h"
#include "SEQ_modifier.h"
#include "SEQ_sequencer.h"
#include "readfile.h"
#include <errno.h>

Go to the source code of this file.

Classes

struct  BHeadN
 
struct  OldNew
 
struct  OldNewMap
 
struct  BlendDataReader
 
struct  BlendLibReader
 
struct  BlendExpander
 
struct  BLOCacheStorage
 
struct  BHeadSort
 

Macros

#define DNA_DEPRECATED_ALLOW
 
#define U   (*((const UserDef *)&U))
 
#define USE_BHEAD_READ_ON_DEMAND
 
#define USE_GHASH_BHEAD
 
#define USE_GHASH_RESTORE_POINTER
 
#define DEBUG_PRINTF(...)
 
#define BHEADN_FROM_BHEAD(bh)   ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead)))
 
#define BHEAD_USE_READ_ON_DEMAND(bhead)   ((bhead)->code == DATA)
 

Typedefs

typedef struct BHeadN BHeadN
 

Functions

void BLO_reportf_wrap (ReportList *reports, ReportType type, const char *format,...)
 
static const char * library_parent_filepath (Library *lib)
 
Library Reading
static void read_libraries (FileData *basefd, ListBase *mainlist)
 
static int has_linked_ids_to_read (Main *mainvar)
 
static void read_library_linked_id (FileData *basefd, FileData *fd, Main *mainvar, ID *id, ID **r_id)
 
static void read_library_linked_ids (FileData *basefd, FileData *fd, ListBase *mainlist, Main *mainvar)
 
static void read_library_clear_weak_links (FileData *basefd, ListBase *mainlist, Main *mainvar)
 
static FileDataread_library_file_data (FileData *basefd, ListBase *mainlist, Main *mainl, Main *mainptr)
 
void * BLO_read_get_new_data_address (BlendDataReader *reader, const void *old_address)
 
void * BLO_read_get_new_data_address_no_us (BlendDataReader *reader, const void *old_address)
 
void * BLO_read_get_new_packed_address (BlendDataReader *reader, const void *old_address)
 
IDBLO_read_get_new_id_address (BlendLibReader *reader, Library *lib, ID *id)
 
bool BLO_read_requires_endian_switch (BlendDataReader *reader)
 
void BLO_read_list_cb (BlendDataReader *reader, ListBase *list, BlendReadListFn callback)
 
void BLO_read_list (BlendDataReader *reader, struct ListBase *list)
 
void BLO_read_int32_array (BlendDataReader *reader, int array_size, int32_t **ptr_p)
 
void BLO_read_uint32_array (BlendDataReader *reader, int array_size, uint32_t **ptr_p)
 
void BLO_read_float_array (BlendDataReader *reader, int array_size, float **ptr_p)
 
void BLO_read_float3_array (BlendDataReader *reader, int array_size, float **ptr_p)
 
void BLO_read_double_array (BlendDataReader *reader, int array_size, double **ptr_p)
 
static void convert_pointer_array_64_to_32 (BlendDataReader *reader, uint array_size, const uint64_t *src, uint32_t *dst)
 
static void convert_pointer_array_32_to_64 (BlendDataReader *UNUSED(reader), uint array_size, const uint32_t *src, uint64_t *dst)
 
void BLO_read_pointer_array (BlendDataReader *reader, void **ptr_p)
 
bool BLO_read_data_is_undo (BlendDataReader *reader)
 
void BLO_read_data_globmap_add (BlendDataReader *reader, void *oldaddr, void *newaddr)
 
void BLO_read_glob_list (BlendDataReader *reader, ListBase *list)
 
ReportListBLO_read_data_reports (BlendDataReader *reader)
 
bool BLO_read_lib_is_undo (BlendLibReader *reader)
 
MainBLO_read_lib_get_main (BlendLibReader *reader)
 
ReportListBLO_read_lib_reports (BlendLibReader *reader)
 
void BLO_expand_id (BlendExpander *expander, ID *id)
 
DNA Struct Loading
static void * read_struct (FileData *fd, BHead *bh, const char *blockname)
 
static void switch_endian_structs (const struct SDNA *filesdna, BHead *bhead)
 
static const void * peek_struct_undo (FileData *fd, BHead *bhead)
 
static void link_glob_list (FileData *fd, ListBase *lb)
 
Library Linking

Also used for append.

static BHeadfind_bhead_from_code_name (FileData *fd, const short idcode, const char *name)
 
static BHeadfind_bhead_from_idname (FileData *fd, const char *idname)
 
static int verg_bheadsort (const void *v1, const void *v2)
 
static void sort_bhead_old_map (FileData *fd)
 
static BHeadfind_previous_lib (FileData *fd, BHead *bhead)
 
static BHeadfind_bhead (FileData *fd, void *old)
 
static IDis_yet_read (FileData *fd, Main *mainvar, BHead *bhead)
 
Library Linking (helper functions)
static bool library_link_idcode_needs_tag_check (const short idcode, const int flag)
 
static bool object_in_any_scene (Main *bmain, Object *ob)
 
static bool object_in_any_collection (Main *bmain, Object *ob)
 
static void object_base_instance_init (Object *ob, bool set_selected, bool set_active, ViewLayer *view_layer, const View3D *v3d)
 
static void add_loose_objects_to_scene (Main *mainvar, Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
 
static void add_loose_object_data_to_scene (Main *mainvar, Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d, const short flag)
 
static void add_collections_to_scene (Main *mainvar, Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
 
static IDlink_named_part (Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
 
int BLO_library_link_copypaste (Main *mainl, BlendHandle *bh, const uint64_t id_types_mask)
 
IDBLO_library_link_named_part (Main *mainl, BlendHandle **bh, const short idcode, const char *name, const struct LibraryLink_Params *params)
 
static void library_link_clear_tag (Main *mainvar, const int flag)
 
static Mainlibrary_link_begin (Main *mainvar, FileData **fd, const char *filepath, const int flag, const int id_tag_extra)
 
void BLO_library_link_params_init (struct LibraryLink_Params *params, struct Main *bmain, const int flag, const int id_tag_extra)
 
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)
 
MainBLO_library_link_begin (BlendHandle **bh, const char *filepath, const struct LibraryLink_Params *params)
 
static void split_main_newid (Main *mainptr, Main *main_newid)
 
static void library_link_end (Main *mainl, FileData **fd, Main *bmain, const int flag, Scene *scene, ViewLayer *view_layer, const View3D *v3d)
 
void BLO_library_link_end (Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
 
void * BLO_library_read_struct (FileData *fd, BHead *bh, const char *blockname)
 
Helper Functions
static void add_main_to_main (Main *mainvar, Main *from)
 
void blo_join_main (ListBase *mainlist)
 
static void split_libdata (ListBase *lb_src, Main **lib_main_array, const uint lib_main_array_len)
 
void blo_split_main (ListBase *mainlist, Main *main)
 
static void read_file_version (FileData *fd, Main *main)
 
static bool blo_bhead_is_id (const BHead *bhead)
 
static bool blo_bhead_is_id_valid_type (const BHead *bhead)
 
static void read_file_bhead_idname_map_create (FileData *fd)
 
static Mainblo_find_main (FileData *fd, const char *filepath, const char *relabase)
 
File Data API
static ssize_t fd_read_data_from_file (FileData *filedata, void *buffer, size_t size, bool *UNUSED(r_is_memchunck_identical))
 
static off64_t fd_seek_data_from_file (FileData *filedata, off64_t offset, int whence)
 
static ssize_t fd_read_gzip_from_file (FileData *filedata, void *buffer, size_t size, bool *UNUSED(r_is_memchunck_identical))
 
static ssize_t fd_read_from_memory (FileData *filedata, void *buffer, size_t size, bool *UNUSED(r_is_memchunck_identical))
 
static ssize_t fd_read_from_mmap (FileData *filedata, void *buffer, size_t size, bool *UNUSED(r_is_memchunck_identical))
 
static off64_t fd_seek_from_mmap (FileData *filedata, off64_t offset, int whence)
 
static ssize_t fd_read_from_memfile (FileData *filedata, void *buffer, size_t size, bool *r_is_memchunck_identical)
 
static FileDatafiledata_new (void)
 
static FileDatablo_decode_and_check (FileData *fd, ReportList *reports)
 
static FileDatablo_filedata_from_file_descriptor (const char *filepath, ReportList *reports, int file)
 
static FileDatablo_filedata_from_file_open (const char *filepath, ReportList *reports)
 
FileDatablo_filedata_from_file (const char *filepath, ReportList *reports)
 
static FileDatablo_filedata_from_file_minimal (const char *filepath)
 
static ssize_t fd_read_gzip_from_memory (FileData *filedata, void *buffer, size_t size, bool *UNUSED(r_is_memchunck_identical))
 
static int fd_read_gzip_from_memory_init (FileData *fd)
 
FileDatablo_filedata_from_memory (const void *mem, int memsize, ReportList *reports)
 
FileDatablo_filedata_from_memfile (MemFile *memfile, const struct BlendFileReadParams *params, ReportList *reports)
 
void blo_filedata_free (FileData *fd)
 
Public Utilities
bool BLO_has_bfile_extension (const char *str)
 
bool BLO_library_path_explode (const char *path, char *r_dir, char **r_group, char **r_name)
 
BlendThumbnailBLO_thumbnail_from_file (const char *filepath)
 
Read ID
static void lib_link_id (BlendLibReader *reader, ID *id)
 
static void lib_link_id_embedded_id (BlendLibReader *reader, ID *id)
 
static void direct_link_id_override_property_operation_cb (BlendDataReader *reader, void *data)
 
static void direct_link_id_override_property_cb (BlendDataReader *reader, void *data)
 
static void direct_link_id_common (BlendDataReader *reader, Library *current_library, ID *id, ID *id_old, const int tag)
 
static void direct_link_id_embedded_id (BlendDataReader *reader, Library *current_library, ID *id, ID *id_old)
 
static int direct_link_id_restore_recalc_exceptions (const ID *id_current)
 
static int direct_link_id_restore_recalc (const FileData *fd, const ID *id_target, const ID *id_current, const bool is_identical)
 
Read ID: Shape Keys
void blo_do_versions_key_uidgen (Key *key)
 
Read ID: Scene
static void lib_link_scenes_check_set (Main *bmain)
 
Read ID: Library
static void direct_link_library (FileData *fd, Library *lib, Main *main)
 
static void lib_link_library (BlendLibReader *UNUSED(reader), Library *UNUSED(lib))
 
static void fix_relpaths_library (const char *basepath, Main *main)
 
Read Library Data Block
static IDcreate_placeholder (Main *mainvar, const short idcode, const char *idname, const int tag)
 
static void placeholders_ensure_valid (Main *bmain)
 
static const char * dataname (short id_code)
 
static bool direct_link_id (FileData *fd, Main *main, const int tag, ID *id, ID *id_old)
 
static BHeadread_data_into_datamap (FileData *fd, BHead *bhead, const char *allocname)
 
static bool read_libblock_is_identical (FileData *fd, BHead *bhead)
 
static bool read_libblock_undo_restore_library (FileData *fd, Main *main, const ID *id)
 
static bool read_libblock_undo_restore_linked (FileData *fd, Main *main, const ID *id, BHead *bhead)
 
static void read_libblock_undo_restore_identical (FileData *fd, Main *main, const ID *UNUSED(id), ID *id_old, const int tag)
 
static void read_libblock_undo_restore_at_old_address (FileData *fd, Main *main, ID *id, ID *id_old)
 
static bool read_libblock_undo_restore (FileData *fd, Main *main, BHead *bhead, const int tag, ID **r_id_old)
 
static BHeadread_libblock (FileData *fd, Main *main, BHead *bhead, const int tag, const bool placeholder_set_indirect_extern, ID **r_id)
 
Read Asset Data
BHeadblo_read_asset_data_block (FileData *fd, BHead *bhead, AssetMetaData **r_asset_data)
 
Read Global Data
static BHeadread_global (BlendFileData *bfd, FileData *fd, BHead *bhead)
 
static void link_global (FileData *fd, BlendFileData *bfd)
 
Versioning
static void do_versions_userdef (FileData *UNUSED(fd), BlendFileData *bfd)
 
static void do_versions (FileData *fd, Library *lib, Main *main)
 
static void do_versions_after_linking (Main *main, ReportList *reports)
 
Read Library Data Block (all)
static void lib_link_all (FileData *fd, Main *bmain)
 
static void after_liblink_merged_bmain_process (Main *bmain)
 
Read User Preferences
static void direct_link_keymapitem (BlendDataReader *reader, wmKeyMapItem *kmi)
 
static BHeadread_userdef (BlendFileData *bfd, FileData *fd, BHead *bhead)
 
Read File (Internal)
BlendFileDatablo_read_file_internal (FileData *fd, const char *filepath)
 

OldNewMap API

#define ENTRIES_CAPACITY(onm)   (1ll << (onm)->capacity_exp)
 
#define MAP_CAPACITY(onm)   (1ll << ((onm)->capacity_exp + 1))
 
#define SLOT_MASK(onm)   (MAP_CAPACITY(onm) - 1)
 
#define DEFAULT_SIZE_EXP   6
 
#define PERTURB_SHIFT   5
 
#define ITER_SLOTS(onm, KEY, SLOT_NAME, INDEX_NAME)
 
typedef struct OldNew OldNew
 
typedef struct OldNewMap OldNewMap
 
static void oldnewmap_insert_index_in_map (OldNewMap *onm, const void *ptr, int index)
 
static void oldnewmap_insert_or_replace (OldNewMap *onm, OldNew entry)
 
static OldNewoldnewmap_lookup_entry (const OldNewMap *onm, const void *addr)
 
static void oldnewmap_clear_map (OldNewMap *onm)
 
static void oldnewmap_increase_size (OldNewMap *onm)
 
static OldNewMapoldnewmap_new (void)
 
static void oldnewmap_insert (OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
 
void blo_do_versions_oldnewmap_insert (OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
 
static void * oldnewmap_lookup_and_inc (OldNewMap *onm, const void *addr, bool increase_users)
 
static void * oldnewmap_liblookup (OldNewMap *onm, const void *addr, const void *lib)
 
static void oldnewmap_clear (OldNewMap *onm)
 
static void oldnewmap_free (OldNewMap *onm)
 

Read ID: Screen

enum  ePointerUserMode { USER_IGNORE = 0 , USER_REAL = 1 }
 
typedef enum ePointerUserMode ePointerUserMode
 
static void restore_pointer_user (ID *id, ID *newid, ePointerUserMode user)
 
static void * restore_pointer_by_name (struct IDNameLib_Map *id_map, ID *id, ePointerUserMode user)
 
static void lib_link_seq_clipboard_pt_restore (ID *id, struct IDNameLib_Map *id_map)
 
static int lib_link_seq_clipboard_cb (Sequence *seq, void *arg_pt)
 
static void lib_link_clipboard_restore (struct IDNameLib_Map *id_map)
 
static int lib_link_main_data_restore_cb (LibraryIDLinkCallbackData *cb_data)
 
static void lib_link_main_data_restore (struct IDNameLib_Map *id_map, Main *newmain)
 
static void lib_link_wm_xr_data_restore (struct IDNameLib_Map *id_map, wmXrData *xr_data)
 
static void lib_link_window_scene_data_restore (wmWindow *win, Scene *scene, ViewLayer *view_layer)
 
static void lib_link_workspace_layout_restore (struct IDNameLib_Map *id_map, Main *newmain, WorkSpaceLayout *layout)
 
void blo_lib_link_restore (Main *oldmain, Main *newmain, wmWindowManager *curwm, Scene *curscene, ViewLayer *cur_view_layer)
 

File Parsing

typedef struct BlendDataReader BlendDataReader
 
typedef struct BlendLibReader BlendLibReader
 
typedef struct BlendExpander BlendExpander
 
static void switch_endian_bh4 (BHead4 *bhead)
 
static void switch_endian_bh8 (BHead8 *bhead)
 
static void bh4_from_bh8 (BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
 
static void bh8_from_bh4 (BHead *bhead, BHead4 *bhead4)
 
static BHeadNget_bhead (FileData *fd)
 
BHeadblo_bhead_first (FileData *fd)
 
BHeadblo_bhead_prev (FileData *UNUSED(fd), BHead *thisblock)
 
BHeadblo_bhead_next (FileData *fd, BHead *thisblock)
 
static bool blo_bhead_read_data (FileData *fd, BHead *thisblock, void *buf)
 
static BHeadblo_bhead_read_full (FileData *fd, BHead *thisblock)
 
const char * blo_bhead_id_name (const FileData *fd, const BHead *bhead)
 
AssetMetaDatablo_bhead_id_asset_data_address (const FileData *fd, const BHead *bhead)
 
static void decode_blender_header (FileData *fd)
 
static bool read_file_dna (FileData *fd, const char **r_error_message)
 
static int * read_file_thumbnail (FileData *fd)
 

Old/New Pointer Map

typedef struct BLOCacheStorage BLOCacheStorage
 
static void * newdataadr (FileData *fd, const void *adr)
 
static void * newdataadr_no_us (FileData *fd, const void *adr)
 
void * blo_read_get_new_globaldata_address (FileData *fd, const void *adr)
 
static void * newpackedadr (FileData *fd, const void *adr)
 
static void * newlibadr (FileData *fd, const void *lib, const void *adr)
 
void * blo_do_versions_newlibadr (FileData *fd, const void *lib, const void *adr)
 
static void change_link_placeholder_to_real_ID_pointer_fd (FileData *fd, const void *old, void *new)
 
static void change_link_placeholder_to_real_ID_pointer (ListBase *mainlist, FileData *basefd, void *old, void *new)
 
void blo_clear_proxy_pointers_from_lib (Main *oldmain)
 
static void insert_packedmap (FileData *fd, PackedFile *pf)
 
void blo_make_packed_pointer_map (FileData *fd, Main *oldmain)
 
void blo_end_packed_pointer_map (FileData *fd, Main *oldmain)
 
void blo_add_library_pointer_map (ListBase *old_mainlist, FileData *fd)
 
void blo_make_old_idmap_from_main (FileData *fd, Main *bmain)
 
static void blo_cache_storage_entry_register (ID *id, const IDCacheKey *key, void **UNUSED(cache_p), uint UNUSED(flags), void *cache_storage_v)
 
static void blo_cache_storage_entry_restore_in_new (ID *UNUSED(id), const IDCacheKey *key, void **cache_p, uint flags, void *cache_storage_v)
 
static void blo_cache_storage_entry_clear_in_old (ID *UNUSED(id), const IDCacheKey *key, void **cache_p, uint UNUSED(flags), void *cache_storage_v)
 
void blo_cache_storage_init (FileData *fd, Main *bmain)
 
void blo_cache_storage_old_bmain_clear (FileData *fd, Main *bmain_old)
 
void blo_cache_storage_end (FileData *fd)
 

Library Linking (expand pointers)

static BLOExpandDoitCallback expand_doit
 
static void expand_doit_library (void *fdhandle, Main *mainvar, void *old)
 
static void expand_id (BlendExpander *expander, ID *id)
 
static void expand_id_embedded_id (BlendExpander *expander, ID *id)
 
void BLO_main_expander (BLOExpandDoitCallback expand_doit_func)
 
void BLO_expand_main (void *fdhandle, Main *mainvar)
 

Macro Definition Documentation

◆ BHEAD_USE_READ_ON_DEMAND

#define BHEAD_USE_READ_ON_DEMAND (   bhead)    ((bhead)->code == DATA)

Definition at line 219 of file readfile.c.

◆ BHEADN_FROM_BHEAD

#define BHEADN_FROM_BHEAD (   bh)    ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead)))

Definition at line 215 of file readfile.c.

◆ DEBUG_PRINTF

#define DEBUG_PRINTF (   ...)

Definition at line 193 of file readfile.c.

◆ DEFAULT_SIZE_EXP

#define DEFAULT_SIZE_EXP   6

Definition at line 277 of file readfile.c.

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 44 of file readfile.c.

◆ ENTRIES_CAPACITY

#define ENTRIES_CAPACITY (   onm)    (1ll << (onm)->capacity_exp)

Definition at line 274 of file readfile.c.

◆ ITER_SLOTS

#define ITER_SLOTS (   onm,
  KEY,
  SLOT_NAME,
  INDEX_NAME 
)
Value:
uint32_t mask = SLOT_MASK(onm); \
uint perturb = hash; \
int SLOT_NAME = mask & hash; \
int INDEX_NAME = onm->map[SLOT_NAME]; \
for (;; SLOT_NAME = mask & ((5 * SLOT_NAME) + 1 + perturb), \
perturb >>= PERTURB_SHIFT, \
INDEX_NAME = onm->map[SLOT_NAME])
unsigned int BLI_ghashutil_ptrhash(const void *key)
#define KEY(a)
#define hash
Definition: noise.c:169
#define SLOT_MASK(onm)
Definition: readfile.c:276
#define PERTURB_SHIFT
Definition: readfile.c:278
unsigned int uint32_t
Definition: stdint.h:83
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)

Definition at line 281 of file readfile.c.

◆ MAP_CAPACITY

#define MAP_CAPACITY (   onm)    (1ll << ((onm)->capacity_exp + 1))

Definition at line 275 of file readfile.c.

◆ PERTURB_SHIFT

#define PERTURB_SHIFT   5

Definition at line 278 of file readfile.c.

◆ SLOT_MASK

#define SLOT_MASK (   onm)    (MAP_CAPACITY(onm) - 1)

Definition at line 276 of file readfile.c.

◆ U

#define U   (*((const UserDef *)&U))

Definition at line 120 of file readfile.c.

◆ USE_BHEAD_READ_ON_DEMAND

#define USE_BHEAD_READ_ON_DEMAND

READ

  • Existing Library (Main) push or free
  • allocate new Main
  • load file
  • read SDNA
  • for each LibBlock
    • read LibBlock
    • if a Library
      • make a new Main
      • attach ID's to it
    • else
      • read associated 'direct data'
      • link direct data (internal and to LibBlock)
  • read FileGlobal
  • read USER data, only when indicated (file is ~/.config/blender/X.XX/config/userpref.blend)
  • free file
  • per Library (per Main)
    • read file
    • read SDNA
    • find LibBlocks and attach ID's to Main
      • if external LibBlock
        • search all Main's
          • or it's already read,
          • or not read yet
          • or make new Main
    • per LibBlock
      • read recursive
      • read associated direct data
      • link direct data (internal and to LibBlock)
    • free file
  • per Library with unread LibBlocks
    • read file
    • read SDNA
    • per LibBlock
      • read recursive
      • read associated direct data
      • link direct data (internal and to LibBlock)
    • free file
  • join all Main's
  • link all LibBlocks and indirect pointers to libblocks
  • initialize FileGlobal and copy pointers to Global
Note
Still a weak point is the new-address function, that doesn't solve reading from multiple files at the same time. (added remark: oh, i thought that was solved? will look at that... (ton). Delay reading blocks we might not use (especially applies to library linking). which keeps large arrays in memory from data-blocks we may not even use.
This is disabled when using compression, while zlib supports seek it's unusably slow, see: T61880.

Definition at line 179 of file readfile.c.

◆ USE_GHASH_BHEAD

#define USE_GHASH_BHEAD

Definition at line 182 of file readfile.c.

◆ USE_GHASH_RESTORE_POINTER

#define USE_GHASH_RESTORE_POINTER

Definition at line 185 of file readfile.c.

Typedef Documentation

◆ BHeadN

typedef struct BHeadN BHeadN

◆ BlendDataReader

◆ BlendExpander

typedef struct BlendExpander BlendExpander

◆ BlendLibReader

◆ BLOCacheStorage

◆ ePointerUserMode

◆ OldNew

typedef struct OldNew OldNew

◆ OldNewMap

typedef struct OldNewMap OldNewMap

Enumeration Type Documentation

◆ ePointerUserMode

Enumerator
USER_IGNORE 
USER_REAL 

Definition at line 2605 of file readfile.c.

Function Documentation

◆ add_collections_to_scene()

static void add_collections_to_scene ( Main mainvar,
Main bmain,
Scene scene,
ViewLayer view_layer,
const View3D v3d,
Library lib,
const short  flag 
)
static

◆ add_loose_object_data_to_scene()

static void add_loose_object_data_to_scene ( Main mainvar,
Main bmain,
Scene scene,
ViewLayer view_layer,
const View3D v3d,
const short  flag 
)
static

◆ add_loose_objects_to_scene()

static void add_loose_objects_to_scene ( Main mainvar,
Main bmain,
Scene scene,
ViewLayer view_layer,
const View3D v3d,
Library lib,
const short  flag 
)
static

◆ add_main_to_main()

static void add_main_to_main ( Main mainvar,
Main from 
)
static

◆ after_liblink_merged_bmain_process()

static void after_liblink_merged_bmain_process ( Main bmain)
static

Checks to perform after lib_link_all. Those operations cannot perform properly in a split bmain case, since some data from other bmain's (aka libraries) may not have been processed yet.

Definition at line 3973 of file readfile.c.

References BKE_main_collections_parent_relations_rebuild(), BLI_assert, BLO_main_validate_shapekeys(), lib_link_scenes_check_set(), Main::next, NULL, and Main::prev.

Referenced by blo_read_file_internal(), and library_link_end().

◆ bh4_from_bh8()

static void bh4_from_bh8 ( BHead bhead,
BHead8 bhead8,
bool  do_endian_swap 
)
static

◆ bh8_from_bh4()

static void bh8_from_bh4 ( BHead bhead,
BHead4 bhead4 
)
static

◆ blo_add_library_pointer_map()

void blo_add_library_pointer_map ( ListBase old_mainlist,
FileData fd 
)

◆ blo_bhead_first()

BHead* blo_bhead_first ( FileData fd)

◆ blo_bhead_id_asset_data_address()

AssetMetaData* blo_bhead_id_asset_data_address ( const FileData fd,
const BHead bhead 
)

◆ blo_bhead_id_name()

const char* blo_bhead_id_name ( const FileData fd,
const BHead bhead 
)

◆ blo_bhead_is_id()

static bool blo_bhead_is_id ( const BHead bhead)
static

Definition at line 558 of file readfile.c.

References BHead::code.

Referenced by blo_bhead_is_id_valid_type().

◆ blo_bhead_is_id_valid_type()

static bool blo_bhead_is_id_valid_type ( const BHead bhead)
static

◆ blo_bhead_next()

BHead* blo_bhead_next ( FileData fd,
BHead thisblock 
)

◆ blo_bhead_prev()

BHead* blo_bhead_prev ( FileData UNUSEDfd,
BHead thisblock 
)

Definition at line 914 of file readfile.c.

References BHeadN::bhead, BHEADN_FROM_BHEAD, NULL, and BHeadN::prev.

Referenced by BLO_blendhandle_get_datablock_info(), and find_previous_lib().

◆ blo_bhead_read_data()

static bool blo_bhead_read_data ( FileData fd,
BHead thisblock,
void *  buf 
)
static

◆ blo_bhead_read_full()

static BHead* blo_bhead_read_full ( FileData fd,
BHead thisblock 
)
static

◆ blo_cache_storage_end()

void blo_cache_storage_end ( FileData fd)

◆ blo_cache_storage_entry_clear_in_old()

static void blo_cache_storage_entry_clear_in_old ( ID UNUSEDid,
const IDCacheKey key,
void **  cache_p,
uint   UNUSEDflags,
void *  cache_storage_v 
)
static

Clear as needed a cache data entry from old ID, when reading some undo memfile.

Definition at line 2060 of file readfile.c.

References BLI_ghash_lookup_p(), BLOCacheStorage::cache_map, IDCacheKey::cache_v, NULL, and POINTER_AS_UINT.

Referenced by blo_cache_storage_old_bmain_clear().

◆ blo_cache_storage_entry_register()

static void blo_cache_storage_entry_register ( ID id,
const IDCacheKey key,
void **  UNUSEDcache_p,
uint   UNUSEDflags,
void *  cache_storage_v 
)
static

Register a cache data entry to be preserved when reading some undo memfile.

Definition at line 2017 of file readfile.c.

References BLI_assert, BLI_ghash_haskey(), BLI_ghash_insert(), BLI_memarena_alloc(), BLOCacheStorage::cache_map, id, IDCacheKey::id_session_uuid, BLOCacheStorage::memarena, POINTER_FROM_UINT, ID::session_uuid, and UNUSED_VARS_NDEBUG.

Referenced by blo_cache_storage_init().

◆ blo_cache_storage_entry_restore_in_new()

static void blo_cache_storage_entry_restore_in_new ( ID UNUSEDid,
const IDCacheKey key,
void **  cache_p,
uint  flags,
void *  cache_storage_v 
)
static

Restore a cache data entry from old ID into new one, when reading some undo memfile.

Definition at line 2035 of file readfile.c.

References BLI_ghash_lookup_p(), BLOCacheStorage::cache_map, IDCacheKey::cache_v, IDTYPE_CACHE_CB_FLAGS_PERSISTENT, NULL, POINTER_AS_UINT, and POINTER_FROM_UINT.

Referenced by direct_link_id().

◆ blo_cache_storage_init()

void blo_cache_storage_init ( FileData fd,
Main bmain 
)

◆ blo_cache_storage_old_bmain_clear()

void blo_cache_storage_old_bmain_clear ( FileData fd,
Main bmain_old 
)

◆ blo_clear_proxy_pointers_from_lib()

void blo_clear_proxy_pointers_from_lib ( Main oldmain)

Definition at line 1887 of file readfile.c.

References LISTBASE_FOREACH, NULL, and Main::objects.

Referenced by BLO_read_from_memfile().

◆ blo_decode_and_check()

static FileData* blo_decode_and_check ( FileData fd,
ReportList reports 
)
static

◆ blo_do_versions_key_uidgen()

void blo_do_versions_key_uidgen ( Key key)

Definition at line 2529 of file readfile.c.

References Key::block, LISTBASE_FOREACH, and Key::uidgen.

Referenced by blo_do_versions_260().

◆ blo_do_versions_newlibadr()

void* blo_do_versions_newlibadr ( FileData fd,
const void *  lib,
const void *  adr 
)

Definition at line 1840 of file readfile.c.

References lib, and newlibadr().

Referenced by blo_do_versions_250(), blo_do_versions_260(), blo_do_versions_pre250(), and ntree_version_245().

◆ blo_do_versions_oldnewmap_insert()

void blo_do_versions_oldnewmap_insert ( OldNewMap onm,
const void *  oldaddr,
void *  newaddr,
int  nr 
)

Definition at line 380 of file readfile.c.

References oldnewmap_insert().

Referenced by blo_do_versions_pre250().

◆ blo_end_packed_pointer_map()

void blo_end_packed_pointer_map ( FileData fd,
Main oldmain 
)

◆ BLO_expand_id()

void BLO_expand_id ( BlendExpander expander,
ID id 
)

Definition at line 5805 of file readfile.c.

References expand_doit, BlendExpander::fd, and BlendExpander::main.

◆ BLO_expand_main()

void BLO_expand_main ( void *  fdhandle,
Main mainvar 
)

Loop over all ID data in Main to mark relations. Set (id->tag & LIB_TAG_NEED_EXPAND) to mark expanding. Flags get cleared after expanding.

Parameters
fdhandleusually filedata, or own handle.
mainvarthe Main database to expand.

Definition at line 4587 of file readfile.c.

References Freestyle::a, BKE_idtype_get_info_from_id(), IDTypeInfo::blend_read_expand, expand_id(), ListBase::first, id, INDEX_ID_MAX, LIB_TAG_NEED_EXPAND, NULL, set_listbasepointers(), and ID::tag.

Referenced by BKE_blendfile_write_partial(), library_link_end(), and read_libraries().

◆ blo_filedata_free()

void blo_filedata_free ( FileData fd)

◆ blo_filedata_from_file()

FileData* blo_filedata_from_file ( const char *  filepath,
ReportList reports 
)

◆ blo_filedata_from_file_descriptor()

static FileData* blo_filedata_from_file_descriptor ( const char *  filepath,
ReportList reports,
int  file 
)
static

◆ blo_filedata_from_file_minimal()

static FileData* blo_filedata_from_file_minimal ( const char *  filepath)
static

Same as blo_filedata_from_file(), but does not reads DNA data, only header. Use it for light access (e.g. thumbnail reading).

Definition at line 1486 of file readfile.c.

References blo_filedata_free(), blo_filedata_from_file_open(), decode_blender_header(), FD_FLAGS_FILE_OK, FileData::flags, and NULL.

Referenced by BLO_thumbnail_from_file().

◆ blo_filedata_from_file_open()

static FileData* blo_filedata_from_file_open ( const char *  filepath,
ReportList reports 
)
static

◆ blo_filedata_from_memfile()

FileData* blo_filedata_from_memfile ( MemFile memfile,
const struct BlendFileReadParams params,
ReportList reports 
)

◆ blo_filedata_from_memory()

FileData* blo_filedata_from_memory ( const void *  mem,
int  memsize,
ReportList reports 
)

◆ blo_find_main()

static Main* blo_find_main ( FileData fd,
const char *  filepath,
const char *  relabase 
)
static

◆ BLO_has_bfile_extension()

bool BLO_has_bfile_extension ( const char *  str)

Check whether given path ends with a blend file compatible extension (.blend, .ble or .blend.gz).

Parameters
strThe path to check.
Returns
true is this path ends with a blender file extension.

Definition at line 1684 of file readfile.c.

References BLI_path_extension_check_array(), NULL, and str.

Referenced by arg_handle_load_file(), blend_save_check(), BLO_library_path_explode(), ED_path_extension_type(), file_path_to_ui_path(), filelist_readjob_list_dir(), recent_files_menu_draw(), uiTemplateRecentFiles(), WM_lib_reload(), and wm_lib_relocate_exec_do().

◆ blo_join_main()

void blo_join_main ( ListBase mainlist)

◆ blo_lib_link_restore()

void blo_lib_link_restore ( Main oldmain,
Main newmain,
wmWindowManager curwm,
Scene curscene,
ViewLayer cur_view_layer 
)

◆ BLO_library_link_begin()

Main* BLO_library_link_begin ( BlendHandle **  bh,
const char *  filepath,
const struct LibraryLink_Params params 
)

Initialize the BlendHandle for linking library data.

Parameters
bhA blender file handle as returned by BLO_blendhandle_from_file or BLO_blendhandle_from_memory.
filepathUsed for relative linking, copied to the lib->filepath.
paramsSettings for linking that don't change from beginning to end of linking.
Returns
the library Main, to be passed to BLO_library_link_named_part as mainl.

Definition at line 5109 of file readfile.c.

References library_link_begin(), and params.

Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), BLO_library_temp_load_id(), bpy_lib_exit(), and wm_link_do().

◆ BLO_library_link_copypaste()

int BLO_library_link_copypaste ( Main mainl,
BlendHandle bh,
const uint64_t  id_types_mask 
)

◆ BLO_library_link_end()

void BLO_library_link_end ( Main mainl,
BlendHandle **  bh,
const struct LibraryLink_Params params 
)

Finalize linking from a given .blend file (library). Optionally instance the indirect object/collection in the scene when the flags are set.

Note
Do not use bh after calling this function, it may frees it.
Parameters
mainlThe main database to link from (not the active one).
bhThe blender file handle (WARNING! may be freed by this function!).
paramsSettings for linking that don't change from beginning to end of linking.

Definition at line 5258 of file readfile.c.

References library_link_end(), and params.

Referenced by BKE_copybuffer_paste(), BKE_copybuffer_read(), BLO_library_temp_free(), bpy_lib_exit(), and wm_link_do().

◆ BLO_library_link_named_part()

ID* BLO_library_link_named_part ( Main mainl,
BlendHandle **  bh,
const short  idcode,
const char *  name,
const struct LibraryLink_Params params 
)

Link a named data-block from an external blend file.

Parameters
mainlThe main database to link from (not the active one).
bhThe blender file handle.
idcodeThe kind of data-block to link.
nameThe name of the data-block (without the 2 char ID prefix).
Returns
the linked ID when found.

Definition at line 4989 of file readfile.c.

References link_named_part(), and params.

Referenced by BLO_library_temp_load_id(), bpy_lib_exit(), and wm_link_do().

◆ BLO_library_link_params_init()

void BLO_library_link_params_init ( struct LibraryLink_Params params,
struct Main bmain,
const int  flag,
const int  id_tag_extra 
)

◆ BLO_library_link_params_init_with_context()

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 
)

◆ BLO_library_path_explode()

bool BLO_library_path_explode ( const char *  path,
char *  r_dir,
char **  r_group,
char **  r_name 
)

Try to explode given path into its 'library components' (i.e. a .blend file, id type/group, and data-block itself).

Parameters
paththe full path to explode.
r_dirthe string that'll contain path up to blend file itself ('library' path). WARNING! Must be FILE_MAX_LIBEXTRA long (it also stores group and name strings)!
r_groupthe string that'll contain 'group' part of the path, if any. May be NULL.
r_namethe string that'll contain data's name part of the path, if any. May be NULL.
Returns
true if path contains a blend file.

Definition at line 1701 of file readfile.c.

References BLI_assert, BLI_is_dir(), BLI_is_file(), BLI_path_slash_rfind(), BLO_EMBEDDED_STARTUP_BLEND, BLO_GROUP_MAX, BLO_has_bfile_extension(), Freestyle::c, MAX_ID_NAME, NULL, and STREQ.

Referenced by file_directory_enter_handle(), file_draw_icon(), file_draw_preview(), fileentry_uiname(), filelist_checkdir_lib(), filelist_islibrary(), filelist_readjob_list_lib(), IMB_thumb_manage(), is_filtered_lib(), and wm_link_append_exec().

◆ BLO_library_read_struct()

void* BLO_library_read_struct ( FileData fd,
BHead bh,
const char *  blockname 
)

Definition at line 5271 of file readfile.c.

References read_struct().

Referenced by BLO_blendhandle_get_previews().

◆ BLO_main_expander()

void BLO_main_expander ( BLOExpandDoitCallback  expand_doit_func)

Set the callback func used over all ID data found by BLO_expand_main func.

Parameters
expand_doit_funcCalled for each ID block it finds.

Definition at line 4575 of file readfile.c.

References expand_doit.

Referenced by BKE_blendfile_write_partial(), library_link_end(), and read_libraries().

◆ blo_make_old_idmap_from_main()

void blo_make_old_idmap_from_main ( FileData fd,
Main bmain 
)

◆ blo_make_packed_pointer_map()

void blo_make_packed_pointer_map ( FileData fd,
Main oldmain 
)

◆ blo_read_asset_data_block()

BHead* blo_read_asset_data_block ( FileData fd,
BHead bhead,
AssetMetaData **  r_asset_data 
)

◆ BLO_read_data_globmap_add()

void BLO_read_data_globmap_add ( BlendDataReader reader,
void *  oldaddr,
void *  newaddr 
)

Definition at line 5775 of file readfile.c.

References BlendDataReader::fd, FileData::globmap, and oldnewmap_insert().

Referenced by window_manager_blend_read_data().

◆ BLO_read_data_is_undo()

bool BLO_read_data_is_undo ( BlendDataReader reader)

◆ BLO_read_data_reports()

ReportList* BLO_read_data_reports ( BlendDataReader reader)

Definition at line 5785 of file readfile.c.

References BlendDataReader::fd, and FileData::reports.

Referenced by BKE_modifier_blend_read_data().

◆ BLO_read_double_array()

void BLO_read_double_array ( BlendDataReader reader,
int  array_size,
double **  ptr_p 
)

◆ blo_read_file_internal()

BlendFileData* blo_read_file_internal ( FileData fd,
const char *  filepath 
)

◆ BLO_read_float3_array()

void BLO_read_float3_array ( BlendDataReader reader,
int  array_size,
float **  ptr_p 
)

Definition at line 5683 of file readfile.c.

References BLO_read_float_array().

Referenced by blendRead().

◆ BLO_read_float_array()

void BLO_read_float_array ( BlendDataReader reader,
int  array_size,
float **  ptr_p 
)

◆ BLO_read_get_new_data_address()

void* BLO_read_get_new_data_address ( BlendDataReader reader,
const void *  old_address 
)

◆ BLO_read_get_new_data_address_no_us()

void* BLO_read_get_new_data_address_no_us ( BlendDataReader reader,
const void *  old_address 
)

Definition at line 5605 of file readfile.c.

References BlendDataReader::fd, and newdataadr_no_us().

Referenced by direct_link_area().

◆ blo_read_get_new_globaldata_address()

void* blo_read_get_new_globaldata_address ( FileData fd,
const void *  adr 
)

Definition at line 1818 of file readfile.c.

References FileData::globmap, and oldnewmap_lookup_and_inc().

Referenced by blo_do_versions_290(), and link_global().

◆ BLO_read_get_new_id_address()

ID* BLO_read_get_new_id_address ( BlendLibReader reader,
Library lib,
ID id 
)

◆ BLO_read_get_new_packed_address()

void* BLO_read_get_new_packed_address ( BlendDataReader reader,
const void *  old_address 
)

Definition at line 5610 of file readfile.c.

References BlendDataReader::fd, and newpackedadr().

◆ BLO_read_glob_list()

void BLO_read_glob_list ( BlendDataReader reader,
ListBase list 
)

Definition at line 5780 of file readfile.c.

References BlendDataReader::fd, and link_glob_list().

Referenced by scene_blend_read_data().

◆ BLO_read_int32_array()

void BLO_read_int32_array ( BlendDataReader reader,
int  array_size,
int32_t **  ptr_p 
)

◆ BLO_read_lib_get_main()

Main* BLO_read_lib_get_main ( BlendLibReader reader)

◆ BLO_read_lib_is_undo()

bool BLO_read_lib_is_undo ( BlendLibReader reader)

Definition at line 5790 of file readfile.c.

References BlendLibReader::fd, FileData::memfile, and NULL.

Referenced by BKE_pose_blend_read_lib(), and ntreeBlendReadLib().

◆ BLO_read_lib_reports()

ReportList* BLO_read_lib_reports ( BlendLibReader reader)

Definition at line 5800 of file readfile.c.

References BlendLibReader::fd, and FileData::reports.

Referenced by object_blend_read_lib(), and scene_blend_read_lib().

◆ BLO_read_list()

void BLO_read_list ( BlendDataReader reader,
struct ListBase list 
)

◆ BLO_read_list_cb()

void BLO_read_list_cb ( BlendDataReader reader,
ListBase list,
BlendReadListFn  callback 
)

Updates all ->prev and ->next pointers of the list elements. Updates the list->first and list->last pointers. When not NULL, calls the callback on every element.

Definition at line 5630 of file readfile.c.

References BLI_listbase_is_empty(), BLO_read_data_address, callback, ListBase::first, ListBase::last, Link::next, NULL, and Link::prev.

Referenced by BLO_read_list(), direct_link_id_common(), direct_link_id_override_property_cb(), and direct_link_pointcache().

◆ BLO_read_pointer_array()

void BLO_read_pointer_array ( BlendDataReader reader,
void **  ptr_p 
)

◆ BLO_read_requires_endian_switch()

bool BLO_read_requires_endian_switch ( BlendDataReader reader)

◆ BLO_read_uint32_array()

void BLO_read_uint32_array ( BlendDataReader reader,
int  array_size,
uint32_t **  ptr_p 
)

◆ BLO_reportf_wrap()

void BLO_reportf_wrap ( ReportList reports,
ReportType  type,
const char *  format,
  ... 
)

This function ensures that reports are printed, in the case of library linking errors this is important!

bit kludge but better than doubling up on prints, we could alternatively have a versions of a report function which forces printing - campbell

Definition at line 228 of file readfile.c.

References BKE_report(), BKE_report_type_str(), G, and type.

Referenced by direct_link_library(), expand_doit_library(), read_library_file_data(), and read_library_linked_id().

◆ blo_split_main()

void blo_split_main ( ListBase mainlist,
Main main 
)

◆ BLO_thumbnail_from_file()

BlendThumbnail* BLO_thumbnail_from_file ( const char *  filepath)

Does a very light reading of given .blend file to extract its stored thumbnail.

Parameters
filepathThe path of the file to extract thumbnail from.
Returns
The raw thumbnail (MEM-allocated, as stored in file, use BKE_main_thumbnail_to_imbuf() to convert it to ImBuf image).

Definition at line 1769 of file readfile.c.

References BLEN_THUMB_MEMSIZE, BLEN_THUMB_MEMSIZE_FILE, BLEN_THUMB_MEMSIZE_IS_VALID, BLI_assert, blo_filedata_free(), blo_filedata_from_file_minimal(), data, height, MEM_mallocN, NULL, read_file_thumbnail(), and width.

Referenced by IMB_thumb_load_blend().

◆ change_link_placeholder_to_real_ID_pointer()

static void change_link_placeholder_to_real_ID_pointer ( ListBase mainlist,
FileData basefd,
void *  old,
void *  new 
)
static

◆ change_link_placeholder_to_real_ID_pointer_fd()

static void change_link_placeholder_to_real_ID_pointer_fd ( FileData fd,
const void *  old,
void *  new 
)
static

◆ convert_pointer_array_32_to_64()

static void convert_pointer_array_32_to_64 ( BlendDataReader UNUSEDreader,
uint  array_size,
const uint32_t src,
uint64_t dst 
)
static

Definition at line 5716 of file readfile.c.

Referenced by BLO_read_pointer_array().

◆ convert_pointer_array_64_to_32()

static void convert_pointer_array_64_to_32 ( BlendDataReader reader,
uint  array_size,
const uint64_t src,
uint32_t dst 
)
static

Definition at line 5696 of file readfile.c.

References BLI_endian_switch_uint64(), BLO_read_requires_endian_switch(), and ptr.

Referenced by BLO_read_pointer_array().

◆ create_placeholder()

static ID* create_placeholder ( Main mainvar,
const short  idcode,
const char *  idname,
const int  tag 
)
static

◆ dataname()

static const char* dataname ( short  id_code)
static

◆ decode_blender_header()

static void decode_blender_header ( FileData fd)
static

◆ direct_link_id()

static bool direct_link_id ( FileData fd,
Main main,
const int  tag,
ID id,
ID id_old 
)
static

◆ direct_link_id_common()

static void direct_link_id_common ( BlendDataReader reader,
Library current_library,
ID id,
ID id_old,
const int  tag 
)
static

◆ direct_link_id_embedded_id()

static void direct_link_id_embedded_id ( BlendDataReader reader,
Library current_library,
ID id,
ID id_old 
)
static

◆ direct_link_id_override_property_cb()

static void direct_link_id_override_property_cb ( BlendDataReader reader,
void *  data 
)
static

◆ direct_link_id_override_property_operation_cb()

static void direct_link_id_override_property_operation_cb ( BlendDataReader reader,
void *  data 
)
static

◆ direct_link_id_restore_recalc()

static int direct_link_id_restore_recalc ( const FileData fd,
const ID id_target,
const ID id_current,
const bool  is_identical 
)
static

◆ direct_link_id_restore_recalc_exceptions()

static int direct_link_id_restore_recalc_exceptions ( const ID id_current)
static

◆ direct_link_keymapitem()

static void direct_link_keymapitem ( BlendDataReader reader,
wmKeyMapItem kmi 
)
static

◆ direct_link_library()

static void direct_link_library ( FileData fd,
Library lib,
Main main 
)
static

◆ do_versions()

static void do_versions ( FileData fd,
Library lib,
Main main 
)
static

◆ do_versions_after_linking()

static void do_versions_after_linking ( Main main,
ReportList reports 
)
static

◆ do_versions_userdef()

static void do_versions_userdef ( FileData UNUSEDfd,
BlendFileData bfd 
)
static

Definition at line 3828 of file readfile.c.

References blo_do_versions_userdef(), NULL, and BlendFileData::user.

Referenced by blo_read_file_internal().

◆ expand_doit_library()

static void expand_doit_library ( void *  fdhandle,
Main mainvar,
void *  old 
)
static

◆ expand_id()

static void expand_id ( BlendExpander expander,
ID id 
)
static

◆ expand_id_embedded_id()

static void expand_id_embedded_id ( BlendExpander expander,
ID id 
)
static

◆ fd_read_data_from_file()

static ssize_t fd_read_data_from_file ( FileData filedata,
void *  buffer,
size_t  size,
bool *  UNUSEDr_is_memchunck_identical 
)
static

Definition at line 1143 of file readfile.c.

References buffer, FileData::file_offset, FileData::filedes, and size().

Referenced by blo_filedata_from_file_descriptor().

◆ fd_read_from_memfile()

static ssize_t fd_read_from_memfile ( FileData filedata,
void *  buffer,
size_t  size,
bool *  r_is_memchunck_identical 
)
static

◆ fd_read_from_memory()

static ssize_t fd_read_from_memory ( FileData filedata,
void *  buffer,
size_t  size,
bool *  UNUSEDr_is_memchunck_identical 
)
static

◆ fd_read_from_mmap()

static ssize_t fd_read_from_mmap ( FileData filedata,
void *  buffer,
size_t  size,
bool *  UNUSEDr_is_memchunck_identical 
)
static

◆ fd_read_gzip_from_file()

static ssize_t fd_read_gzip_from_file ( FileData filedata,
void *  buffer,
size_t  size,
bool *  UNUSEDr_is_memchunck_identical 
)
static

◆ fd_read_gzip_from_memory()

static ssize_t fd_read_gzip_from_memory ( FileData filedata,
void *  buffer,
size_t  size,
bool *  UNUSEDr_is_memchunck_identical 
)
static

Definition at line 1499 of file readfile.c.

References buffer, err, FileData::file_offset, size(), and FileData::strm.

Referenced by fd_read_gzip_from_memory_init().

◆ fd_read_gzip_from_memory_init()

static int fd_read_gzip_from_memory_init ( FileData fd)
static

◆ fd_seek_data_from_file()

static off64_t fd_seek_data_from_file ( FileData filedata,
off64_t  offset,
int  whence 
)
static

Definition at line 1160 of file readfile.c.

References BLI_lseek(), FileData::file_offset, and FileData::filedes.

Referenced by blo_filedata_from_file_descriptor().

◆ fd_seek_from_mmap()

static off64_t fd_seek_from_mmap ( FileData filedata,
off64_t  offset,
int  whence 
)
static

Definition at line 1226 of file readfile.c.

References FileData::buffersize, and FileData::file_offset.

Referenced by blo_filedata_from_file_descriptor().

◆ filedata_new()

static FileData* filedata_new ( void  )
static

◆ find_bhead()

static BHead* find_bhead ( FileData fd,
void *  old 
)
static

◆ find_bhead_from_code_name()

static BHead * find_bhead_from_code_name ( FileData fd,
const short  idcode,
const char *  name 
)
static

◆ find_bhead_from_idname()

static BHead * find_bhead_from_idname ( FileData fd,
const char *  idname 
)
static

◆ find_previous_lib()

static BHead* find_previous_lib ( FileData fd,
BHead bhead 
)
static

Definition at line 4316 of file readfile.c.

References BHeadSort::bhead, blo_bhead_prev(), BHead::code, ID_LI, FileData::memfile, and NULL.

Referenced by expand_doit_library().

◆ fix_relpaths_library()

static void fix_relpaths_library ( const char *  basepath,
Main main 
)
static

◆ get_bhead()

static BHeadN* get_bhead ( FileData fd)
static

◆ has_linked_ids_to_read()

static int has_linked_ids_to_read ( Main mainvar)
static

◆ insert_packedmap()

static void insert_packedmap ( FileData fd,
PackedFile pf 
)
static

Definition at line 1899 of file readfile.c.

References oldnewmap_insert(), FileData::packedmap, and pf.

Referenced by blo_make_packed_pointer_map().

◆ is_yet_read()

static ID* is_yet_read ( FileData fd,
Main mainvar,
BHead bhead 
)
static

◆ lib_link_all()

static void lib_link_all ( FileData fd,
Main bmain 
)
static

◆ lib_link_clipboard_restore()

static void lib_link_clipboard_restore ( struct IDNameLib_Map id_map)
static

◆ lib_link_id()

static void lib_link_id ( BlendLibReader reader,
ID id 
)
static

◆ lib_link_id_embedded_id()

static void lib_link_id_embedded_id ( BlendLibReader reader,
ID id 
)
static

◆ lib_link_library()

static void lib_link_library ( BlendLibReader UNUSEDreader,
Library UNUSEDlib 
)
static

Definition at line 3150 of file readfile.c.

Referenced by lib_link_all().

◆ lib_link_main_data_restore()

static void lib_link_main_data_restore ( struct IDNameLib_Map id_map,
Main newmain 
)
static

◆ lib_link_main_data_restore_cb()

static int lib_link_main_data_restore_cb ( LibraryIDLinkCallbackData cb_data)
static

◆ lib_link_scenes_check_set()

static void lib_link_scenes_check_set ( Main bmain)
static

◆ lib_link_seq_clipboard_cb()

static int lib_link_seq_clipboard_cb ( Sequence seq,
void *  arg_pt 
)
static

◆ lib_link_seq_clipboard_pt_restore()

static void lib_link_seq_clipboard_pt_restore ( ID id,
struct IDNameLib_Map id_map 
)
static

Definition at line 2676 of file readfile.c.

References BLI_assert, id, ID::newid, NULL, restore_pointer_by_name(), and USER_REAL.

Referenced by lib_link_seq_clipboard_cb().

◆ lib_link_window_scene_data_restore()

static void lib_link_window_scene_data_restore ( wmWindow win,
Scene scene,
ViewLayer view_layer 
)
static

◆ lib_link_wm_xr_data_restore()

static void lib_link_wm_xr_data_restore ( struct IDNameLib_Map id_map,
wmXrData xr_data 
)
static

◆ lib_link_workspace_layout_restore()

static void lib_link_workspace_layout_restore ( struct IDNameLib_Map id_map,
Main newmain,
WorkSpaceLayout layout 
)
static

Definition at line 2798 of file readfile.c.

References SpaceAction::action, SpaceAction::ads, SpaceGraph::ads, SpaceNla::ads, blender::compositor::area(), bScreen::areabase, BKE_workspace_layout_screen_get(), BLI_mempool_iternew(), BLI_mempool_iterstep(), BLI_remlink(), View3D::camera, SpaceClip::clip, context, SpaceSpreadsheet::context_path, SpaceNode::edittree, FILE_TAG_REBUILD_MAIN_FILES, bDopeSheet::filter_grp, ListBase::first, SpaceAction_Runtime::flag, SpaceProperties::flag, SpaceGraph_Runtime::flag, SpaceNode::from, SpaceSeq::gpd, SpaceImage::gpd, TreeStoreElem::id, SpaceNode::id, SpaceImage::image, SpaceImage::iuser, ListBase::last, LISTBASE_FOREACH, MaskSpaceInfo::mask, SpaceImage::mask_info, SpaceClip::mask_info, MEM_freeN, MEM_SAFE_FREE, bNodeTreePath::next, bNodeTreePath::nodetree, SpaceNode::nodetree, ntree, ntreeFromID(), NULL, View3D::ob_center, SpreadsheetContextObject::object, Scopes::ok, MovieClipScopes::ok, SpaceFile::op, SpaceProperties::path, SpaceProperties::pinid, SpaceFile::previews_timer, restore_pointer_by_name(), SpaceAction::runtime, SpaceGraph::runtime, SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC, SB_PIN_CONTEXT, ImageUser::scene, SpaceImage::scopes, SpaceClip::scopes, SpaceScript::script, SCRIPT_SET_NULL, SpaceOutliner::search_tse, SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR, SO_TREESTORE_REBUILD, bDopeSheet::source, SPACE_ACTION, SPACE_CLIP, SPACE_FILE, SPACE_GRAPH, SPACE_IMAGE, SPACE_NLA, SPACE_NODE, SPACE_OUTLINER, SPACE_PROPERTIES, SPACE_SCRIPT, SPACE_SEQ, SPACE_SPREADSHEET, SPACE_TEXT, SPACE_VIEW3D, SPREADSHEET_CONTEXT_OBJECT, SpaceOutliner::storeflag, SpaceFile::tags, SpaceText::text, Main::texts, SpaceNode::treepath, SpaceOutliner::treestore, TSE_IS_REAL_ID, USER_IGNORE, USER_REAL, Scopes::vecscope, Scopes::waveform_1, Scopes::waveform_2, and Scopes::waveform_3.

Referenced by blo_lib_link_restore().

◆ library_link_begin()

static Main* library_link_begin ( Main mainvar,
FileData **  fd,
const char *  filepath,
const int  flag,
const int  id_tag_extra 
)
static

◆ library_link_clear_tag()

static void library_link_clear_tag ( Main mainvar,
const int  flag 
)
static

◆ library_link_end()

static void library_link_end ( Main mainl,
FileData **  fd,
Main bmain,
const int  flag,
Scene scene,
ViewLayer view_layer,
const View3D v3d 
)
static

◆ library_link_idcode_needs_tag_check()

static bool library_link_idcode_needs_tag_check ( const short  idcode,
const int  flag 
)
static

Checks if the idcode needs to be tagged with LIB_TAG_DOIT when linking/appending.

Definition at line 5004 of file readfile.c.

References BLO_LIBLINK_NEEDS_ID_TAG_DOIT, ELEM, FILE_OBDATA_INSTANCE, ID_GR, ID_OB, and OB_DATA_SUPPORT_ID.

Referenced by library_link_clear_tag(), and link_named_part().

◆ library_parent_filepath()

static const char* library_parent_filepath ( Library lib)
static

Definition at line 248 of file readfile.c.

References lib.

Referenced by read_library_file_data(), and read_library_linked_id().

◆ link_glob_list()

static void link_glob_list ( FileData fd,
ListBase lb 
)
static

◆ link_global()

static void link_global ( FileData fd,
BlendFileData bfd 
)
static

◆ link_named_part()

static ID* link_named_part ( Main mainl,
FileData fd,
const short  idcode,
const char *  name,
const int  flag 
)
static

◆ newdataadr()

static void* newdataadr ( FileData fd,
const void *  adr 
)
static

◆ newdataadr_no_us()

static void* newdataadr_no_us ( FileData fd,
const void *  adr 
)
static

Definition at line 1812 of file readfile.c.

References FileData::datamap, and oldnewmap_lookup_and_inc().

Referenced by BLO_read_get_new_data_address_no_us().

◆ newlibadr()

static void* newlibadr ( FileData fd,
const void *  lib,
const void *  adr 
)
static

◆ newpackedadr()

static void* newpackedadr ( FileData fd,
const void *  adr 
)
static

◆ object_base_instance_init()

static void object_base_instance_init ( Object ob,
bool  set_selected,
bool  set_active,
ViewLayer view_layer,
const View3D v3d 
)
static

◆ object_in_any_collection()

static bool object_in_any_collection ( Main bmain,
Object ob 
)
static

◆ object_in_any_scene()

static bool object_in_any_scene ( Main bmain,
Object ob 
)
static

Definition at line 4627 of file readfile.c.

References BKE_scene_object_find(), LISTBASE_FOREACH, and Main::scenes.

Referenced by add_collections_to_scene().

◆ oldnewmap_clear()

static void oldnewmap_clear ( OldNewMap onm)
static

◆ oldnewmap_clear_map()

static void oldnewmap_clear_map ( OldNewMap onm)
static

Definition at line 332 of file readfile.c.

References OldNewMap::map, and MAP_CAPACITY.

Referenced by oldnewmap_clear(), oldnewmap_increase_size(), and oldnewmap_new().

◆ oldnewmap_free()

static void oldnewmap_free ( OldNewMap onm)
static

Definition at line 430 of file readfile.c.

References OldNewMap::entries, OldNewMap::map, and MEM_freeN.

Referenced by blo_filedata_free(), and read_library_file_data().

◆ oldnewmap_increase_size()

static void oldnewmap_increase_size ( OldNewMap onm)
static

◆ oldnewmap_insert()

static void oldnewmap_insert ( OldNewMap onm,
const void *  oldaddr,
void *  newaddr,
int  nr 
)
static

◆ oldnewmap_insert_index_in_map()

static void oldnewmap_insert_index_in_map ( OldNewMap onm,
const void *  ptr,
int  index 
)
static

Definition at line 291 of file readfile.c.

References ITER_SLOTS, OldNewMap::map, and ptr.

Referenced by oldnewmap_increase_size().

◆ oldnewmap_insert_or_replace()

static void oldnewmap_insert_or_replace ( OldNewMap onm,
OldNew  entry 
)
static

Definition at line 301 of file readfile.c.

References OldNewMap::entries, ITER_SLOTS, OldNewMap::map, OldNewMap::nentries, and OldNew::oldp.

Referenced by oldnewmap_insert().

◆ oldnewmap_liblookup()

static void* oldnewmap_liblookup ( OldNewMap onm,
const void *  addr,
const void *  lib 
)
static

Definition at line 398 of file readfile.c.

References id, lib, ID::lib, NULL, and oldnewmap_lookup_and_inc().

Referenced by newlibadr().

◆ oldnewmap_lookup_and_inc()

static void* oldnewmap_lookup_and_inc ( OldNewMap onm,
const void *  addr,
bool  increase_users 
)
static

◆ oldnewmap_lookup_entry()

static OldNew* oldnewmap_lookup_entry ( const OldNewMap onm,
const void *  addr 
)
static

Definition at line 317 of file readfile.c.

References OldNewMap::entries, ITER_SLOTS, NULL, and OldNew::oldp.

Referenced by oldnewmap_lookup_and_inc().

◆ oldnewmap_new()

static OldNewMap* oldnewmap_new ( void  )
static

◆ peek_struct_undo()

static const void* peek_struct_undo ( FileData fd,
BHead bhead 
)
static

Definition at line 2243 of file readfile.c.

References BLI_assert, BHead::len, FileData::memfile, NULL, and UNUSED_VARS_NDEBUG.

Referenced by read_libblock_undo_restore().

◆ placeholders_ensure_valid()

static void placeholders_ensure_valid ( Main bmain)
static

◆ read_data_into_datamap()

static BHead* read_data_into_datamap ( FileData fd,
BHead bhead,
const char *  allocname 
)
static

◆ read_file_bhead_idname_map_create()

static void read_file_bhead_idname_map_create ( FileData fd)
static

◆ read_file_dna()

static bool read_file_dna ( FileData fd,
const char **  r_error_message 
)
static

◆ read_file_thumbnail()

static int* read_file_thumbnail ( FileData fd)
static

◆ read_file_version()

static void read_file_version ( FileData fd,
Main main 
)
static

◆ read_global()

static BHead* read_global ( BlendFileData bfd,
FileData fd,
BHead bhead 
)
static

◆ read_libblock()

static BHead* read_libblock ( FileData fd,
Main main,
BHead bhead,
const int  tag,
const bool  placeholder_set_indirect_extern,
ID **  r_id 
)
static

◆ read_libblock_is_identical()

static bool read_libblock_is_identical ( FileData fd,
BHead bhead 
)
static

Definition at line 3389 of file readfile.c.

References BHEADN_FROM_BHEAD, blo_bhead_next(), BHead::code, DATA, and BHead::len.

Referenced by read_libblock_undo_restore().

◆ read_libblock_undo_restore()

static bool read_libblock_undo_restore ( FileData fd,
Main main,
BHead bhead,
const int  tag,
ID **  r_id_old 
)
static

◆ read_libblock_undo_restore_at_old_address()

static void read_libblock_undo_restore_at_old_address ( FileData fd,
Main main,
ID id,
ID id_old 
)
static

◆ read_libblock_undo_restore_identical()

static void read_libblock_undo_restore_identical ( FileData fd,
Main main,
const ID UNUSEDid,
ID id_old,
const int  tag 
)
static

◆ read_libblock_undo_restore_library()

static bool read_libblock_undo_restore_library ( FileData fd,
Main main,
const ID id 
)
static

◆ read_libblock_undo_restore_linked()

static bool read_libblock_undo_restore_linked ( FileData fd,
Main main,
const ID id,
BHead bhead 
)
static

◆ read_libraries()

static void read_libraries ( FileData basefd,
ListBase mainlist 
)
static

◆ read_library_clear_weak_links()

static void read_library_clear_weak_links ( FileData basefd,
ListBase mainlist,
Main mainvar 
)
static

◆ read_library_file_data()

static FileData* read_library_file_data ( FileData basefd,
ListBase mainlist,
Main mainl,
Main mainptr 
)
static

◆ read_library_linked_id()

static void read_library_linked_id ( FileData basefd,
FileData fd,
Main mainvar,
ID id,
ID **  r_id 
)
static

◆ read_library_linked_ids()

static void read_library_linked_ids ( FileData basefd,
FileData fd,
ListBase mainlist,
Main mainvar 
)
static

◆ read_struct()

static void * read_struct ( FileData fd,
BHead bh,
const char *  blockname 
)
static

◆ read_userdef()

static BHead* read_userdef ( BlendFileData bfd,
FileData fd,
BHead bhead 
)
static

◆ restore_pointer_by_name()

static void* restore_pointer_by_name ( struct IDNameLib_Map id_map,
ID id,
ePointerUserMode  user 
)
static

Only for undo files, or to restore a screen after reading without UI...

Parameters
user
  • USER_IGNORE: no user-count change.
  • USER_REAL: ensure a real user (even if a fake one is set).
id_maplookup table, use when performing many lookups. this could be made an optional argument (falling back to a full lookup), however at the moment it's always available.

Definition at line 2658 of file readfile.c.

References BKE_main_idmap_lookup_id(), BKE_main_idmap_main_get(), NULL, and restore_pointer_user().

Referenced by blo_lib_link_restore(), lib_link_main_data_restore_cb(), lib_link_seq_clipboard_pt_restore(), lib_link_wm_xr_data_restore(), and lib_link_workspace_layout_restore().

◆ restore_pointer_user()

static void restore_pointer_user ( ID id,
ID newid,
ePointerUserMode  user 
)
static

Definition at line 2610 of file readfile.c.

References BLI_assert, id, id_us_ensure_real(), ID::lib, ID::name, STREQ, UNUSED_VARS_NDEBUG, and USER_REAL.

Referenced by restore_pointer_by_name().

◆ sort_bhead_old_map()

static void sort_bhead_old_map ( FileData fd)
static

◆ split_libdata()

static void split_libdata ( ListBase lb_src,
Main **  lib_main_array,
const uint  lib_main_array_len 
)
static

◆ split_main_newid()

static void split_main_newid ( Main mainptr,
Main main_newid 
)
static

◆ switch_endian_bh4()

static void switch_endian_bh4 ( BHead4 bhead)
static

Definition at line 688 of file readfile.c.

References BLI_endian_switch_int32(), BHead4::code, ENDB, BHead4::len, BHead4::nr, and BHead4::SDNAnr.

Referenced by get_bhead().

◆ switch_endian_bh8()

static void switch_endian_bh8 ( BHead8 bhead)
static

Definition at line 702 of file readfile.c.

References BLI_endian_switch_int32(), BHead8::code, ENDB, BHead8::len, BHead8::nr, and BHead8::SDNAnr.

Referenced by get_bhead().

◆ switch_endian_structs()

static void switch_endian_structs ( const struct SDNA filesdna,
BHead bhead 
)
static

◆ verg_bheadsort()

static int verg_bheadsort ( const void *  v1,
const void *  v2 
)
static

Definition at line 4278 of file readfile.c.

References BHeadSort::old, v1, v2, and x2.

Referenced by find_bhead(), and sort_bhead_old_map().

Variable Documentation

◆ expand_doit

BLOExpandDoitCallback expand_doit
static

Definition at line 4531 of file readfile.c.

Referenced by BLO_expand_id(), and BLO_main_expander().