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