Main Page   Class Hierarchy   Compound List   File List   Compound Members  

example_zip.cpp

Go to the documentation of this file.
00001 
00002 #include "zipios++/zipios-config.h"
00003 
00004 #include "zipios++/meta-iostreams.h"
00005 #include <memory>
00006 
00007 #include "zipios++/zipfile.h"
00008 
00009 using namespace zipios ;
00010 
00011 using std::cerr ;
00012 using std::cout ;
00013 using std::endl ;
00014 using std::auto_ptr ;
00015 
00016 int main() {
00017   try {
00018   
00019     cout << "Instantiating a ZipFile" << endl ;
00020     ZipFile zf( "test.zip" ) ;
00021     
00022     cout << "list length : " << zf.size() << endl ;
00023     
00024     ConstEntries entries ;
00025     entries = zf.entries() ;
00026     
00027     
00028     ConstEntries::iterator it ;
00029     for( it = entries.begin() ; it != entries.end() ; it++)
00030       cout << *(*it) << endl ;
00031     
00032     ConstEntryPointer ent = zf.getEntry( "file2.txt", FileCollection::IGNORE ) ;
00033     if ( ent != 0 ) {
00034       auto_ptr< istream > is( zf.getInputStream( ent ) ) ;
00035       
00036       cout << "Contents of entry, " << ent->getName() << " :" << endl ;
00037       
00038       cout << is->rdbuf() ;
00039     }
00040     cout << "end of main()" << endl ;
00041     
00042     return 0 ;
00043   }
00044   catch( exception &excp ) {
00045     cerr << "Exception caught in main() :" << endl ;
00046     cerr << excp.what() << endl ;
00047   }
00048 }
00049 
00056 /*
00057   Zipios++ - a small C++ library that provides easy access to .zip files.
00058   Copyright (C) 2000  Thomas Søndergaard
00059   
00060   This library is free software; you can redistribute it and/or
00061   modify it under the terms of the GNU Lesser General Public
00062   License as published by the Free Software Foundation; either
00063   version 2 of the License, or (at your option) any later version.
00064   
00065   This library is distributed in the hope that it will be useful,
00066   but WITHOUT ANY WARRANTY; without even the implied warranty of
00067   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00068   Lesser General Public License for more details.
00069   
00070   You should have received a copy of the GNU Lesser General Public
00071   License along with this library; if not, write to the Free Software
00072   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00073 */

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