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 *****
29 #ifndef BLO_READFILE_H
30 #define BLO_READFILE_H
32 /** \file BLO_readfile.h
34 * \brief external readfile function prototypes.
55 typedef struct BlendHandle BlendHandle;
57 typedef enum BlenFileType {
58 BLENFILETYPE_BLEND= 1,
60 BLENFILETYPE_RUNTIME= 3
63 typedef struct BlendFileData {
71 char filename[240]; /* 240 = FILE_MAX */
73 struct bScreen* curscreen;
74 struct Scene* curscene;
80 * Open a blender file from a pathname. The function
81 * returns NULL and sets a report in the list if
82 * it cannot open the file.
84 * @param filepath The path of the file to open.
85 * @param reports If the return value is NULL, errors
86 * indicating the cause of the failure.
87 * @return The data of the file.
89 BlendFileData* BLO_read_from_file(const char *filepath, struct ReportList *reports);
92 * Open a blender file from memory. The function
93 * returns NULL and sets a report in the list if
94 * it cannot open the file.
96 * @param mem The file data.
97 * @param memsize The length of @a mem.
98 * @param reports If the return value is NULL, errors
99 * indicating the cause of the failure.
100 * @return The data of the file.
102 BlendFileData* BLO_read_from_memory(void *mem, int memsize, struct ReportList *reports);
105 * oldmain is old main, from which we will keep libraries, images, ..
106 * file name is current file, only for retrieving library data */
108 BlendFileData *BLO_read_from_memfile(struct Main *oldmain, const char *filename, struct MemFile *memfile, struct ReportList *reports);
111 * Free's a BlendFileData structure and _all_ the
112 * data associated with it (the userdef data, and
113 * the main libblock data).
115 * @param bfd The structure to free.
118 BLO_blendfiledata_free(
122 * Open a blendhandle from a file path.
124 * @param file The file path to open.
125 * @param reports Report errors in opening the file (can be NULL).
126 * @return A handle on success, or NULL on failure.
129 BLO_blendhandle_from_file(
131 struct ReportList *reports);
134 * Open a blendhandle from memory.
136 * @param mem The data to load from.
137 * @param memsize The size of the data.
138 * @return A handle on success, or NULL on failure.
142 BLO_blendhandle_from_memory(
147 * Gets the names of all the datablocks in a file
148 * of a certain type (ie. All the scene names in
151 * @param bh The blendhandle to access.
152 * @param ofblocktype The type of names to get.
153 * @param tot_names The length of the returned list.
154 * @return A BLI_linklist of strings. The string links
155 * should be freed with malloc.
158 BLO_blendhandle_get_datablock_names(
164 * Gets the previews of all the datablocks in a file
165 * of a certain type (ie. All the scene names in
168 * @param bh The blendhandle to access.
169 * @param ofblocktype The type of names to get.
170 * @param tot_prev The length of the returned list.
171 * @return A BLI_linklist of PreviewImage. The PreviewImage links
172 * should be freed with malloc.
175 BLO_blendhandle_get_previews(
181 * Gets the names of all the datablock groups in a
182 * file. (ie. file contains Scene, Mesh, and Lamp
185 * @param bh The blendhandle to access.
186 * @return A BLI_linklist of strings. The string links
187 * should be freed with malloc.
190 BLO_blendhandle_get_linkable_groups(
194 * Close and free a blendhandle. The handle
195 * becomes invalid after this call.
197 * @param bh The handle to close.
200 BLO_blendhandle_close(
207 int BLO_has_bfile_extension(char *str);
209 /* return ok when a blenderfile, in dir is the filename,
210 * in group the type of libdata
212 int BLO_is_a_library(const char *path, char *dir, char *group);
214 struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath);
217 * Link/Append a named datablock from an external blend file.
219 * @param C The context, when NULL instancing object in the scene isnt done.
220 * @param mainl The main database to link from (not the active one).
221 * @param bh The blender file handle.
222 * @param idname The name of the datablock (without the 2 char ID prefix)
223 * @param idcode The kind of datablock to link.
224 * @param flag Options for linking, used for instancing.
225 * @return Boolean, 0 when the datablock could not be found.
227 struct ID *BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag);
228 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag);
230 void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
234 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
237 BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);