60 int oldseek = -1, seek = 0;
66 seek = oldseek + offset;
69 seek =
pf->size + offset;
81 else if (seek >
pf->size) {
97 if ((
pf !=
nullptr) && (size >= 0) && (data !=
nullptr)) {
98 if (size +
pf->seek >
pf->size) {
99 size =
pf->size -
pf->seek;
103 memcpy(data, ((
const char *)
pf->data) +
pf->seek, size);
138 count.individual_files++;
146 count.individual_files++;
151 volume =
static_cast<Volume *
>(volume->id.next))
154 count.individual_files++;
183 pf->sharing_info->remove_user_and_delete_if_last();
187 printf(
"%s: Trying to free a nullptr pointer\n", __func__);
217 pf->sharing_info = sharing_info;
228 if (filepath_rel[0] ==
'\0') {
236 STRNCPY(filepath, filepath_rel);
250 if (file_size ==
size_t(-1)) {
253 else if (file_size > INT_MAX) {
259 void *data =
MEM_mallocN(std::max(file_size,
size_t(1)),
"packFile");
260 if (
BLI_read(file, data, file_size) == file_size) {
294 "Image '%s' skipped, packing movies or image sequences not supported",
323 volume =
static_cast<Volume *
>(volume->id.next))
355 const char *ref_file_name,
356 const char *filepath_rel,
361 bool remove_tmp =
false;
366 STRNCPY(filepath, filepath_rel);
370 for (number = 1; number <= 999; number++) {
371 SNPRINTF(filepath_temp,
"%s.%03d_", filepath, number);
389 if (write(file,
pf->data,
pf->size) !=
pf->size) {
405 "Error restoring temp file (check files '%s' '%s')",
411 if (
BLI_delete(filepath_temp,
false,
false) != 0) {
421 const char *filepath_rel,
429 STRNCPY(filepath, filepath_rel);
432 if (
BLI_stat(filepath, &st) == -1) {
435 else if (st.st_size !=
pf->size) {
448 for (
int i = 0; i <
pf->size; i +=
sizeof(buf)) {
449 int len =
pf->size - i;
450 if (
len >
sizeof(buf)) {
460 if (memcmp(buf, ((
const char *)
pf->data) + i,
len) != 0) {
474 const char *ref_file_name,
475 const char *abs_name,
476 const char *local_name,
480 char *newname =
nullptr;
481 const char *temp =
nullptr;
530 printf(
"%s: unknown return_value %d\n", __func__, how);
545 size_t abspath_maxncpy,
547 size_t relpath_maxncpy)
549 const short id_type =
GS(id->name);
554 filepath, temp_dirname,
sizeof(temp_dirname), temp_filename,
sizeof(temp_filename));
556 if (temp_filename[0] ==
'\0') {
559 printf(
"%s\n", temp_filename);
563 if (id_type ==
ID_IM) {
566 if (imapf !=
nullptr && imapf->
packedfile !=
nullptr) {
583 printf(
"%s\n", temp_filename);
586 if (temp_dirname[0] ==
'\0') {
592 const char *dir_name =
nullptr;
601 dir_name =
"textures";
604 dir_name =
"volumes";
610 BLI_path_join(r_relpath, relpath_maxncpy,
"//", dir_name, temp_filename);
623 const char *orig_file_path,
628 char *new_name =
nullptr;
632 orig_file_path,
id, absname,
sizeof(absname), localname,
sizeof(localname));
648 bmain, reports, (
ID *)vfont, vfont->filepath, vfont->packedfile, how);
650 if (new_file_path !=
nullptr) {
653 vfont->packedfile =
nullptr;
654 STRNCPY(vfont->filepath, new_file_path);
669 if (sound !=
nullptr) {
671 bmain, reports, (
ID *)sound, sound->filepath, sound->packedfile, how);
672 if (new_file_path !=
nullptr) {
673 STRNCPY(sound->filepath, new_file_path);
677 sound->packedfile =
nullptr;
695 if (ima !=
nullptr) {
701 if (new_file_path !=
nullptr) {
717 STRNCPY(ima->filepath, new_file_path);
734 if (ret_value ==
RET_OK) {
748 if (volume !=
nullptr) {
750 bmain, reports, (
ID *)volume, volume->filepath, volume->packedfile, how);
751 if (new_file_path !=
nullptr) {
752 STRNCPY(volume->filepath, new_file_path);
756 volume->packedfile =
nullptr;
776 if (
lib->packedfile &&
lib->filepath[0]) {
780 lib->runtime.filepath_abs,
781 lib->runtime.filepath_abs,
784 if (newname !=
nullptr) {
787 printf(
"Unpacked .blend library: %s\n", newname);
790 lib->packedfile =
nullptr;
821 if (
lib->packedfile ==
nullptr) {
857 volume =
static_cast<Volume *
>(volume->id.next))
873 *bmain, reports, *
object, *nmd,
bake, how);
882 switch (
GS(id->name)) {
916 switch (
GS(id->name)) {
940 if (volume->packedfile) {
962 BLO_write_raw(writer, pf->size, pf->data);
975 BLO_read_data_address(reader, &pf->data);
977 return pf->data ? blender::implicit_sharing::info_for_mem_free(const_cast<void *>(pf->data)) :
980 if (
pf->data ==
nullptr) {
984 "%s: nullptr packedfile data (source: '%s'), cleaning up...",
void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
void BKE_image_ensure_tile_token(char *filepath, size_t filepath_maxncpy)
#define IMA_SIGNAL_RELOAD
bool BKE_image_has_packedfile(const Image *image)
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_sound_load(struct Main *bmain, struct bSound *sound)
bool BKE_vfont_is_builtin(const VFont *vfont)
void BKE_volume_unload(Volume *volume)
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_copy(const char *path_src, const char *path_dst) ATTR_NONNULL()
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
int BLI_rename_overwrite(const char *from, const char *to) ATTR_NONNULL()
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int64_t BLI_read(int fd, void *buf, size_t nbytes)
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
#define BLI_path_join(...)
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
bool BLI_path_make_safe_filename(char *filename) ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
#define STRNCPY_RLEN(dst, src)
#define SNPRINTF(dst, format,...)
char char size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define BLO_write_struct(writer, struct_name, data_ptr)
#define BLO_read_struct(reader, struct_name, ptr_p)
void BLO_write_shared(BlendWriter *writer, const void *data, size_t approximate_size_in_bytes, const blender::ImplicitSharingInfo *sharing_info, blender::FunctionRef< void()> write_fn)
const blender::ImplicitSharingInfo * BLO_read_shared(BlendDataReader *reader, T **data_ptr, blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn)
#define CLOG_WARN(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_LINKED(_id)
#define ID_BLEND_PATH(_bmain, _id)
#define ID_IS_EDITABLE(_id)
int IMB_ispic_type_from_memory(const unsigned char *buf, size_t buf_size)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
constexpr const char * c_str() const
#define pf(_x, _i)
Prefetch 64.
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
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)
const ImplicitSharingInfo * info_for_mem_free(void *data)
int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
PackedFile * BKE_packedfile_duplicate(const PackedFile *pf_src)
void BKE_packedfile_free(PackedFile *pf)
PackedFileCount BKE_packedfile_count_all(Main *bmain)
PackedFile * BKE_packedfile_new_from_memory(const void *mem, int memlen, const blender::ImplicitSharingInfo *sharing_info)
void BKE_packedfile_blend_read(BlendDataReader *reader, PackedFile **pf_p, StringRefNull filepath)
bool BKE_packedfile_id_check(const ID *id)
int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound, enum ePF_FileStatus how)
void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileStatus how)
void BKE_packedfile_pack_all_libraries(Main *bmain, ReportList *reports)
int BKE_packedfile_read(PackedFile *pf, void *data, int size)
int BKE_packedfile_unpack_image(Main *bmain, ReportList *reports, Image *ima, enum ePF_FileStatus how)
char * BKE_packedfile_unpack_to_file(ReportList *reports, const char *ref_file_name, const char *abs_name, const char *local_name, PackedFile *pf, enum ePF_FileStatus how)
int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont, enum ePF_FileStatus how)
void BKE_packedfile_blend_write(BlendWriter *writer, const PackedFile *pf)
char * BKE_packedfile_unpack(Main *bmain, ReportList *reports, ID *id, const char *orig_file_path, PackedFile *pf, enum ePF_FileStatus how)
void BKE_packedfile_rewind(PackedFile *pf)
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath)
static void unpack_generate_paths(const char *filepath, ID *id, char *r_abspath, size_t abspath_maxncpy, char *r_relpath, size_t relpath_maxncpy)
int BKE_packedfile_write_to_file(ReportList *reports, const char *ref_file_name, const char *filepath_rel, PackedFile *pf)
int BKE_packedfile_unpack_volume(Main *bmain, ReportList *reports, Volume *volume, enum ePF_FileStatus how)
enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, const char *filepath_rel, const PackedFile *pf)
void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF_FileStatus how)
struct PackedFile * packedfile
struct ListBase packedfiles
struct PackedFile * packedfile
NodesModifierBake * bakes
const ImplicitSharingInfoHandle * sharing_info
struct PackedFile * packedfile
struct PackedFile * packedfile
struct PackedFile * packedfile
static DynamicLibrary lib