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.
53 typedef struct BlendHandle BlendHandle;
55 typedef enum BlenFileType {
56 BLENFILETYPE_BLEND= 1,
58 BLENFILETYPE_RUNTIME= 3
61 typedef struct BlendFileData {
69 char filename[240]; /* 240 = FILE_MAX */
71 struct bScreen* curscreen;
72 struct Scene* curscene;
78 * Open a blender file from a pathname. The function
79 * returns NULL and sets a report in the list if
80 * it cannot open the file.
82 * @param file The path of the file to open.
83 * @param reports If the return value is NULL, errors
84 * indicating the cause of the failure.
85 * @return The data of the file.
87 BlendFileData* BLO_read_from_file(const char *file, struct ReportList *reports);
90 * Open a blender file from memory. The function
91 * returns NULL and sets a report in the list if
92 * it cannot open the file.
94 * @param mem The file data.
95 * @param memsize The length of @a mem.
96 * @param reports If the return value is NULL, errors
97 * indicating the cause of the failure.
98 * @return The data of the file.
100 BlendFileData* BLO_read_from_memory(void *mem, int memsize, struct ReportList *reports);
103 * oldmain is old main, from which we will keep libraries, images, ..
104 * file name is current file, only for retrieving library data */
106 BlendFileData *BLO_read_from_memfile(struct Main *oldmain, const char *filename, struct MemFile *memfile, struct ReportList *reports);
109 * Free's a BlendFileData structure and _all_ the
110 * data associated with it (the userdef data, and
111 * the main libblock data).
113 * @param bfd The structure to free.
116 BLO_blendfiledata_free(
120 * Open a blendhandle from a file path.
122 * @param file The file path to open.
123 * @param reports Report errors in opening the file (can be NULL).
124 * @return A handle on success, or NULL on failure.
127 BLO_blendhandle_from_file(
129 struct ReportList *reports);
132 * Open a blendhandle from memory.
134 * @param mem The data to load from.
135 * @param memsize The size of the data.
136 * @return A handle on success, or NULL on failure.
140 BLO_blendhandle_from_memory(
145 * Gets the names of all the datablocks in a file
146 * of a certain type (ie. All the scene names in
149 * @param bh The blendhandle to access.
150 * @param ofblocktype The type of names to get.
151 * @param tot_names The length of the returned list.
152 * @return A BLI_linklist of strings. The string links
153 * should be freed with malloc.
156 BLO_blendhandle_get_datablock_names(
162 * Gets the previews of all the datablocks in a file
163 * of a certain type (ie. All the scene names in
166 * @param bh The blendhandle to access.
167 * @param ofblocktype The type of names to get.
168 * @param tot_prev The length of the returned list.
169 * @return A BLI_linklist of PreviewImage. The PreviewImage links
170 * should be freed with malloc.
173 BLO_blendhandle_get_previews(
179 * Gets the names of all the datablock groups in a
180 * file. (ie. file contains Scene, Mesh, and Lamp
183 * @param bh The blendhandle to access.
184 * @return A BLI_linklist of strings. The string links
185 * should be freed with malloc.
188 BLO_blendhandle_get_linkable_groups(
192 * Close and free a blendhandle. The handle
193 * becomes invalid after this call.
195 * @param bh The handle to close.
198 BLO_blendhandle_close(
205 int BLO_has_bfile_extension(char *str);
207 /* return ok when a blenderfile, in dir is the filename,
208 * in group the type of libdata
210 int BLO_is_a_library(const char *path, char *dir, char *group);
212 struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, char *dir);
215 * Link/Append a named datablock from an external blend file.
217 * @param C The context, when NULL instancing object in the scene isnt done.
218 * @param mainl The main database to link from (not the active one).
219 * @param bh The blender file handle.
220 * @param name The name of the datablock (without the 2 char ID prefix)
221 * @param idcode The kind of datablock to link.
222 * @param flag Options for linking, used for instancing.
223 * @return Boolean, 0 when the datablock could not be found.
225 int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag);
226 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag);
230 void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
233 BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);