00001 00002 #include "zipios-config.h" 00003 00004 #include "meta-iostreams.h" 00005 00006 #include "gzipoutputstreambuf.h" 00007 #include "gzipoutputstream.h" 00008 00009 using std::ostream; 00010 00011 namespace zipios { 00012 00013 GZIPOutputStream::GZIPOutputStream( std::ostream &os ) 00014 : ostream( 0 ), 00015 ofs( 0 ) 00016 { 00017 ozf = new GZIPOutputStreambuf( os.rdbuf() ) ; 00018 00019 init( ozf ) ; 00020 } 00021 00022 GZIPOutputStream::GZIPOutputStream( const std::string &filename ) 00023 : ostream( 0 ), 00024 ofs( 0 ) 00025 { 00026 ofs = new std::ofstream( filename.c_str(), std::ios::out | std::ios::binary ) ; 00027 ozf = new GZIPOutputStreambuf( ofs->rdbuf() ) ; 00028 init( ozf ) ; 00029 } 00030 00031 void GZIPOutputStream::setFilename( const string &filename ) { 00032 ozf->setFilename(filename); 00033 } 00034 00035 void GZIPOutputStream::setComment( const string &comment ) { 00036 ozf->setComment(comment); 00037 } 00038 00039 void GZIPOutputStream::close() { 00040 ozf->close() ; 00041 if ( ofs ) 00042 ofs->close() ; 00043 } 00044 00045 00046 void GZIPOutputStream::finish() { 00047 ozf->finish() ; 00048 } 00049 00050 00051 GZIPOutputStream::~GZIPOutputStream() { 00052 // It's ok to call delete with a Null pointer. 00053 delete ozf ; 00054 delete ofs ; 00055 } 00056 00057 } // namespace 00058 00063 /* 00064 Zipios++ - a small C++ library that provides easy access to .zip files. 00065 Copyright (C) 2000 Thomas Søndergaard 00066 00067 This library is free software; you can redistribute it and/or 00068 modify it under the terms of the GNU Lesser General Public 00069 License as published by the Free Software Foundation; either 00070 version 2 of the License, or (at your option) any later version. 00071 00072 This library is distributed in the hope that it will be useful, 00073 but WITHOUT ANY WARRANTY; without even the implied warranty of 00074 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00075 Lesser General Public License for more details. 00076 00077 You should have received a copy of the GNU Lesser General Public 00078 License along with this library; if not, write to the Free Software 00079 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00080 */