36 for (
const int i :
IndexRange(dir_entries_num)) {
37 const direntry &dir_entry = dir_entries[i];
44 bake_files.append(bake_file);
88 fstream fs(file_path, std::ios::out);
89 fs.write(
static_cast<const char *
>(bake_file.packed_file->data), bake_file.packed_file->size);
100 if (!unpack_file(bake_path.
meta_dir, bake_file)) {
107 if (!unpack_file(bake_path.
blobs_dir, bake_file)) {
142 return entries_num == 0;
161 BKE_report(reports,
RPT_ERROR,
"Can only unpack bake if the current .blend file is saved");
167 auto prepare_local_path = [&]() {
169 bmain,
object, nmd,
bake.id);
175 STRNCPY(absolute_dir, directory.c_str());
179 auto prepare_original_path = [&]() {
181 bmain,
object, nmd,
bake.id))
185 return prepare_local_path();
188 BLI_delete(bake_path.meta_dir.c_str(),
true,
true);
189 BLI_delete(bake_path.blobs_dir.c_str(),
true,
true);
191 auto free_packed_bake = [&]() {
193 bake.packed =
nullptr;
196 auto finalize_on_success = [&]() {
205 delete_bake_on_disk(bake_path);
211 return finalize_on_success();
215 delete_bake_on_disk(bake_path);
220 return finalize_on_success();
225 delete_bake_on_disk(bake_path);
231 return finalize_on_success();
235 delete_bake_on_disk(bake_path);
240 return finalize_on_success();
243 return finalize_on_success();
247 return finalize_on_success();
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist)
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()
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
File and directory operations.
#define BLI_SCOPED_DEFER(function_to_defer)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
#define BLI_path_join(...)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
void DEG_id_tag_update(ID *id, unsigned int flags)
#define ID_BLEND_PATH(_bmain, _id)
@ NODES_MODIFIER_BAKE_TARGET_PACKED
@ NODES_MODIFIER_BAKE_TARGET_DISK
@ NODES_MODIFIER_BAKE_CUSTOM_PATH
constexpr const char * c_str() const
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)
static bool directory_is_empty(const blender::StringRefNull path)
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 disk_bake_exists(const blender::bke::bake::BakePath &path)
std::string get_default_node_bake_directory(const Main &bmain, const Object &object, const NodesModifierData &nmd, int node_id)
void nodes_modifier_packed_bake_free(NodesModifierPackedBake *packed_bake)
void uninitialized_copy_n(const T *src, int64_t n, T *dst)
NodesModifierRuntimeHandle * runtime
NodesModifierBakeFile * meta_files
NodesModifierBakeFile * blob_files
static BakePath from_single_root(StringRefNull root_dir)