46 int oldseek = -1, seek = 0;
67 else if (seek >
pf->size) {
149 printf(
"%s: Trying to free a NULL pointer\n", __func__);
186 if (filepath[0] ==
'\0') {
215 if (read(
file,
data, filelen) == filelen) {
247 "Image '%s' skipped, packing movies or image sequences not supported",
287 const char *ref_file_name,
288 const char *filepath,
294 bool remove_tmp =
false;
306 for (number = 1; number <= 999; number++) {
307 BLI_snprintf(tempname,
sizeof(tempname),
"%s.%03d_", name, number);
326 if (write(
file,
pf->data,
pf->size) !=
pf->size) {
342 "Error restoring temp file (check files '%s' '%s')",
348 if (
BLI_delete(tempname,
false,
false) != 0) {
361 const char *filepath,
375 else if (
st.st_size !=
pf->size) {
388 for (
int i = 0; i <
pf->size; i +=
sizeof(buf)) {
389 int len =
pf->size - i;
390 if (
len >
sizeof(buf)) {
400 if (memcmp(buf, ((
char *)
pf->data) + i,
len) != 0) {
414 const char *ref_file_name,
415 const char *abs_name,
416 const char *local_name,
420 char *newname =
NULL;
421 const char *temp =
NULL;
433 BLI_strncpy(temp_abs, local_name,
sizeof(temp_abs));
470 printf(
"%s: unknown return_value %u\n", __func__, how);
495 if (tempname[0] ==
'\0') {
498 printf(
"%s\n", tempname);
502 if (id_type ==
ID_IM) {
521 printf(
"%s\n", tempname);
524 if (tempdir[0] ==
'\0') {
531 BLI_snprintf(r_relpath, relpathlen,
"//fonts/%s", tempname);
534 BLI_snprintf(r_relpath, relpathlen,
"//sounds/%s", tempname);
537 BLI_snprintf(r_relpath, relpathlen,
"//textures/%s", tempname);
540 BLI_snprintf(r_relpath, relpathlen,
"//volumes/%s", tempname);
555 const char *orig_file_path,
560 char *new_name =
NULL;
564 orig_file_path,
id, absname, localname,
sizeof(absname),
sizeof(localname));
580 bmain, reports, (
ID *)vfont, vfont->filepath, vfont->packedfile, how);
582 if (new_file_path !=
NULL) {
585 vfont->packedfile =
NULL;
586 BLI_strncpy(vfont->filepath, new_file_path,
sizeof(vfont->filepath));
603 bmain, reports, (
ID *)sound, sound->filepath, sound->packedfile, how);
604 if (new_file_path !=
NULL) {
605 BLI_strncpy(sound->filepath, new_file_path,
sizeof(sound->filepath));
609 sound->packedfile =
NULL;
633 if (new_file_path !=
NULL) {
666 if (ret_value ==
RET_OK) {
680 if (volume !=
NULL) {
682 bmain, reports, (
ID *)volume, volume->filepath, volume->packedfile, how);
683 if (new_file_path !=
NULL) {
684 BLI_strncpy(volume->filepath, new_file_path,
sizeof(volume->filepath));
688 volume->packedfile =
NULL;
706 if (
lib->packedfile &&
lib->filepath[0]) {
714 if (newname !=
NULL) {
717 printf(
"Unpacked .blend library: %s\n", newname);
876 printf(
"%s: NULL packedfile data, cleaning up...\n", __func__);
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath)
bool BKE_image_has_packedfile(const struct Image *image)
void BKE_image_ensure_tile_token(char *filename)
#define IMA_SIGNAL_RELOAD
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
const char * BKE_main_blendfile_path(const struct 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 *main, struct bSound *sound)
bool BKE_vfont_is_builtin(const struct VFont *vfont)
void BKE_volume_unload(struct Volume *volume)
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT 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 *file, bool dir, bool recursive) ATTR_NONNULL()
int BLI_rename(const char *from, const char *to) ATTR_NONNULL()
int BLI_copy(const char *file, const char *to) ATTR_NONNULL()
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
const char * BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_make_existing_file(const char *name)
void BLI_split_dirfile(const char *string, char *dir, char *file, size_t dirlen, size_t filelen)
bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1)
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define BLO_read_packed_address(reader, ptr_p)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_write_raw(BlendWriter *writer, size_t size_in_bytes, const void *data_ptr)
ID and Library types, which are fundamental for sdna.
#define ID_IS_LINKED(_id)
#define ID_BLEND_PATH(_bmain, _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)
struct ListBase packedfiles
#define pf(_x, _i)
Prefetch 64.
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
void BKE_packedfile_blend_write(BlendWriter *writer, PackedFile *pf)
void BKE_packedfile_free(PackedFile *pf)
int BKE_packedfile_count_all(Main *bmain)
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filepath, const char *basepath)
static void unpack_generate_paths(const char *name, ID *id, char *r_abspath, char *r_relpath, size_t abspathlen, size_t relpathlen)
bool BKE_packedfile_id_check(const ID *id)
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)
void BKE_packedfile_blend_read(BlendDataReader *reader, PackedFile **pf_p)
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)
enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, const char *filepath, PackedFile *pf)
int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont, enum ePF_FileStatus how)
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_write_to_file(ReportList *reports, const char *ref_file_name, const char *filepath, PackedFile *pf, const bool guimode)
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
PackedFile * BKE_packedfile_duplicate(const PackedFile *pf_src)
int BKE_packedfile_unpack_volume(Main *bmain, ReportList *reports, Volume *volume, enum ePF_FileStatus how)
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)
PackedFile * BKE_packedfile_new_from_memory(void *mem, int memlen)
struct PackedFile * packedfile
struct PackedFile * packedfile
struct PackedFile * packedfile
struct PackedFile * packedfile
struct PackedFile * packedfile