Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BKE_packedFile.h « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 87a46f5f8884dcec690a9b71ba960660ef3fa398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 */
#pragma once

/** \file
 * \ingroup bke
 */

#ifdef __cplusplus
extern "C" {
#endif

#define RET_OK 0
#define RET_ERROR 1

struct BlendDataReader;
struct BlendWriter;
struct ID;
struct Image;
struct Main;
struct PackedFile;
struct ReportList;
struct VFont;
struct Volume;
struct bSound;

enum ePF_FileCompare {
  PF_CMP_EQUAL = 0,
  PF_CMP_DIFFERS = 1,
  PF_CMP_NOFILE = 2,
};

enum ePF_FileStatus {
  PF_WRITE_ORIGINAL = 3,
  PF_WRITE_LOCAL = 4,
  PF_USE_LOCAL = 5,
  PF_USE_ORIGINAL = 6,
  PF_KEEP = 7,
  PF_REMOVE = 8,

  PF_ASK = 10,
};

/* Pack. */

struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src);
struct PackedFile *BKE_packedfile_new(struct ReportList *reports,
                                      const char *filename,
                                      const char *basepath);
struct PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen);

/**
 * No libraries for now.
 */
void BKE_packedfile_pack_all(struct Main *bmain, struct ReportList *reports, bool verbose);
void BKE_packedfile_pack_all_libraries(struct Main *bmain, struct ReportList *reports);

/* Unpack. */

/**
 * #BKE_packedfile_unpack_to_file() looks at the existing files (abs_name, local_name)
 * and a packed file.
 *
 * It returns a char *to the existing file name / new file name or NULL when
 * there was an error or when the user decides to cancel the operation.
 *
 * \warning 'abs_name' may be relative still! (use a "//" prefix)
 * be sure to run #BLI_path_abs on it first.
 */
char *BKE_packedfile_unpack_to_file(struct ReportList *reports,
                                    const char *ref_file_name,
                                    const char *abs_name,
                                    const char *local_name,
                                    struct PackedFile *pf,
                                    enum ePF_FileStatus how);
char *BKE_packedfile_unpack(struct Main *bmain,
                            struct ReportList *reports,
                            struct ID *id,
                            const char *orig_file_path,
                            struct PackedFile *pf,
                            enum ePF_FileStatus how);
int BKE_packedfile_unpack_vfont(struct Main *bmain,
                                struct ReportList *reports,
                                struct VFont *vfont,
                                enum ePF_FileStatus how);
int BKE_packedfile_unpack_sound(struct Main *bmain,
                                struct ReportList *reports,
                                struct bSound *sound,
                                enum ePF_FileStatus how);
int BKE_packedfile_unpack_image(struct Main *bmain,
                                struct ReportList *reports,
                                struct Image *ima,
                                enum ePF_FileStatus how);
int BKE_packedfile_unpack_volume(struct Main *bmain,
                                 struct ReportList *reports,
                                 struct Volume *volume,
                                 enum ePF_FileStatus how);
void BKE_packedfile_unpack_all(struct Main *bmain,
                               struct ReportList *reports,
                               enum ePF_FileStatus how);
int BKE_packedfile_unpack_all_libraries(struct Main *bmain, struct ReportList *reports);

int BKE_packedfile_write_to_file(struct ReportList *reports,
                                 const char *ref_file_name,
                                 const char *filename,
                                 struct PackedFile *pf,
                                 bool guimode);

/* Free. */

void BKE_packedfile_free(struct PackedFile *pf);

/* Info. */

int BKE_packedfile_count_all(struct Main *bmain);
/**
 * This function compares a packed file to a 'real' file.
 * It returns an integer indicating if:
 *
 * - #PF_EQUAL:     the packed file and original file are identical.
 * - #PF_DIFFERENT: the packed file and original file differ.
 * - #PF_NOFILE:    the original file doesn't exist.
 */
enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
                                                    const char *filename,
                                                    struct PackedFile *pf);

/* Read. */

int BKE_packedfile_seek(struct PackedFile *pf, int offset, int whence);
void BKE_packedfile_rewind(struct PackedFile *pf);
int BKE_packedfile_read(struct PackedFile *pf, void *data, int size);

/**
 * ID should be not NULL, return true if there's a packed file.
 */
bool BKE_packedfile_id_check(const struct ID *id);
/**
 * ID should be not NULL, throws error when ID is Library.
 */
void BKE_packedfile_id_unpack(struct Main *bmain,
                              struct ID *id,
                              struct ReportList *reports,
                              enum ePF_FileStatus how);

void BKE_packedfile_blend_write(struct BlendWriter *writer, struct PackedFile *pf);
void BKE_packedfile_blend_read(struct BlendDataReader *reader, struct PackedFile **pf_p);

#ifdef __cplusplus
}
#endif