Zipios++
|
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 , 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 return -1; 00059 } 00060 00067 /* 00068 Zipios++ - a small C++ library that provides easy access to .zip files. 00069 Copyright (C) 2000 Thomas Søndergaard 00070 00071 This library is free software; you can redistribute it and/or 00072 modify it under the terms of the GNU Lesser General Public 00073 License as published by the Free Software Foundation; either 00074 version 2 of the License, or (at your option) any later version. 00075 00076 This library is distributed in the hope that it will be useful, 00077 but WITHOUT ANY WARRANTY; without even the implied warranty of 00078 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00079 Lesser General Public License for more details. 00080 00081 You should have received a copy of the GNU Lesser General Public 00082 License along with this library; if not, write to the Free Software 00083 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00084 */