zipoutputstream.cpp

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

Generated on Wed Nov 23 19:01:12 2011 for FreeCAD by  doxygen 1.6.1