diff options
author | Ton Roosendaal <ton@blender.org> | 2005-07-27 23:46:06 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-07-27 23:46:06 +0400 |
commit | 410512e2656007587cc1671c71c37cbc0b5bda4f (patch) | |
tree | 4c09eac0d6de21a38e0d355ea7cc71b46174cf81 /source/blender/blenloader/intern/writefile.c | |
parent | cd6cbda7dba939cec05b820e4a09ad0a5770d2b7 (diff) |
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.
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 61c7911ffca..3ae58e92b03 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -167,6 +167,9 @@ Important to know is that 'streaming' has been added to files, for Blender Publi #include "readfile.h" #include "genfile.h" +#include "zlib.h" + +#include <errno.h> /* ********* my write, buffered writing with minimum 50k chunks ************ */ @@ -1607,10 +1610,28 @@ int BLO_write_file(char *dir, int write_flags, char **error_r) close(file); if(!fout) { + if(write_flags & G_FILE_COMPRESS) + { + // compressed files have the same ending as regular files... only from 2.4!!! + + int ret = BLI_gzip(tempname, dir); + + if(-1==ret) { + *error_r= "Failed opening .gz file"; + return 0; + } + if(-2==ret) { + *error_r= "Failed opening .blend file for compression"; + return 0; + } + } + else if(BLI_rename(tempname, dir) < 0) { *error_r= "Can't change old file. File saved with @"; return 0; } + + } else { remove(tempname); |