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 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083