2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* blenloader readfile private function prototypes
|
|
|
|
*/
|
2011-02-27 20:35:41 +00:00
|
|
|
|
|
|
|
/** \file blender/blenloader/intern/readfile.h
|
|
|
|
* \ingroup blenloader
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __READFILE_H__
|
|
|
|
#define __READFILE_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
#include "zlib.h"
|
2013-11-29 23:16:13 +06:00
|
|
|
#include "DNA_windowmanager_types.h" /* for ReportType */
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
struct OldNewMap;
|
2004-09-05 13:43:51 +00:00
|
|
|
struct MemFile;
|
2008-01-30 18:18:33 +00:00
|
|
|
struct bheadsort;
|
2008-12-19 00:50:21 +00:00
|
|
|
struct ReportList;
|
2012-05-04 15:42:49 +00:00
|
|
|
struct Object;
|
|
|
|
struct PartEff;
|
|
|
|
struct View3D;
|
|
|
|
struct bNodeTree;
|
2013-11-29 23:16:13 +06:00
|
|
|
struct Key;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
typedef struct FileData {
|
|
|
|
// linked list of BHeadN's
|
|
|
|
ListBase listbase;
|
|
|
|
int flags;
|
|
|
|
int eof;
|
|
|
|
int buffersize;
|
|
|
|
int seek;
|
2009-01-02 19:10:35 +00:00
|
|
|
int (*read)(struct FileData *filedata, void *buffer, unsigned int size);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// variables needed for reading from memory / stream
|
2013-03-17 19:13:04 +00:00
|
|
|
const char *buffer;
|
2004-09-05 13:43:51 +00:00
|
|
|
// variables needed for reading from memfile (undo)
|
|
|
|
struct MemFile *memfile;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// variables needed for reading from file
|
|
|
|
int filedes;
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
gzFile gzfiledes;
|
|
|
|
|
2005-06-02 17:38:42 +00:00
|
|
|
// now only in use for library appending
|
2011-11-26 04:07:38 +00:00
|
|
|
char relabase[FILE_MAX];
|
2005-06-02 17:38:42 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// variables needed for reading from stream
|
|
|
|
char headerdone;
|
|
|
|
int inbuffer;
|
|
|
|
|
2012-12-27 15:07:19 +00:00
|
|
|
// gzip stream for memory decompression
|
|
|
|
z_stream strm;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// general reading variables
|
|
|
|
struct SDNA *filesdna;
|
|
|
|
struct SDNA *memsdna;
|
|
|
|
char *compflags;
|
|
|
|
|
2006-11-27 18:58:33 +00:00
|
|
|
int fileversion;
|
2012-05-12 20:39:39 +00:00
|
|
|
int id_name_offs; /* used to retrieve ID names from (bhead+1) */
|
|
|
|
int globalf, fileflags; /* for do_versions patching */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
struct OldNewMap *datamap;
|
|
|
|
struct OldNewMap *globmap;
|
|
|
|
struct OldNewMap *libmap;
|
2006-11-10 10:17:04 +00:00
|
|
|
struct OldNewMap *imamap;
|
2011-11-07 12:55:18 +00:00
|
|
|
struct OldNewMap *movieclipmap;
|
2014-11-24 18:18:35 +01:00
|
|
|
struct OldNewMap *soundmap;
|
2012-12-27 15:07:19 +00:00
|
|
|
struct OldNewMap *packedmap;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-08-04 19:34:38 +00:00
|
|
|
struct BHeadSort *bheadmap;
|
2008-01-30 18:18:33 +00:00
|
|
|
int tot_bheadmap;
|
|
|
|
|
2012-05-25 17:13:30 +00:00
|
|
|
ListBase *mainlist;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/* ick ick, used to return
|
|
|
|
* data through streamglue.
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
BlendFileData **bfd_r;
|
2008-12-19 00:50:21 +00:00
|
|
|
struct ReportList *reports;
|
2002-10-12 11:37:38 +00:00
|
|
|
} FileData;
|
|
|
|
|
|
|
|
typedef struct BHeadN {
|
|
|
|
struct BHeadN *next, *prev;
|
|
|
|
struct BHead bhead;
|
|
|
|
} BHeadN;
|
|
|
|
|
2006-11-26 21:17:15 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
#define FD_FLAGS_SWITCH_ENDIAN (1 << 0)
|
|
|
|
#define FD_FLAGS_FILE_POINTSIZE_IS_4 (1 << 1)
|
|
|
|
#define FD_FLAGS_POINTSIZE_DIFFERS (1 << 2)
|
|
|
|
#define FD_FLAGS_FILE_OK (1 << 3)
|
|
|
|
#define FD_FLAGS_NOT_MY_BUFFER (1 << 4)
|
|
|
|
#define FD_FLAGS_NOT_MY_LIBMAP (1 << 5)
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#define SIZEOFBLENDERHEADER 12
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/***/
|
2006-11-25 13:07:28 +00:00
|
|
|
struct Main;
|
2002-10-12 11:37:38 +00:00
|
|
|
void blo_join_main(ListBase *mainlist);
|
2006-11-25 13:07:28 +00:00
|
|
|
void blo_split_main(ListBase *mainlist, struct Main *main);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-05-18 06:27:32 +00:00
|
|
|
BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-05-18 06:27:32 +00:00
|
|
|
FileData *blo_openblenderfile(const char *filepath, struct ReportList *reports);
|
2013-03-17 19:13:04 +00:00
|
|
|
FileData *blo_openblendermemory(const void *buffer, int buffersize, struct ReportList *reports);
|
2008-12-19 00:50:21 +00:00
|
|
|
FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
void blo_clear_proxy_pointers_from_lib(Main *oldmain);
|
2008-12-19 16:36:15 +00:00
|
|
|
void blo_make_image_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_image_pointer_map(FileData *fd, Main *oldmain);
|
2011-11-07 12:55:18 +00:00
|
|
|
void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain);
|
2014-11-24 18:18:35 +01:00
|
|
|
void blo_make_sound_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_sound_pointer_map(FileData *fd, Main *oldmain);
|
2012-12-27 15:07:19 +00:00
|
|
|
void blo_make_packed_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_packed_pointer_map(FileData *fd, Main *oldmain);
|
2006-11-25 13:07:28 +00:00
|
|
|
void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
void blo_freefiledata(FileData *fd);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
BHead *blo_firstbhead(FileData *fd);
|
|
|
|
BHead *blo_nextbhead(FileData *fd, BHead *thisblock);
|
|
|
|
BHead *blo_prevbhead(FileData *fd, BHead *thisblock);
|
2007-04-28 16:15:00 +00:00
|
|
|
|
|
|
|
char *bhead_id_name(FileData *fd, BHead *bhead);
|
|
|
|
|
2012-05-04 15:42:49 +00:00
|
|
|
/* do versions stuff */
|
|
|
|
|
2013-11-29 23:16:13 +06:00
|
|
|
void blo_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(3, 4);
|
|
|
|
|
2012-05-04 15:42:49 +00:00
|
|
|
void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm, void *oldaddr, void *newaddr, int nr);
|
|
|
|
void *blo_do_versions_newlibadr(struct FileData *fd, void *lib, void *adr);
|
|
|
|
void *blo_do_versions_newlibadr_us(struct FileData *fd, void *lib, void *adr);
|
|
|
|
|
|
|
|
struct PartEff *blo_do_version_give_parteff_245(struct Object *ob);
|
|
|
|
void blo_do_version_old_trackto_to_constraints(struct Object *ob);
|
|
|
|
void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions);
|
2013-11-29 23:16:13 +06:00
|
|
|
void blo_do_versions_key_uidgen(struct Key *key);
|
2012-05-04 15:42:49 +00:00
|
|
|
|
|
|
|
void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *main);
|
|
|
|
void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *main);
|
2013-11-29 23:16:13 +06:00
|
|
|
void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *main);
|
2014-03-06 04:33:15 +11:00
|
|
|
void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *main);
|
2012-05-04 15:42:49 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
2002-10-30 02:07:20 +00:00
|
|
|
|