Main Page   Class Hierarchy   Compound List   File List   Compound Members  

test_appzip.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++/fcollexceptions.h"
00008 #include "zipios++/zipfile.h"
00009 
00010 using namespace zipios ;
00011 
00012 using std::cerr ;
00013 using std::cout ;
00014 using std::endl ;
00015 using std::auto_ptr ;
00016 
00017 int main( int argc, char *argv[] ) {
00018   try {
00019   
00020     cout << "Instantiating a ZipFile" << endl ;
00021     ZipFile zf = ZipFile::openEmbeddedZipFile( argv[ 0 ] ) ;
00022     
00023     cout << "list length : " << zf.size() << endl ;
00024     
00025     ConstEntries entries ;
00026     entries = zf.entries() ;
00027     
00028     
00029     ConstEntries::iterator it ;
00030     for( it = entries.begin() ; it != entries.end() ; it++)
00031       cout << *(*it) << endl ;
00032     
00033     ConstEntryPointer ent = zf.getEntry( "file2.txt", FileCollection::IGNORE ) ;
00034     if ( ent != 0 ) {
00035       auto_ptr< istream > is( zf.getInputStream( ent ) ) ;
00036       
00037       cout << "Contents of entry, " << ent->getName() << " :" << endl ;
00038 
00039       cout << is->rdbuf() ;
00040     }
00041     cout << "end of main()" << endl ;
00042     
00043     return 0 ;
00044   }
00045   catch( FCollException &excp ) {
00046     cerr << "Exception caught in main() :" << endl ;
00047     cerr << excp.what() << endl ;
00048     cerr << "\nThe invalid virtual endings exception very probably means that\n" 
00049          <<   "this program hasn't had a zip file appended to it with 'appendzip'\n" 
00050          << "\nTry the following command and re-run " << argv[ 0 ] << " :\n"
00051          << "  ./appendzip " << argv[ 0 ] << " test.zip\n" 
00052          << endl ;
00053   }
00054   catch( exception &excp ) {
00055     cerr << "Exception caught in main() :" << endl ;
00056     cerr << excp.what() << endl ;
00057   }
00058 }
00059 
00066 /*
00067   Zipios++ - a small C++ library that provides easy access to .zip files.
00068   Copyright (C) 2000  Thomas Søndergaard
00069   
00070   This library is free software; you can redistribute it and/or
00071   modify it under the terms of the GNU Lesser General Public
00072   License as published by the Free Software Foundation; either
00073   version 2 of the License, or (at your option) any later version.
00074   
00075   This library is distributed in the hope that it will be useful,
00076   but WITHOUT ANY WARRANTY; without even the implied warranty of
00077   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00078   Lesser General Public License for more details.
00079   
00080   You should have received a copy of the GNU Lesser General Public
00081   License along with this library; if not, write to the Free Software
00082   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00083 */

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