2 #include "zipios++/zipios-config.h" 4 #include "zipios++/meta-iostreams.h" 19 void entryToFile(
const string &ent_name, istream &is,
const string &outfile,
20 bool cerr_report =
false ) ;
24 const string name_zipfile(
"test.zip" ) ;
25 const string name_entry1 (
"file1.txt" ) ;
26 const string name_entry2 (
"file2.txt" ) ;
27 const string name_entry3 (
"file3.txt" ) ;
28 const string unzip_ext (
"unzipped" ) ;
29 const string name_uz1 ( name_entry1 + unzip_ext ) ;
30 const string name_uz2 ( name_entry2 + unzip_ext ) ;
31 const string name_uz3 ( name_entry3 + unzip_ext ) ;
32 const string diffcmd (
"diff -q " ) ;
33 const string unzipcmd (
"unzip -oq " ) ;
50 auto_ptr< istream > is( zf.getInputStream( ent ) ) ;
51 entryToFile( name_entry2, *is, name_uz2 ) ;
55 ent = zf.getEntry( name_entry1, FileCollection::IGNORE ) ;
57 auto_ptr< istream > is( zf.getInputStream( ent ) ) ;
58 entryToFile( name_entry1, *is, name_uz1 ) ;
65 entryToFile( name_entry3, zf2, name_uz3 ) ;
68 system(
string( unzipcmd + name_zipfile +
" " + name_entry1 +
" " +
69 name_entry2 +
" " + name_entry3 ).c_str() ) ;
73 return system(
string( diffcmd + name_uz1 +
" " + name_entry1 ).c_str() ) +
74 system(
string( diffcmd + name_uz2 +
" " + name_entry2 ).c_str() ) +
75 system(
string( diffcmd + name_uz3 +
" " + name_entry3 ).c_str() ) ;
77 catch( exception &excp ) {
78 cerr <<
"Exception caught in main() :" << endl ;
79 cerr << excp.what() << endl ;
85 void entryToFile(
const string &, istream &is,
const string &outfile,
87 ofstream ofs( outfile.c_str(), ios::out | ios::binary ) ;
93 cerr <<
"Stream state: " ;
94 cerr <<
"good() = " << is.good() <<
",\t" ;
95 cerr <<
"fail() = " << is.fail() <<
",\t" ;
96 cerr <<
"bad() = " << is.bad() <<
",\t" ;
97 cerr <<
"eof() = " << is.eof() << endl << endl;
Header file that defines ZipFile.
SimpleSmartPointer is a simple reference counting smart pointer template.
vector< EntryPointer > ConstEntries
ConstEntries is a vector of ConstEntryPointer's.