Blender V2.61 - r43446
Classes | Defines | Functions | Variables

writefile.c File Reference

#include <math.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "zlib.h"
#include <unistd.h>
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_actuator_types.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
#include "DNA_constraint_types.h"
#include "DNA_controller_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_genfile.h"
#include "DNA_group_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
#include "DNA_lamp_types.h"
#include "DNA_meta_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_property_types.h"
#include "DNA_scene_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
#include "DNA_sensor_types.h"
#include "DNA_smoke_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
#include "DNA_speaker_types.h"
#include "DNA_sound_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_vfont_types.h"
#include "DNA_world_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_movieclip_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_bpath.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_action.h"
#include "BKE_blender.h"
#include "BKE_curve.h"
#include "BKE_constraint.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_sequencer.h"
#include "BKE_utildefines.h"
#include "BKE_modifier.h"
#include "BKE_fcurve.h"
#include "BKE_pointcache.h"
#include "BLO_writefile.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "readfile.h"
#include <errno.h>

Go to the source code of this file.

Classes

struct  WriteData

Defines

#define MYWRITE_BUFFER_SIZE   100000
#define MYWRITE_MAX_CHUNK   32768
#define MYWRITE_FLUSH   NULL

Functions

static WriteDatawritedata_new (int file)
static void writedata_do_write (WriteData *wd, void *mem, int memlen)
static void writedata_free (WriteData *wd)
static void mywrite (WriteData *wd, void *adr, int len)
static WriteDatabgnwrite (int file, MemFile *compare, MemFile *current)
static int endwrite (WriteData *wd)
static void writestruct (WriteData *wd, int filecode, const char *structname, int nr, void *adr)
static void writedata (WriteData *wd, int filecode, int len, void *adr)
void IDP_WriteProperty_OnlyData (IDProperty *prop, void *wd)
void IDP_WriteProperty (IDProperty *prop, void *wd)
static void IDP_WriteArray (IDProperty *prop, void *wd)
static void IDP_WriteIDPArray (IDProperty *prop, void *wd)
static void IDP_WriteString (IDProperty *prop, void *wd)
static void IDP_WriteGroup (IDProperty *prop, void *wd)
static void write_fmodifiers (WriteData *wd, ListBase *fmodifiers)
static void write_fcurves (WriteData *wd, ListBase *fcurves)
static void write_actions (WriteData *wd, ListBase *idbase)
static void write_keyingsets (WriteData *wd, ListBase *list)
static void write_nlastrips (WriteData *wd, ListBase *strips)
static void write_nladata (WriteData *wd, ListBase *nlabase)
static void write_animdata (WriteData *wd, AnimData *adt)
static void write_curvemapping (WriteData *wd, CurveMapping *cumap)
static void write_node_socket (WriteData *wd, bNodeSocket *sock)
static void write_nodetree (WriteData *wd, bNodeTree *ntree)
static void current_screen_compat (Main *mainvar, bScreen **screen)
static void write_renderinfo (WriteData *wd, Main *mainvar)
static void write_keymapitem (WriteData *wd, wmKeyMapItem *kmi)
static void write_userdef (WriteData *wd)
static void write_boid_state (WriteData *wd, BoidState *state)
static void write_pointcaches (WriteData *wd, ListBase *ptcaches)
static void write_particlesettings (WriteData *wd, ListBase *idbase)
static void write_particlesystems (WriteData *wd, ListBase *particles)
static void write_properties (WriteData *wd, ListBase *lb)
static void write_sensors (WriteData *wd, ListBase *lb)
static void write_controllers (WriteData *wd, ListBase *lb)
static void write_actuators (WriteData *wd, ListBase *lb)
static void write_motionpath (WriteData *wd, bMotionPath *mpath)
static void write_constraints (WriteData *wd, ListBase *conlist)
static void write_pose (WriteData *wd, bPose *pose)
static void write_defgroups (WriteData *wd, ListBase *defbase)
static void write_modifiers (WriteData *wd, ListBase *modbase)
static void write_objects (WriteData *wd, ListBase *idbase)
static void write_vfonts (WriteData *wd, ListBase *idbase)
static void write_keys (WriteData *wd, ListBase *idbase)
static void write_cameras (WriteData *wd, ListBase *idbase)
static void write_mballs (WriteData *wd, ListBase *idbase)
static int amount_of_chars (char *str)
static void write_curves (WriteData *wd, ListBase *idbase)
static void write_dverts (WriteData *wd, int count, MDeformVert *dvlist)
static void write_mdisps (WriteData *wd, int count, MDisps *mdlist, int external)
static void write_customdata (WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count)
static void write_meshs (WriteData *wd, ListBase *idbase)
static void write_lattices (WriteData *wd, ListBase *idbase)
static void write_previews (WriteData *wd, PreviewImage *prv)
static void write_images (WriteData *wd, ListBase *idbase)
static void write_textures (WriteData *wd, ListBase *idbase)
static void write_materials (WriteData *wd, ListBase *idbase)
static void write_worlds (WriteData *wd, ListBase *idbase)
static void write_lamps (WriteData *wd, ListBase *idbase)
static void write_scenes (WriteData *wd, ListBase *scebase)
static void write_gpencils (WriteData *wd, ListBase *lb)
static void write_windowmanagers (WriteData *wd, ListBase *lb)
static void write_region (WriteData *wd, ARegion *ar, int spacetype)
static void write_screens (WriteData *wd, ListBase *scrbase)
static void write_libraries (WriteData *wd, Main *main)
static void write_bone (WriteData *wd, Bone *bone)
static void write_armatures (WriteData *wd, ListBase *idbase)
static void write_texts (WriteData *wd, ListBase *idbase)
static void write_speakers (WriteData *wd, ListBase *idbase)
static void write_sounds (WriteData *wd, ListBase *idbase)
static void write_groups (WriteData *wd, ListBase *idbase)
static void write_nodetrees (WriteData *wd, ListBase *idbase)
static void write_brushes (WriteData *wd, ListBase *idbase)
static void write_scripts (WriteData *wd, ListBase *idbase)
static void write_movieTracks (WriteData *wd, ListBase *tracks)
static void write_movieReconstruction (WriteData *wd, MovieTrackingReconstruction *reconstruction)
static void write_movieclips (WriteData *wd, ListBase *idbase)
static void write_global (WriteData *wd, int fileflags, Main *mainvar)
static void write_thumb (WriteData *wd, int *img)
static int write_file_handle (Main *mainvar, int handle, MemFile *compare, MemFile *current, int write_user_block, int write_flags, int *thumb)
static int do_history (const char *name, ReportList *reports)
int BLO_write_file (Main *mainvar, const char *filepath, int write_flags, ReportList *reports, int *thumb)
int BLO_write_file_mem (Main *mainvar, MemFile *compare, MemFile *current, int write_flags)

Variables

static const char * ptcache_data_struct []
static const char * ptcache_extra_struct []

Detailed Description

Definition in file writefile.c.


Define Documentation

#define MYWRITE_BUFFER_SIZE   100000

Definition at line 166 of file writefile.c.

Referenced by mywrite(), and writedata_new().

#define MYWRITE_FLUSH   NULL

Low level WRITE(2) wrapper that buffers data

Parameters:
adrPointer to new chunk of data
lenLength of new chunk of data
Warning:
Talks to other functions with global parameters

Definition at line 235 of file writefile.c.

Referenced by mywrite(), write_actions(), write_armatures(), write_curves(), write_images(), write_keys(), write_movieclips(), write_objects(), write_scenes(), write_sounds(), write_texts(), and write_textures().

#define MYWRITE_MAX_CHUNK   32768

Definition at line 167 of file writefile.c.

Referenced by mywrite().


Function Documentation

static int amount_of_chars ( char *  str) [static]

Definition at line 1553 of file writefile.c.

References strlen().

Referenced by write_curves().

static WriteData* bgnwrite ( int  file,
MemFile compare,
MemFile current 
) [static]

BeGiN initializer for mywrite

Parameters:
fileFile descriptor
write_flagsWrite parameters
Warning:
Talks to other functions with global parameters

Definition at line 287 of file writefile.c.

References add_memfilechunk(), compare(), WriteData::compare, WriteData::current, NULL, and writedata_new().

Referenced by write_file_handle().

int BLO_write_file ( Main mainvar,
const char *  filepath,
int  write_flags,
ReportList reports,
int *  thumb 
)
int BLO_write_file_mem ( Main mainvar,
MemFile compare,
MemFile current,
int  write_flags 
)

Definition at line 2849 of file writefile.c.

References err, NULL, and write_file_handle().

Referenced by BKE_write_undo().

static void current_screen_compat ( Main mainvar,
bScreen **  screen 
) [static]

Definition at line 736 of file writefile.c.

References ListBase::first, NULL, wmWindow::screen, wmWindowManager::windows, and Main::wm.

Referenced by write_global(), and write_renderinfo().

static int do_history ( const char *  name,
ReportList reports 
) [static]

Definition at line 2712 of file writefile.c.

References BKE_report(), BLI_rename(), BLI_snprintf(), FILE_MAX, RPT_ERROR, strlen(), U, and UserDef::versions.

Referenced by BLO_write_file().

static int endwrite ( WriteData wd) [static]

END the mywrite wrapper

Returns:
1 if write failed
unknown global variable otherwise
Warning:
Talks to other functions with global parameters

Definition at line 307 of file writefile.c.

References WriteData::buf, WriteData::count, err, WriteData::error, writedata_do_write(), and writedata_free().

Referenced by write_file_handle().

static void IDP_WriteArray ( IDProperty prop,
void *  wd 
) [static]
static void IDP_WriteGroup ( IDProperty prop,
void *  wd 
) [static]
static void IDP_WriteIDPArray ( IDProperty prop,
void *  wd 
) [static]
void IDP_WriteProperty ( IDProperty prop,
void *  wd 
)
void IDP_WriteProperty_OnlyData ( IDProperty prop,
void *  wd 
)
static void IDP_WriteString ( IDProperty prop,
void *  wd 
) [static]
static void mywrite ( WriteData wd,
void *  adr,
int  len 
) [static]
static void write_actions ( WriteData wd,
ListBase idbase 
) [static]
static void write_actuators ( WriteData wd,
ListBase lb 
) [static]
static void write_animdata ( WriteData wd,
AnimData adt 
) [static]
static void write_armatures ( WriteData wd,
ListBase idbase 
) [static]
static void write_boid_state ( WriteData wd,
BoidState state 
) [static]
static void write_bone ( WriteData wd,
Bone bone 
) [static]
static void write_brushes ( WriteData wd,
ListBase idbase 
) [static]
static void write_cameras ( WriteData wd,
ListBase idbase 
) [static]
static void write_constraints ( WriteData wd,
ListBase conlist 
) [static]
static void write_controllers ( WriteData wd,
ListBase lb 
) [static]
static void write_curvemapping ( WriteData wd,
CurveMapping cumap 
) [static]
static void write_curves ( WriteData wd,
ListBase idbase 
) [static]
static void write_customdata ( WriteData wd,
ID id,
int  count,
CustomData data,
int  partial_type,
int  partial_count 
) [static]
static void write_defgroups ( WriteData wd,
ListBase defbase 
) [static]

Definition at line 1266 of file writefile.c.

References DATA, ListBase::first, bDeformGroup::next, and writestruct().

Referenced by write_objects().

static void write_dverts ( WriteData wd,
int  count,
MDeformVert dvlist 
) [static]

Definition at line 1608 of file writefile.c.

References DATA, i, and writestruct().

Referenced by write_customdata(), and write_lattices().

static void write_fcurves ( WriteData wd,
ListBase fcurves 
) [static]
static int write_file_handle ( Main mainvar,
int  handle,
MemFile compare,
MemFile current,
int  write_user_block,
int  write_flags,
int *  thumb 
) [static]
static void write_fmodifiers ( WriteData wd,
ListBase fmodifiers 
) [static]
static void write_global ( WriteData wd,
int  fileflags,
Main mainvar 
) [static]
static void write_gpencils ( WriteData wd,
ListBase lb 
) [static]
static void write_groups ( WriteData wd,
ListBase idbase 
) [static]
static void write_images ( WriteData wd,
ListBase idbase 
) [static]
static void write_keyingsets ( WriteData wd,
ListBase list 
) [static]
static void write_keymapitem ( WriteData wd,
wmKeyMapItem kmi 
) [static]

Definition at line 770 of file writefile.c.

References DATA, IDP_WriteProperty(), wmKeyMapItem::properties, and writestruct().

Referenced by write_userdef().

static void write_keys ( WriteData wd,
ListBase idbase 
) [static]
static void write_lamps ( WriteData wd,
ListBase idbase 
) [static]
static void write_lattices ( WriteData wd,
ListBase idbase 
) [static]
static void write_libraries ( WriteData wd,
Main main 
) [static]
static void write_materials ( WriteData wd,
ListBase idbase 
) [static]
static void write_mballs ( WriteData wd,
ListBase idbase 
) [static]
static void write_mdisps ( WriteData wd,
int  count,
MDisps mdlist,
int  external 
) [static]

Definition at line 1624 of file writefile.c.

References DATA, i, writedata(), and writestruct().

Referenced by write_customdata().

static void write_meshs ( WriteData wd,
ListBase idbase 
) [static]
static void write_modifiers ( WriteData wd,
ListBase modbase 
) [static]

Definition at line 1274 of file writefile.c.

References MeshDeformModifierData::bindcagecos, MeshDeformModifierData::bindinfluences, MeshDeformModifierData::bindoffsets, BKE_ptcache_add(), BKE_ptcache_free_list(), DynamicPaintModifierData::brush, DynamicPaintModifierData::canvas, WeightVGEditModifierData::cmap_curve, SmokeModifierData::coll, ClothModifierData::coll_parms, WarpModifierData::curfalloff, DATA, SmokeModifierData::domain, MeshDeformModifierData::dyngrid, MeshDeformModifierData::dyngridsize, MeshDeformModifierData::dyninfluences, MeshDeformModifierData::dynverts, DynamicPaintSurface::effector_weights, SmokeDomainSettings::effector_weights, ClothSimSettings::effector_weights, eModifierType_Cloth, eModifierType_Collision, eModifierType_DynamicPaint, eModifierType_Fluidsim, eModifierType_Hook, eModifierType_MeshDeform, eModifierType_Smoke, eModifierType_Warp, eModifierType_WeightVGEdit, ListBase::first, PointCache::flag, SmokeModifierData::flow, FluidsimModifierData::fss, HookModifierData::indexar, MOD_SMOKE_TYPE_COLL, MOD_SMOKE_TYPE_DOMAIN, MOD_SMOKE_TYPE_FLOW, modifierType_getInfo(), mti, DynamicPaintSurface::next, ModifierData::next, NULL, DynamicPaintBrushSettings::paint_ramp, SmokeDomainSettings::point_cache, PTCACHE_DISK_CACHE, PTCACHE_FAKE_SMOKE, DynamicPaintSurface::ptcaches, SmokeDomainSettings::ptcaches, ClothModifierData::ptcaches, ClothModifierData::sim_parms, size(), PointCache::step, ModifierTypeInfo::structName, DynamicPaintCanvasSettings::surfaces, MeshDeformModifierData::totcagevert, HookModifierData::totindex, MeshDeformModifierData::totinfluence, MeshDeformModifierData::totvert, SmokeModifierData::type, ModifierData::type, DynamicPaintBrushSettings::vel_ramp, write_curvemapping(), write_pointcaches(), writedata(), and writestruct().

Referenced by write_objects().

static void write_motionpath ( WriteData wd,
bMotionPath mpath 
) [static]

Definition at line 1166 of file writefile.c.

References DATA, bMotionPath::length, NULL, bMotionPath::points, and writestruct().

Referenced by write_objects(), and write_pose().

static void write_movieclips ( WriteData wd,
ListBase idbase 
) [static]
static void write_movieReconstruction ( WriteData wd,
MovieTrackingReconstruction reconstruction 
) [static]
static void write_movieTracks ( WriteData wd,
ListBase tracks 
) [static]
static void write_nladata ( WriteData wd,
ListBase nlabase 
) [static]

Definition at line 603 of file writefile.c.

References DATA, ListBase::first, NlaTrack::next, NlaTrack::strips, write_nlastrips(), and writestruct().

Referenced by write_animdata().

static void write_nlastrips ( WriteData wd,
ListBase strips 
) [static]
static void write_node_socket ( WriteData wd,
bNodeSocket sock 
) [static]
static void write_nodetree ( WriteData wd,
bNodeTree ntree 
) [static]
static void write_nodetrees ( WriteData wd,
ListBase idbase 
) [static]
static void write_objects ( WriteData wd,
ListBase idbase 
) [static]
static void write_particlesettings ( WriteData wd,
ListBase idbase 
) [static]
static void write_particlesystems ( WriteData wd,
ListBase particles 
) [static]
static void write_pointcaches ( WriteData wd,
ListBase ptcaches 
) [static]
static void write_pose ( WriteData wd,
bPose pose 
) [static]
static void write_previews ( WriteData wd,
PreviewImage prv 
) [static]
static void write_properties ( WriteData wd,
ListBase lb 
) [static]
static void write_region ( WriteData wd,
ARegion ar,
int  spacetype 
) [static]
static void write_renderinfo ( WriteData wd,
Main mainvar 
) [static]
static void write_scenes ( WriteData wd,
ListBase scebase 
) [static]
static void write_screens ( WriteData wd,
ListBase scrbase 
) [static]
static void write_scripts ( WriteData wd,
ListBase idbase 
) [static]
static void write_sensors ( WriteData wd,
ListBase lb 
) [static]
static void write_sounds ( WriteData wd,
ListBase idbase 
) [static]
static void write_speakers ( WriteData wd,
ListBase idbase 
) [static]
static void write_texts ( WriteData wd,
ListBase idbase 
) [static]
static void write_textures ( WriteData wd,
ListBase idbase 
) [static]
static void write_thumb ( WriteData wd,
int *  img 
) [static]

Definition at line 2630 of file writefile.c.

References TEST, and writedata().

Referenced by write_file_handle().

static void write_userdef ( WriteData wd) [static]
static void write_vfonts ( WriteData wd,
ListBase idbase 
) [static]
static void write_windowmanagers ( WriteData wd,
ListBase lb 
) [static]
static void write_worlds ( WriteData wd,
ListBase idbase 
) [static]
static void writedata ( WriteData wd,
int  filecode,
int  len,
void *  adr 
) [static]
static void writedata_do_write ( WriteData wd,
void *  mem,
int  memlen 
) [static]
static void writedata_free ( WriteData wd) [static]

Definition at line 218 of file writefile.c.

References WriteData::buf, DNA_sdna_free(), MEM_freeN(), and WriteData::sdna.

Referenced by endwrite().

static WriteData* writedata_new ( int  file) [static]
static void writestruct ( WriteData wd,
int  filecode,
const char *  structname,
int  nr,
void *  adr 
) [static]

Variable Documentation

const char* ptcache_data_struct[] [static]
Initial value:
 {
    "", 
    "", 
    "", 
    "", 
    "", 
    "", 
    "", 
    "BoidData" 
}

Definition at line 849 of file writefile.c.

Referenced by write_pointcaches().

const char* ptcache_extra_struct[] [static]
Initial value:
 {
    "",
    "ParticleSpring"
}

Definition at line 859 of file writefile.c.

Referenced by write_pointcaches().