]> git.donarmstrong.com Git - flightcrew.git/blob - src/zipios/src/gzipoutputstream.cpp
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / zipios / src / gzipoutputstream.cpp
1
2 #include "zipios++/zipios-config.h"
3
4 #include "zipios++/meta-iostreams.h"
5
6 #include "zipios++/gzipoutputstreambuf.h"
7 #include "zipios++/gzipoutputstream.h"
8
9 using std::ostream;
10
11 namespace zipios {
12
13 GZIPOutputStream::GZIPOutputStream( std::ostream &os )
14   : ostream( 0 ),
15     ofs( 0 )
16 {
17   ozf = new GZIPOutputStreambuf( os.rdbuf() ) ;
18
19   init( ozf ) ;
20 }
21
22 GZIPOutputStream::GZIPOutputStream( const std::string &filename )
23   : ostream( 0 ),
24     ofs( 0 )
25 {
26   ofs = new std::ofstream( filename.c_str(), std::ios::out | std::ios::binary ) ;
27   ozf = new GZIPOutputStreambuf( ofs->rdbuf() ) ;
28   init( ozf ) ;
29 }
30
31 void GZIPOutputStream::setFilename( const string &filename ) {
32   ozf->setFilename(filename);
33 }
34
35 void GZIPOutputStream::setComment( const string &comment ) {
36   ozf->setComment(comment);
37 }
38
39 void GZIPOutputStream::close() {
40   ozf->close() ;
41   if ( ofs )
42     ofs->close() ;
43 }
44
45
46 void GZIPOutputStream::finish() {
47   ozf->finish() ;
48 }
49
50
51 GZIPOutputStream::~GZIPOutputStream() {
52   // It's ok to call delete with a Null pointer.
53   delete ozf ;
54   delete ofs ;
55 }
56
57 } // namespace
58
59 /** \file
60     Implementation of GZIPOutputStream.
61 */
62
63 /*
64   Zipios++ - a small C++ library that provides easy access to .zip files.
65   Copyright (C) 2000  Thomas Søndergaard
66
67   This library is free software; you can redistribute it and/or
68   modify it under the terms of the GNU Lesser General Public
69   License as published by the Free Software Foundation; either
70   version 2 of the License, or (at your option) any later version.
71
72   This library is distributed in the hope that it will be useful,
73   but WITHOUT ANY WARRANTY; without even the implied warranty of
74   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
75   Lesser General Public License for more details.
76
77   You should have received a copy of the GNU Lesser General Public
78   License along with this library; if not, write to the Free Software
79   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
80 */