61 int oldseek = -1, seek = 0;
67 seek = oldseek + offset;
70 seek =
pf->size + offset;
82 else if (seek >
pf->size) {
164 printf(
"%s: Trying to free a NULL pointer\n", __func__);
201 if (filename[0] ==
'\0') {
230 if (read(
file,
data, filelen) == filelen) {
263 "Image '%s' skipped, movies, image sequences and packed files not supported",
303 const char *ref_file_name,
304 const char *filename,
310 bool remove_tmp =
false;
322 for (number = 1; number <= 999; number++) {
323 BLI_snprintf(tempname,
sizeof(tempname),
"%s.%03d_", name, number);
342 if (write(
file,
pf->data,
pf->size) !=
pf->size) {
358 "Error restoring temp file (check files '%s' '%s')",
364 if (
BLI_delete(tempname,
false,
false) != 0) {
385 const char *filename,
399 else if (st.st_size !=
pf->size) {
412 for (
int i = 0; i <
pf->size; i +=
sizeof(buf)) {
413 int len =
pf->size - i;
414 if (
len >
sizeof(buf)) {
424 if (memcmp(buf, ((
char *)
pf->data) + i,
len) != 0) {
448 const char *ref_file_name,
449 const char *abs_name,
450 const char *local_name,
454 char *newname =
NULL;
455 const char *temp =
NULL;
467 BLI_strncpy(temp_abs, local_name,
sizeof(temp_abs));
504 printf(
"%s: unknown return_value %u\n", __func__, how);
529 if (tempname[0] ==
'\0') {
532 printf(
"%s\n", tempname);
535 if (id_type ==
ID_IM) {
548 printf(
"%s\n", tempname);
551 if (tempdir[0] ==
'\0') {
558 BLI_snprintf(r_relpath, relpathlen,
"//fonts/%s", tempname);
561 BLI_snprintf(r_relpath, relpathlen,
"//sounds/%s", tempname);
564 BLI_snprintf(r_relpath, relpathlen,
"//textures/%s", tempname);
567 BLI_snprintf(r_relpath, relpathlen,
"//volumes/%s", tempname);
590 vfont->
filepath, (
ID *)vfont, absname, localname,
sizeof(absname),
sizeof(localname));
593 if (newname !=
NULL) {
596 vfont->packedfile =
NULL;
597 BLI_strncpy(vfont->filepath, newname,
sizeof(vfont->filepath));
616 sound->
filepath, (
ID *)sound, absname, localname,
sizeof(absname),
sizeof(localname));
619 if (newname !=
NULL) {
620 BLI_strncpy(sound->filepath, newname,
sizeof(sound->filepath));
624 sound->packedfile =
NULL;
649 imapf->
filepath, (
ID *)ima, absname, localname,
sizeof(absname),
sizeof(localname));
653 if (newname !=
NULL) {
681 if (ret_value ==
RET_OK) {
697 if (volume !=
NULL) {
699 volume->
filepath, (
ID *)volume, absname, localname,
sizeof(absname),
sizeof(localname));
702 if (newfilepath !=
NULL) {
703 BLI_strncpy(volume->filepath, newfilepath,
sizeof(volume->filepath));
707 volume->packedfile =
NULL;
725 if (
lib->packedfile &&
lib->filepath[0]) {
733 if (newname !=
NULL) {
736 printf(
"Unpacked .blend library: %s\n", newname);
897 printf(
"%s: NULL packedfile data, cleaning up...\n", __func__);
bool BKE_vfont_is_builtin(struct VFont *vfont)
bool BKE_image_has_packedfile(struct Image *image)
char BKE_image_ftype_to_imtype(const int ftype, const struct ImbFormatOptions *options)
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath)
#define IMA_SIGNAL_RELOAD
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
bool BKE_image_has_multiple_ibufs(struct Image *image)
int BKE_image_path_ensure_ext_from_imtype(char *string, const char imtype)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
void BKE_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_sound_load(struct Main *main, struct bSound *sound)
void BKE_volume_unload(struct Volume *volume)
int BLI_open(const char *filename, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
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()
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_make_existing_file(const char *name)
bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1)
void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen)
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#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, const 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.
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)
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filename, const char *basepath)
enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, const char *filename, PackedFile *pf)
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)
static void unpack_generate_paths(const char *name, ID *id, char *r_abspath, char *r_relpath, size_t abspathlen, size_t relpathlen)
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_write_to_file(ReportList *reports, const char *ref_file_name, const char *filename, PackedFile *pf, const bool guimode)
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)
int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont, enum ePF_FileStatus how)
void BKE_packedfile_rewind(PackedFile *pf)
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
bool BKE_packedfile_id_check(ID *id)
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