Blender V4.3
BKE_blendfile.hh File Reference
#include "BKE_main.hh"
#include "BLI_function_ref.hh"
#include "BLI_map.hh"
#include "BLI_utility_mixins.hh"
#include <string>

Go to the source code of this file.

Classes

class  blender::bke::blendfile::PartialWriteContext
 
struct  blender::bke::blendfile::PartialWriteContext::IDAddOptions
 

Namespaces

namespace  blender
 
namespace  blender::bke
 
namespace  blender::bke::blendfile
 

Macros

#define BLENDER_ASSET_FILE_SUFFIX   ".asset.blend"
 

Functions

bool BKE_blendfile_extension_check (const char *str)
 
bool BKE_blendfile_library_path_explode (const char *path, char *r_dir, char **r_group, char **r_name)
 
bool BKE_blendfile_is_readable (const char *path, ReportList *reports)
 
void BKE_blendfile_read_setup_readfile (bContext *C, BlendFileData *bfd, const BlendFileReadParams *params, BlendFileReadWMSetupData *wm_setup_data, BlendFileReadReport *reports, bool startup_update_defaults, const char *startup_app_template)
 
void BKE_blendfile_read_setup_undo (bContext *C, BlendFileData *bfd, const BlendFileReadParams *params, BlendFileReadReport *reports)
 
BlendFileDataBKE_blendfile_read (const char *filepath, const BlendFileReadParams *params, BlendFileReadReport *reports)
 
BlendFileDataBKE_blendfile_read_from_memory (const void *file_buf, int file_buf_size, const BlendFileReadParams *params, ReportList *reports)
 
BlendFileDataBKE_blendfile_read_from_memfile (Main *bmain, MemFile *memfile, const BlendFileReadParams *params, ReportList *reports)
 
void BKE_blendfile_read_make_empty (bContext *C)
 
UserDefBKE_blendfile_userdef_read (const char *filepath, ReportList *reports)
 
UserDefBKE_blendfile_userdef_read_from_memory (const void *file_buf, int file_buf_size, ReportList *reports)
 
UserDefBKE_blendfile_userdef_from_defaults ()
 
bool BKE_blendfile_userdef_write (const char *filepath, ReportList *reports)
 
bool BKE_blendfile_userdef_write_app_template (const char *filepath, ReportList *reports)
 
bool BKE_blendfile_userdef_write_all (ReportList *reports)
 
WorkspaceConfigFileDataBKE_blendfile_workspace_config_read (const char *filepath, const void *file_buf, int file_buf_size, ReportList *reports)
 
void BKE_blendfile_workspace_config_data_free (WorkspaceConfigFileData *workspace_config)
 

Macro Definition Documentation

◆ BLENDER_ASSET_FILE_SUFFIX

#define BLENDER_ASSET_FILE_SUFFIX   ".asset.blend"

The suffix used for blend-files managed by the asset system.

Definition at line 35 of file BKE_blendfile.hh.

Referenced by blender::bke::asset_blendfile_path_for_save(), blender::bke::asset_link_id(), save_set_filepath(), and wm_file_write_check_with_report_on_failure().

Function Documentation

◆ BKE_blendfile_extension_check()

bool BKE_blendfile_extension_check ( 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 83 of file blendfile.cc.

References BLI_path_extension_check_array(), and str.

Referenced by BKE_blendfile_library_path_explode(), ED_path_extension_type(), file_path_to_ui_path(), filelist_readjob_list_dir(), handle_load_file(), uiTemplateRecentFiles(), WM_lib_reload(), wm_lib_relocate_exec_do(), and wm_save_mainfile_check().

◆ BKE_blendfile_is_readable()

bool BKE_blendfile_is_readable ( const char * path,
ReportList * reports )

Check whether a given path is actually a Blender-readable, valid .blend file.

Note
Currently does attempt to open and read (part of) the given file.

Definition at line 152 of file blendfile.cc.

References BLO_blendhandle_close(), BLO_blendhandle_from_file(), and BlendFileReadReport::reports.

Referenced by file_draw_hint_if_invalid().

◆ BKE_blendfile_library_path_explode()

bool BKE_blendfile_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 at least FILE_MAX_LIBEXTRA long (it also stores group and name strings)!
r_groupa pointer within r_dir to the 'group' part of the path, if any ('\0' terminated). May be NULL.
r_namea pointer within r_dir to the data-block name, if any ('\0' terminated). May be NULL.
Returns
true if path contains a blend file.

Definition at line 89 of file blendfile.cc.

References BKE_blendfile_extension_check(), BLI_assert, BLI_is_dir(), BLI_is_file(), BLI_path_slash_rfind(), BLI_strncpy(), BLO_EMBEDDED_STARTUP_BLEND, BLO_GROUP_MAX, FILE_MAX_LIBEXTRA, MAX_ID_NAME, and STREQ.

Referenced by file_directory_enter_handle(), fileentry_uiname(), filelist_checkdir_lib(), filelist_islibrary(), filelist_readjob_list_lib(), blender::asset_system::AssetRepresentation::full_library_path(), IMB_thumb_manage(), and wm_link_append_exec().

◆ BKE_blendfile_read()

◆ BKE_blendfile_read_from_memfile()

BlendFileData * BKE_blendfile_read_from_memfile ( Main * bmain,
MemFile * memfile,
const BlendFileReadParams * params,
ReportList * reports )
Returns
Blend file data, this must be passed to BKE_blendfile_read_setup_readfile/BKE_blendfile_read_setup_undo when non-NULL.
Note
memfile is the undo buffer.

Definition at line 1350 of file blendfile.cc.

References BKE_main_blendfile_path(), BKE_reports_prepend(), BLO_blendfiledata_free(), BLO_read_from_memfile(), Main::is_read_invalid, BlendFileData::main, and params.

Referenced by BKE_memfile_undo_decode().

◆ BKE_blendfile_read_from_memory()

BlendFileData * BKE_blendfile_read_from_memory ( const void * file_buf,
int file_buf_size,
const BlendFileReadParams * params,
ReportList * reports )

◆ BKE_blendfile_read_make_empty()

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 1367 of file blendfile.cc.

References BKE_id_delete(), CTX_data_main(), ELEM, FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, GS, ID_SCE, ID_SCR, ID_WM, and ID_WS.

Referenced by wm_homefile_read_ex().

◆ BKE_blendfile_read_setup_readfile()

void BKE_blendfile_read_setup_readfile ( bContext * C,
BlendFileData * bfd,
const BlendFileReadParams * params,
BlendFileReadWMSetupData * wm_setup_data,
BlendFileReadReport * reports,
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 returned by 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 1272 of file blendfile.cc.

References BKE_reports_prepend(), BLO_blendfiledata_free(), BLO_READ_SKIP_DATA, BLO_update_defaults_startup_blend(), Main::is_read_invalid, BlendFileData::main, params, BlendFileReadReport::reports, and setup_app_blend_file_data().

Referenced by BKE_blendfile_read_setup_undo(), WM_file_read(), and wm_homefile_read_ex().

◆ BKE_blendfile_read_setup_undo()

void BKE_blendfile_read_setup_undo ( bContext * C,
BlendFileData * bfd,
const BlendFileReadParams * params,
BlendFileReadReport * reports )

Simpler version of BKE_blendfile_read_setup_readfile used when reading undo steps from memfile.

Definition at line 1297 of file blendfile.cc.

References BKE_blendfile_read_setup_readfile(), and params.

Referenced by BKE_memfile_undo_decode().

◆ BKE_blendfile_userdef_from_defaults()

◆ BKE_blendfile_userdef_read()

UserDef * BKE_blendfile_userdef_read ( const char * filepath,
ReportList * reports )

◆ BKE_blendfile_userdef_read_from_memory()

UserDef * BKE_blendfile_userdef_read_from_memory ( const void * file_buf,
int file_buf_size,
ReportList * reports )

◆ BKE_blendfile_userdef_write()

bool BKE_blendfile_userdef_write ( const char * filepath,
ReportList * reports )

Only write the UserDef in a .blend.

Returns
success.

Definition at line 1554 of file blendfile.cc.

References BLO_write_file(), MEM_freeN(), and params.

Referenced by BKE_blendfile_userdef_write_all(), and BKE_blendfile_userdef_write_app_template().

◆ BKE_blendfile_userdef_write_all()

◆ BKE_blendfile_userdef_write_app_template()

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.

Returns
success.
Note
In the future we should re-evaluate user preferences, possibly splitting out system/hardware specific preferences.

Definition at line 1571 of file blendfile.cc.

References BKE_blender_userdef_app_template_data_swap(), BKE_blender_userdef_data_free(), BKE_blendfile_userdef_from_defaults(), BKE_blendfile_userdef_read(), BKE_blendfile_userdef_write(), BLI_exists(), and MEM_freeN().

Referenced by BKE_blendfile_userdef_write_all().

◆ BKE_blendfile_workspace_config_data_free()

void BKE_blendfile_workspace_config_data_free ( WorkspaceConfigFileData * workspace_config)

Definition at line 1701 of file blendfile.cc.

References BKE_main_free(), WorkspaceConfigFileData::main, and MEM_freeN().

Referenced by workspace_add_menu().

◆ BKE_blendfile_workspace_config_read()