「Dev:2.4/Source/Blender File Format/Gzip」の版間の差分

提供: wiki
移動先: 案内検索
 
(1版 をインポートしました)
 
(相違点なし)

2018年6月29日 (金) 02:45時点における最新版

gzipped .blend files

Introduction

The following page is a documentation of the steps taken in order to introduce [[1]] into blender.

Maturity Level In release.

Goals

  • Save and load .blend files in gzip format
  • Have a checkbox in the file menu which can toggle compression on and off

Files changed The following files were edited during the change, the path is from cvs root:

  • source/blender/blenlib/BLI_blenlib.h and source/blender/blenlib/intern/fileops.c - various file functions. Added gzip function
  • source/blender/blenlib/intern/util.c - utilities used by blender. Modified the increment/decrement of files function to work with ".blend.gz".
  • source/blender/blenloader/intern/readfile.c - low level file read function. Added a callback which uses gzread.
  • source/blender/blenloader/intern/writefile.c - low level file write function. Modified to create .gz files when requested.
  • No longer in the scope - source/blender/include/BSE_filesel.h - Added a function to add and remove ".gz" to the filename in the file select.
  • No longer in the scope - source/blender/src/filesel.c - Main file select window. Modified to support compression.
  • No longer in the scope - source/blender/src/header_filesel.c - File select header. Added a checkbox for compression.
  • source/blender/blenkernel/intern/exotic.c - Misc. functions. Modified to support ".blend.gz"
  • source/blender/src/header_info.c - the file menu, added an entry for compression with a checkbox

Note worthy changed

readfile.c

The function blo_openblenderfile use a new callback function, fd_read_gzip_from_file, which uses gzread in order to read files. According to the zlib homepage (and according to my tests) gzread reads regular files as well, so in essence, this function can now open both regular and zipped files.
Another function which was changed is BLO_has_bfile_extension, which now detect ".blend.gz" as a blender file as well.

writefile.c

The function writedata_do_write check if the environment should use compression, if so - it calls a helper function which takes the file ending with "@" (blender always saves with "@" and then renames), zip it and remove the "@" version.

filesel.c - no longer in the scope

This file is a very important even if there aren't any actual changes to it. It is the central hub for all of the load/save/save as operations of blender files.

header_filesel.c - no longer in the scope

Added a button using the uiDefIconButI function. _This would be a good place to mention that I am using a previously configured flag (G_FILE_COMPRESS) as it doesn't seem to be in use_.
The button uses a callback function by using the pointer returned from uiDefIconButI in the uiButSetFunc function. The callback is defined in filesel.c because it uses global variables which are not used in header_filesel.c; BSE_filesel.h is the connection between the two files, the function prototype is void _name_(void *arg1, void* arg2).

header_info.c

Added code to support the compression toggle in the file menu, G_FILE_COMPRESS is used (see previous bullet) and saved in the file, which means that compressed files will toggle this checkbox on in the current codebase (27.7.05). No callback function is used. The compression bit just makes writefile write compressed files, no .gz ending or anything.

Thanks goes out to ton,intrr and sirdude for their help


-- User:Shul- 08 Jul 2005 -- Updated 27 Jul 2005