|
Blender
V2.93
|
#include <stdlib.h>#include <string.h>#include "MEM_guardedalloc.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "DNA_workspace_types.h"#include "BLI_listbase.h"#include "BLI_path_util.h"#include "BLI_string.h"#include "BLI_system.h"#include "BLI_utildefines.h"#include "IMB_colormanagement.h"#include "BKE_addon.h"#include "BKE_appdir.h"#include "BKE_blender.h"#include "BKE_blender_version.h"#include "BKE_blendfile.h"#include "BKE_bpath.h"#include "BKE_colorband.h"#include "BKE_context.h"#include "BKE_global.h"#include "BKE_ipo.h"#include "BKE_keyconfig.h"#include "BKE_layer.h"#include "BKE_lib_id.h"#include "BKE_lib_override.h"#include "BKE_main.h"#include "BKE_preferences.h"#include "BKE_report.h"#include "BKE_scene.h"#include "BKE_screen.h"#include "BKE_studiolight.h"#include "BKE_undo_system.h"#include "BKE_workspace.h"#include "BLO_readfile.h"#include "BLO_writefile.h"#include "RNA_access.h"#include "RE_pipeline.h"Go to the source code of this file.
High level .blend file read/write, and functions for writing partial files (only selected data-blocks).
Definition in file blendfile.c.
| struct BlendFileData* BKE_blendfile_read | ( | const char * | filepath, |
| const struct BlendFileReadParams * | params, | ||
| ReportList * | reports | ||
| ) |
Definition at line 470 of file blendfile.c.
References BKE_reports_prependf(), BLO_read_from_file(), handle_subversion_warning(), BlendFileData::main, and params.
Referenced by BKE_memfile_undo_decode(), WM_file_read(), and wm_homefile_read().
| struct BlendFileData* BKE_blendfile_read_from_memfile | ( | Main * | bmain, |
| struct MemFile * | memfile, | ||
| const struct BlendFileReadParams * | params, | ||
| ReportList * | reports | ||
| ) |
memfile is the undo buffer. Definition at line 511 of file blendfile.c.
References BKE_main_blendfile_path(), BKE_reports_prepend(), BLI_assert, BLI_listbase_is_empty(), BLO_read_from_memfile(), BlendFileData::main, params, Main::screens, Main::wm, and Main::workspaces.
Referenced by BKE_memfile_undo_decode().
| struct BlendFileData* BKE_blendfile_read_from_memory | ( | const void * | filebuf, |
| int | filelength, | ||
| const struct BlendFileReadParams * | params, | ||
| ReportList * | reports | ||
| ) |
Definition at line 492 of file blendfile.c.
References BKE_reports_prepend(), BLO_read_from_memory(), and params.
Referenced by wm_homefile_read().
| void BKE_blendfile_read_make_empty | ( | bContext * | C | ) |
Utility to make a file 'empty' used for startup to optionally give an empty file. Handy for tests.
Definition at line 537 of file blendfile.c.
References BKE_id_delete(), C, CTX_data_main(), ELEM, FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, GS, id, ID_SCE, ID_SCR, ID_WM, ID_WS, and ID::name.
Referenced by wm_homefile_read().
| void BKE_blendfile_read_setup | ( | bContext * | C, |
| BlendFileData * | bfd, | ||
| const struct BlendFileReadParams * | params, | ||
| ReportList * | reports | ||
| ) |
Definition at line 459 of file blendfile.c.
References BKE_blendfile_read_setup_ex(), C, NULL, and params.
Referenced by BKE_memfile_undo_decode(), and WM_file_read().
| void BKE_blendfile_read_setup_ex | ( | bContext * | C, |
| BlendFileData * | bfd, | ||
| const struct BlendFileReadParams * | params, | ||
| ReportList * | reports, | ||
| const bool | startup_update_defaults, | ||
| const char * | startup_app_template | ||
| ) |
Shared setup function that makes the data from bfd into the current blend file, replacing the contents of #G.main. This uses the bfd BKE_blendfile_read and similarly named functions.
This is done in a separate step so the caller may perform actions after it is known the file loaded correctly but before the file replaces the existing blend file contents.
Definition at line 442 of file blendfile.c.
References BLO_blendfiledata_free(), BLO_READ_SKIP_DATA, BLO_update_defaults_startup_blend(), C, BlendFileData::main, params, and setup_app_blend_file_data().
Referenced by BKE_blendfile_read_setup(), and wm_homefile_read().
| UserDef* BKE_blendfile_userdef_from_defaults | ( | void | ) |
Definition at line 596 of file blendfile.c.
References UserDef::addons, ARRAY_SIZE, BKE_addon_new(), BKE_appdir_font_folder_default(), BKE_colorband_init(), BKE_preferences_asset_library_default_add(), BKE_studiolight_default(), BLI_addtail(), BLI_system_memory_max_in_megabytes_int(), UserDef::coba_weight, UserDef::experimental, UserDef::flag, UserDef::fontdir, UserDef::language, UserDef::light_ambient, UserDef::light_param, MEM_mallocN, UserDef::memcachelimit, min_ii(), bAddon::module, STRNCPY, UserDef::themes, UserDef::transopts, U_default, U_theme_default, ULANGUAGE_AUTO, UserDef_Experimental::use_asset_browser, USER_SCRIPT_AUTOEXEC_DISABLE, USER_TR_IFACE, USER_TR_NEWDATANAME, and USER_TR_TOOLTIPS.
Referenced by wm_homefile_read().
| UserDef* BKE_blendfile_userdef_read | ( | const char * | filepath, |
| ReportList * | reports | ||
| ) |
Definition at line 556 of file blendfile.c.
References BKE_main_free(), BLO_read_from_file(), BLO_READ_SKIP_ALL, BLO_READ_SKIP_USERDEF, BlendFileData::main, MEM_freeN, NULL, and BlendFileData::user.
Referenced by BKE_blendfile_userdef_write_app_template(), and wm_homefile_read().
| UserDef* BKE_blendfile_userdef_read_from_memory | ( | const void * | filebuf, |
| int | filelength, | ||
| ReportList * | reports | ||
| ) |
Definition at line 573 of file blendfile.c.
References BKE_main_free(), BKE_reports_prepend(), BLO_read_from_memory(), BLO_READ_SKIP_ALL, BLO_READ_SKIP_USERDEF, BlendFileData::main, MEM_freeN, NULL, and BlendFileData::user.
| bool BKE_blendfile_userdef_write | ( | const char * | filepath, |
| ReportList * | reports | ||
| ) |
Only write the userdef in a .blend
Definition at line 673 of file blendfile.c.
References BLO_write_file(), MEM_callocN, and MEM_freeN.
Referenced by BKE_blendfile_userdef_write_all(), and BKE_blendfile_userdef_write_app_template().
| bool BKE_blendfile_userdef_write_all | ( | ReportList * | reports | ) |
Definition at line 716 of file blendfile.c.
References BKE_appdir_app_template_has_userpref(), BKE_appdir_folder_id_create(), BKE_blendfile_userdef_write(), BKE_blendfile_userdef_write_app_template(), BKE_report(), BLENDER_USER_CONFIG, BLENDER_USERPREF_FILE, BLI_path_join(), FILE_MAX, NULL, and RPT_ERROR.
Referenced by WM_exit_ex(), and wm_userpref_write_exec().
| bool BKE_blendfile_userdef_write_app_template | ( | const char * | filepath, |
| ReportList * | reports | ||
| ) |
Only write the userdef in a .blend, merging with the existing blend file.
Definition at line 700 of file blendfile.c.
References BKE_blender_userdef_app_template_data_swap(), BKE_blender_userdef_data_free(), BKE_blendfile_userdef_read(), BKE_blendfile_userdef_write(), MEM_freeN, and NULL.
Referenced by BKE_blendfile_userdef_write_all().
| void BKE_blendfile_workspace_config_data_free | ( | WorkspaceConfigFileData * | workspace_config | ) |
Definition at line 825 of file blendfile.c.
References BKE_main_free(), WorkspaceConfigFileData::main, and MEM_freeN.
Referenced by workspace_add_menu().
| WorkspaceConfigFileData* BKE_blendfile_workspace_config_read | ( | const char * | filepath, |
| const void * | filebuf, | ||
| int | filelength, | ||
| ReportList * | reports | ||
| ) |
Definition at line 773 of file blendfile.c.
References BLO_read_from_file(), BLO_read_from_memory(), BLO_READ_SKIP_USERDEF, WorkspaceConfigFileData::main, BlendFileData::main, MEM_callocN, MEM_freeN, NULL, Main::versionfile, Main::workspaces, and WorkspaceConfigFileData::workspaces.
Referenced by workspace_config_file_read(), and workspace_system_file_read().
| bool BKE_blendfile_workspace_config_write | ( | Main * | bmain, |
| const char * | filepath, | ||
| ReportList * | reports | ||
| ) |
Definition at line 804 of file blendfile.c.
References BKE_blendfile_write_partial(), BKE_blendfile_write_partial_begin(), BKE_blendfile_write_partial_end(), BKE_blendfile_write_partial_tag_ID(), BLO_WRITE_PATH_REMAP_NONE, BlendFileData::fileflags, ListBase::first, G, G_FILE_NO_UI, and Main::workspaces.
| bool BKE_blendfile_write_partial | ( | Main * | bmain_src, |
| const char * | filepath, | ||
| const int | write_flags, | ||
| const int | remap_mode, | ||
| ReportList * | reports | ||
| ) |
| remap_mode | Choose the kind of path remapping or none eBLO_WritePathRemap. |
Definition at line 871 of file blendfile.c.
References Freestyle::a, BKE_bpath_list_backup(), BKE_bpath_list_free(), BKE_bpath_list_restore(), BKE_BPATH_TRAVERSE_SKIP_LIBRARY, BKE_BPATH_TRAVERSE_SKIP_MULTIFILE, blendfile_write_partial_cb(), BLI_addtail(), BLI_pophead(), BLI_remlink(), BLI_strncpy(), BLO_expand_main(), BLO_main_expander(), BLO_write_file(), BLO_WRITE_PATH_REMAP_NONE, id, id_sort_by_name(), INDEX_ID_MAX, LIB_TAG_DOIT, MEM_callocN, MEM_freeN, Main::name, ID::next, NULL, set_listbasepointers(), and ID::tag.
Referenced by BKE_blendfile_workspace_config_write(), BKE_copybuffer_save(), and bpy_lib_write().
| void BKE_blendfile_write_partial_begin | ( | Main * | bmain_src | ) |
Definition at line 837 of file blendfile.c.
References BKE_main_id_tag_all(), LIB_TAG_DOIT, and LIB_TAG_NEED_EXPAND.
Referenced by BKE_blendfile_workspace_config_write(), BKE_copybuffer_begin(), and bpy_lib_write().
| void BKE_blendfile_write_partial_end | ( | Main * | bmain_src | ) |
Definition at line 952 of file blendfile.c.
References BKE_main_id_tag_all(), LIB_TAG_DOIT, and LIB_TAG_NEED_EXPAND.
Referenced by BKE_blendfile_workspace_config_write(), BKE_copybuffer_save(), and bpy_lib_write().
| void BKE_blendfile_write_partial_tag_ID | ( | ID * | id, |
| bool | set | ||
| ) |
Definition at line 842 of file blendfile.c.
References LIB_TAG_DOIT, and LIB_TAG_NEED_EXPAND.
Referenced by BKE_blendfile_workspace_config_write(), BKE_copybuffer_tag_ID(), and bpy_lib_write().
|
static |
Definition at line 852 of file blendfile.c.
References id, Library::id, ID::lib, LIB_TAG_DOIT, LIB_TAG_NEED_EXPAND, and ID::tag.
Referenced by BKE_blendfile_write_partial().
|
static |
Definition at line 87 of file blendfile.c.
References BKE_bpath_traverse_main(), BKE_BPATH_TRAVERSE_SKIP_MULTIFILE, BLI_path_slash_native(), clean_paths_visit_cb(), Scene::id, main(), ID::next, NULL, RenderData::pic, Scene::r, and scene.
Referenced by setup_app_data().
|
static |
Definition at line 79 of file blendfile.c.
References BLI_path_slash_native(), and STREQ.
Referenced by clean_paths().
|
static |
Definition at line 421 of file blendfile.c.
References BKE_reportf(), BLENDER_FILE_SUBVERSION, BLENDER_FILE_VERSION, main(), and RPT_ERROR.
Referenced by BKE_blendfile_read().
|
static |
Definition at line 408 of file blendfile.c.
References BLO_READ_SKIP_DATA, BLO_READ_SKIP_USERDEF, C, params, setup_app_data(), and setup_app_userdef().
Referenced by BKE_blendfile_read_setup_ex().
|
static |
Context matching, handle no-ui case
| bfd | Blend file data, freed by this function on exit. |
Definition at line 136 of file blendfile.c.
References BKE_blender_globals_clear(), BKE_lib_libblock_session_uuid_renew(), BKE_lib_override_library_main_operations_create(), BKE_lib_override_library_main_resync(), BKE_main_id_refcount_recompute(), BKE_report(), BKE_scene_add(), BKE_scene_set_background(), BKE_screen_gizmo_tag_refresh(), BKE_screen_view3d_scene_sync(), BKE_view_layer_default_view(), BLI_assert, BLI_strncpy(), blo_lib_link_restore(), BPY_context_update(), C, clean_paths(), CTX_data_main_set(), CTX_data_scene(), CTX_data_scene_set(), CTX_py_init_get(), CTX_wm_area_set(), CTX_wm_manager(), CTX_wm_manager_set(), CTX_wm_menu_set(), CTX_wm_region_set(), CTX_wm_screen(), CTX_wm_screen_set(), CTX_wm_window(), BlendFileData::cur_view_layer, BlendFileData::curscene, BlendFileData::curscreen, do_versions_ipos_to_animato(), ELEM, FILE_MAX, BlendFileData::fileflags, BlendFileData::filename, ListBase::first, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, G, G_FILE_FLAG_ALL_RUNTIME, G_FILE_NO_UI, G_FILE_RECOVER_READ, G_FLAG_ALL_READFILE, G_FLAG_ALL_RUNTIME, G_MAIN, BlendFileData::globalf, id, IMB_colormanagement_check_file_config(), LISTBASE_FOREACH, BlendFileData::main, Main::name, NULL, params, RE_FreeAllPersistentData(), RE_FreeAllRenderResults(), Main::recovered, RPT_WARNING, wmWindow::scene, Main::scenes, Main::screens, STEP_INVALID, SWAP, USER_EXPERIMENTAL_TEST, Main::versionfile, wmWindowManager::windows, Main::wm, wm_scene_is_visible(), and Main::workspaces.
Referenced by setup_app_blend_file_data().
|
static |
Definition at line 109 of file blendfile.c.
References BKE_blender_userdef_data_set_and_free(), NULL, BlendFileData::user, and USER_SCRIPT_AUTOEXEC_DISABLE.
Referenced by setup_app_blend_file_data().
|
static |
Definition at line 98 of file blendfile.c.
References ListBase::first, wmWindow::next, scene, wmWindow::scene, and wmWindowManager::windows.
Referenced by setup_app_data().