Main Page   Class Hierarchy   Compound List   File List   Compound Members  

test_zipoutputstream.cpp

Go to the documentation of this file.
00001 #include "zipios++/zipios-config.h"
00002 
00003 #include "zipios++/meta-iostreams.h"
00004 #include <string>
00005 
00006 #include "zipios++/zipoutputstream.h"
00007 
00008 using namespace zipios ;
00009 
00010 using std::ifstream ;
00011 using std::cout ;
00012 using std::cerr ;
00013 using std::endl ;
00014 using std::string ;
00015 
00016 void writeFileToZipOutputStream( ZipOutputStream &zos, const string &filename ) ;
00017 
00018 int main() {
00019   try {
00020 
00021     ZipOutputStream ozs( "zos.zip" ) ;
00022     
00023     writeFileToZipOutputStream( ozs, "test_zip" ) ;
00024     writeFileToZipOutputStream( ozs, "test_dircoll" ) ;
00025     writeFileToZipOutputStream( ozs, "test.zip" ) ;
00026     writeFileToZipOutputStream( ozs, "test_simplesmartptr" ) ;
00027     writeFileToZipOutputStream( ozs, "test_appzip" ) ;
00028     
00029     cerr << "End of main" << endl ;
00030     
00031     return 0;
00032   }
00033   catch( exception &excp ) {
00034     cerr << "Exception caught in main() :" << endl ;
00035     cerr << excp.what() << endl ;
00036   }
00037 }
00038 
00039 void writeFileToZipOutputStream( ZipOutputStream &zos, const string &filename ) {
00040   zos.putNextEntry( ZipCDirEntry( filename ) ) ;
00041 
00042   ifstream ifs( filename.c_str(), ios::in | ios::binary ) ;
00043 
00044   zos << ifs.rdbuf() ; 
00045 
00046   cerr << "ostream Stream state: "  ;
00047   cerr << "good() = " << zos.good() << ",\t" ;
00048   cerr << "fail() = " << zos.fail() << ",\t" ;
00049   cerr << "bad()  = " << zos.bad()  << ",\t" ;
00050   cerr << "eof()  = " << zos.eof()  << endl  ;
00051 
00052   cerr << "istream Stream state: "  ;
00053   cerr << "good() = " << ifs.good() << ",\t" ;
00054   cerr << "fail() = " << ifs.fail() << ",\t" ;
00055   cerr << "bad()  = " << ifs.bad()  << ",\t" ;
00056   cerr << "eof()  = " << ifs.eof()  << endl  ;
00057 
00058 }
00059 
00064 /*
00065   Zipios++ - a small C++ library that provides easy access to .zip files.
00066   Copyright (C) 2000  Thomas Søndergaard
00067   
00068   This library is free software; you can redistribute it and/or
00069   modify it under the terms of the GNU Lesser General Public
00070   License as published by the Free Software Foundation; either
00071   version 2 of the License, or (at your option) any later version.
00072   
00073   This library is distributed in the hope that it will be useful,
00074   but WITHOUT ANY WARRANTY; without even the implied warranty of
00075   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00076   Lesser General Public License for more details.
00077   
00078   You should have received a copy of the GNU Lesser General Public
00079   License along with this library; if not, write to the Free Software
00080   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00081 */

Generated at Tue Aug 14 20:39:26 2001 for Zipios++ by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000