4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
28 * external readfile function prototypes
30 #ifndef BLO_READFILE_H
31 #define BLO_READFILE_H
49 typedef struct BlendHandle BlendHandle;
51 typedef enum BlenFileType {
52 BLENFILETYPE_BLEND= 1,
54 BLENFILETYPE_RUNTIME= 3
57 typedef struct BlendFileData {
65 char filename[240]; /* 240 = FILE_MAX */
67 struct bScreen* curscreen;
68 struct Scene* curscene;
74 * Open a blender file from a pathname. The function
75 * returns NULL and sets a report in the list if
76 * it cannot open the file.
78 * @param file The path of the file to open.
79 * @param reports If the return value is NULL, errors
80 * indicating the cause of the failure.
81 * @return The data of the file.
83 BlendFileData* BLO_read_from_file(const char *file, struct ReportList *reports);
86 * Open a blender file from memory. The function
87 * returns NULL and sets a report in the list if
88 * it cannot open the file.
90 * @param mem The file data.
91 * @param memsize The length of @a mem.
92 * @param reports If the return value is NULL, errors
93 * indicating the cause of the failure.
94 * @return The data of the file.
96 BlendFileData* BLO_read_from_memory(void *mem, int memsize, struct ReportList *reports);
99 * oldmain is old main, from which we will keep libraries, images, ..
100 * file name is current file, only for retrieving library data */
102 BlendFileData *BLO_read_from_memfile(struct Main *oldmain, const char *filename, struct MemFile *memfile, struct ReportList *reports);
105 * Free's a BlendFileData structure and _all_ the
106 * data associated with it (the userdef data, and
107 * the main libblock data).
109 * @param bfd The structure to free.
112 BLO_blendfiledata_free(
116 * Open a blendhandle from a file path.
118 * @param file The file path to open.
119 * @return A handle on success, or NULL on failure.
122 BLO_blendhandle_from_file(
126 * Open a blendhandle from memory.
128 * @param mem The data to load from.
129 * @param memsize The size of the data.
130 * @return A handle on success, or NULL on failure.
134 BLO_blendhandle_from_memory(
139 * Gets the names of all the datablocks in a file
140 * of a certain type (ie. All the scene names in
143 * @param bh The blendhandle to access.
144 * @param ofblocktype The type of names to get.
145 * @return A BLI_linklist of strings. The string links
146 * should be freed with malloc.
149 BLO_blendhandle_get_datablock_names(
154 * Gets the previews of all the datablocks in a file
155 * of a certain type (ie. All the scene names in
158 * @param bh The blendhandle to access.
159 * @param ofblocktype The type of names to get.
160 * @return A BLI_linklist of PreviewImage. The PreviewImage links
161 * should be freed with malloc.
164 BLO_blendhandle_get_previews(
169 * Gets the names of all the datablock groups in a
170 * file. (ie. file contains Scene, Mesh, and Lamp
173 * @param bh The blendhandle to access.
174 * @return A BLI_linklist of strings. The string links
175 * should be freed with malloc.
178 BLO_blendhandle_get_linkable_groups(
182 * Close and free a blendhandle. The handle
183 * becomes invalid after this call.
185 * @param bh The handle to close.
188 BLO_blendhandle_close(
195 int BLO_has_bfile_extension(char *str);
197 /* return ok when a blenderfile, in dir is the filename,
198 * in group the type of libdata
200 int BLO_is_a_library(const char *path, char *dir, char *group);
202 struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, char *dir);
203 void BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag);
204 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag);
208 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
211 BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);