4 #include "zipios++/zipios-config.h"
7 #include "zipios++/meta-iostreams.h"
11 #include "zipios++/gzipoutputstreambuf.h"
19 GZIPOutputStreambuf::GZIPOutputStreambuf( streambuf *outbuf, bool del_outbuf )
20 : DeflateOutputStreambuf( outbuf, true, del_outbuf ),
25 void GZIPOutputStreambuf::setFilename( const string &filename ) {
26 _filename = filename ;
29 void GZIPOutputStreambuf::setComment( const string &comment ) {
33 void GZIPOutputStreambuf::close() {
37 void GZIPOutputStreambuf::finish() {
47 GZIPOutputStreambuf::~GZIPOutputStreambuf() {
51 int GZIPOutputStreambuf::overflow( int c ) {
56 return DeflateOutputStreambuf::overflow( c ) ;
59 int GZIPOutputStreambuf::sync() {
60 return DeflateOutputStreambuf::sync() ;
63 void GZIPOutputStreambuf::writeHeader() {
64 unsigned char flg = 0x00;
65 flg |= (_filename == "") ? 0x00 : 0x08;
66 flg |= (_comment == "") ? 0x00 : 0x10;
68 ostream os( _outbuf ) ;
69 os << (unsigned char)0x1f; // Magic #
70 os << (unsigned char)0x8b; // Magic #
71 os << (unsigned char)0x08; // Deflater.DEFLATED
73 os << (unsigned char)0x00; // MTIME
74 os << (unsigned char)0x00; // MTIME
75 os << (unsigned char)0x00; // MTIME
76 os << (unsigned char)0x00; // MTIME
77 os << (unsigned char)0x00; // XFLG
78 os << (unsigned char)0x00; // OS
80 if (_filename != "") {
81 os << _filename.c_str();// Filename
82 os << (unsigned char)0x00;
86 os << _comment.c_str(); // Comment
87 os << (unsigned char)0x00;
91 void GZIPOutputStreambuf::writeTrailer() {
96 void GZIPOutputStreambuf::writeInt(uint32 i) {
97 ostream os( _outbuf ) ;
98 os << (unsigned char)( i & 0xFF);
99 os << (unsigned char)((i >> 8) & 0xFF);
100 os << (unsigned char)((i >> 16) & 0xFF);
101 os << (unsigned char)((i >> 24) & 0xFF);
107 Implementation of GZIPOutputStreambuf.
111 Zipios++ - a small C++ library that provides easy access to .zip files.
112 Copyright (C) 2000 Thomas Søndergaard
114 This library is free software; you can redistribute it and/or
115 modify it under the terms of the GNU Lesser General Public
116 License as published by the Free Software Foundation; either
117 version 2 of the License, or (at your option) any later version.
119 This library is distributed in the hope that it will be useful,
120 but WITHOUT ANY WARRANTY; without even the implied warranty of
121 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
122 Lesser General Public License for more details.
124 You should have received a copy of the GNU Lesser General Public
125 License along with this library; if not, write to the Free Software
126 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA