00001
00002
00003 #include "zipios++/zipios-config.h"
00004
00005 #include "zipios++/meta-iostreams.h"
00006 #include <memory>
00007
00008 #include "zipios++/dircoll.h"
00009 #include "zipios++/zipfile.h"
00010 #include "zipios++/collcoll.h"
00011
00012 using namespace zipios ;
00013
00014 using std::cerr ;
00015 using std::cout ;
00016 using std::endl ;
00017 using std::auto_ptr ;
00018
00019 int main() {
00020 try {
00021
00022 cout << "Instantiating a DirectoryCollection" << endl ;
00023 DirectoryCollection dircoll( "." ) ;
00024
00025 cout << "Instantiating a ZipFile" << endl ;
00026 ZipFile zipfile( "test.zip" ) ;
00027
00028 cout << "Instantiating a CollectionCollection" << endl ;
00029 CollectionCollection collcoll_orig ;
00030
00031 cout << "Adding the zip file and directory collection to the collection collection"
00032 << endl ;
00033 if ( ! collcoll_orig.addCollection( zipfile ) ) {
00034 cerr << "Failed to add the zip file" << endl ;
00035 return 1 ;
00036 }
00037 if ( ! collcoll_orig.addCollection( dircoll ) ) {
00038 cerr << "Failed to add the zip file" << endl ;
00039 return 1 ;
00040 }
00041
00042 CollectionCollection collcoll( collcoll_orig ) ;
00043 CColl::inst() = collcoll ;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 ConstEntryPointer ent = CColl::inst().getEntry( "file2.txt" ) ;
00065 if ( ent != 0 ) {
00066 auto_ptr< istream > is( CColl::inst().getInputStream( ent ) ) ;
00067
00068 cout << "Contents of entry, " << ent->getName() << " :" << endl ;
00069
00070 cout << is->rdbuf() ;
00071 }
00072
00073 ent = CColl::inst().getEntry( "flistentry.cpp" ) ;
00074 if ( ent != 0 ) {
00075 auto_ptr< istream > is( CColl::inst().getInputStream( ent ) ) ;
00076
00077 cout << "Contents of entry, " << ent->getName() << " :" << endl ;
00078
00079 cout << is->rdbuf() ;
00080 }
00081 cout << "end of main()" << endl ;
00082
00083 return 0 ;
00084 }
00085 catch( exception &excp ) {
00086 cerr << "Exception caught in main() :" << endl ;
00087 cerr << excp.what() << endl ;
00088 }
00089 }
00090
00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114