1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 17 * All rights reserved. 18 */ 19 #pragma once 20 21 /** \file 22 * \ingroup bke 23 */ 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define RET_OK 0 30 #define RET_ERROR 1 31 32 struct BlendDataReader; 33 struct BlendWriter; 34 struct ID; 35 struct Image; 36 struct Main; 37 struct PackedFile; 38 struct ReportList; 39 struct VFont; 40 struct Volume; 41 struct bSound; 42 43 enum ePF_FileCompare { 44 PF_CMP_EQUAL = 0, 45 PF_CMP_DIFFERS = 1, 46 PF_CMP_NOFILE = 2, 47 }; 48 49 enum ePF_FileStatus { 50 PF_WRITE_ORIGINAL = 3, 51 PF_WRITE_LOCAL = 4, 52 PF_USE_LOCAL = 5, 53 PF_USE_ORIGINAL = 6, 54 PF_KEEP = 7, 55 PF_REMOVE = 8, 56 57 PF_ASK = 10, 58 }; 59 60 /* pack */ 61 struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src); 62 struct PackedFile *BKE_packedfile_new(struct ReportList *reports, 63 const char *filename, 64 const char *basepath); 65 struct PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen); 66 67 void BKE_packedfile_pack_all(struct Main *bmain, struct ReportList *reports, bool verbose); 68 void BKE_packedfile_pack_all_libraries(struct Main *bmain, struct ReportList *reports); 69 70 /* unpack */ 71 char *BKE_packedfile_unpack_to_file(struct ReportList *reports, 72 const char *ref_file_name, 73 const char *abs_name, 74 const char *local_name, 75 struct PackedFile *pf, 76 enum ePF_FileStatus how); 77 int BKE_packedfile_unpack_vfont(struct Main *bmain, 78 struct ReportList *reports, 79 struct VFont *vfont, 80 enum ePF_FileStatus how); 81 int BKE_packedfile_unpack_sound(struct Main *bmain, 82 struct ReportList *reports, 83 struct bSound *sound, 84 enum ePF_FileStatus how); 85 int BKE_packedfile_unpack_image(struct Main *bmain, 86 struct ReportList *reports, 87 struct Image *ima, 88 enum ePF_FileStatus how); 89 int BKE_packedfile_unpack_volume(struct Main *bmain, 90 struct ReportList *reports, 91 struct Volume *volume, 92 enum ePF_FileStatus how); 93 void BKE_packedfile_unpack_all(struct Main *bmain, 94 struct ReportList *reports, 95 enum ePF_FileStatus how); 96 int BKE_packedfile_unpack_all_libraries(struct Main *bmain, struct ReportList *reports); 97 98 int BKE_packedfile_write_to_file(struct ReportList *reports, 99 const char *ref_file_name, 100 const char *filename, 101 struct PackedFile *pf, 102 const bool guimode); 103 104 /* free */ 105 void BKE_packedfile_free(struct PackedFile *pf); 106 107 /* info */ 108 int BKE_packedfile_count_all(struct Main *bmain); 109 enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, 110 const char *filename, 111 struct PackedFile *pf); 112 113 /* read */ 114 int BKE_packedfile_seek(struct PackedFile *pf, int offset, int whence); 115 void BKE_packedfile_rewind(struct PackedFile *pf); 116 int BKE_packedfile_read(struct PackedFile *pf, void *data, int size); 117 118 /* ID should be not NULL, return 1 if there's a packed file */ 119 bool BKE_packedfile_id_check(struct ID *id); 120 /* ID should be not NULL, throws error when ID is Library */ 121 void BKE_packedfile_id_unpack(struct Main *bmain, 122 struct ID *id, 123 struct ReportList *reports, 124 enum ePF_FileStatus how); 125 126 void BKE_packedfile_blend_write(struct BlendWriter *writer, struct PackedFile *pf); 127 void BKE_packedfile_blend_read(struct BlendDataReader *reader, struct PackedFile **pf_p); 128 129 #ifdef __cplusplus 130 } 131 #endif 132