43 for (
const int i :
IndexRange(dir_entries_num)) {
44 const direntry &dir_entry = dir_entries[i];
54 bake_files.append(bake_file);
98 fstream fs(file_path, std::ios::out | std::ios::binary);
99 fs.write(
static_cast<const char *
>(bake_file.packed_file->data), bake_file.packed_file->size);
110 if (!unpack_file(bake_path.
meta_dir, bake_file)) {
117 if (!unpack_file(bake_path.
blobs_dir, bake_file)) {
178 BKE_report(reports,
RPT_ERROR,
"Can only unpack bake if the current .blend file is saved");
184 auto prepare_local_path = [&]() {
186 bmain,
object, nmd,
bake.id);
188 MEM_SAFE_DELETE(
bake.directory);
192 STRNCPY(absolute_dir, directory.c_str());
196 auto prepare_original_path = [&]() {
198 bmain,
object, nmd,
bake.id))
202 return prepare_local_path();
205 BLI_delete(bake_path.meta_dir.c_str(),
true,
true);
206 BLI_delete(bake_path.blobs_dir.c_str(),
true,
true);
208 auto free_packed_bake = [&]() {
210 bake.packed =
nullptr;
213 auto finalize_on_success = [&]() {
222 delete_bake_on_disk(bake_path);
228 return finalize_on_success();
232 delete_bake_on_disk(bake_path);
237 return finalize_on_success();
242 delete_bake_on_disk(bake_path);
248 return finalize_on_success();
252 delete_bake_on_disk(bake_path);
257 return finalize_on_success();
260 return finalize_on_success();
264 return finalize_on_success();
Functions and classes for evaluating template expressions in filepaths.
File and directory operations.
#define BLI_SCOPED_DEFER(function_to_defer)
#define BLI_path_join(...)
#define FILENAME_IS_CURRPAR(_n)
#define ID_BLEND_PATH(_bmain, _id)
Object is a sort of wrapper for general info.
constexpr IndexRange()=default
constexpr const char * c_str() const
static bool disk_bake_exists(const bke::bake::BakePath &path)
std::optional< BakePath > get_node_bake_path(const Main &bmain, const Object &object, const NodesModifierData &nmd, int node_id)
bool unpack_bake_to_disk(const NodesModifierPackedBake &packed_bake, const BakePath &bake_path, ReportList *reports)
PackGeometryNodesBakeResult
NodesModifierPackedBake * pack_bake_from_disk(const BakePath &bake_path, ReportList *reports)
UnpackGeometryNodesBakeResult unpack_geometry_nodes_bake(Main &bmain, ReportList *reports, Object &object, NodesModifierData &nmd, NodesModifierBake &bake, ePF_FileStatus how)
PackGeometryNodesBakeResult pack_geometry_nodes_bake(Main &bmain, ReportList *reports, Object &object, NodesModifierData &nmd, NodesModifierBake &bake)
UnpackGeometryNodesBakeResult
static Vector< NodesModifierBakeFile > pack_files_from_directory(const StringRefNull directory, ReportList *reports)
static bool directory_is_empty(const StringRefNull path)
std::string get_default_node_bake_directory(const Main &bmain, const Object &object, const NodesModifierData &nmd, int node_id)
char * STRNCPY(char(&dst)[N], const char *src)
@ NODES_MODIFIER_BAKE_CUSTOM_PATH
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist)
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
std::string BKE_path_template_escape(StringRef text)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
@ NODES_MODIFIER_BAKE_TARGET_PACKED
@ NODES_MODIFIER_BAKE_TARGET_DISK
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
void nodes_modifier_packed_bake_free(NodesModifierPackedBake *packed_bake)
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
void uninitialized_copy_n(const T *src, int64_t n, T *dst)
NodesModifierRuntime * runtime
NodesModifierBakeFile * blob_files
NodesModifierBakeFile * meta_files
std::shared_ptr< bke::bake::ModifierCache > cache
static BakePath from_single_root(StringRefNull root_dir)