00001 #include "zipios++/zipios-config.h"
00002
00003 #include "zipios++/meta-iostreams.h"
00004 #include <string>
00005
00006 #include "zipios++/zipoutputstream.h"
00007
00008 using namespace zipios ;
00009
00010 using std::cerr ;
00011 using std::cout ;
00012 using std::endl ;
00013 using std::ifstream ;
00014 using std::ios ;
00015 using std::string ;
00016
00017 void writeFileToZipOutputStream( ZipOutputStream &zos, const string &filename ) ;
00018
00019 int main() {
00020 try {
00021
00022 ZipOutputStream ozs( "zos.zip" ) ;
00023
00024 writeFileToZipOutputStream( ozs, "test_zip" ) ;
00025 writeFileToZipOutputStream( ozs, "test_dircoll" ) ;
00026 writeFileToZipOutputStream( ozs, "test.zip" ) ;
00027 writeFileToZipOutputStream( ozs, "test_simplesmartptr" ) ;
00028 writeFileToZipOutputStream( ozs, "test_appzip" ) ;
00029
00030 cerr << "End of main" << endl ;
00031
00032 return 0;
00033 }
00034 catch( exception &excp ) {
00035 cerr << "Exception caught in main() :" << endl ;
00036 cerr << excp.what() << endl ;
00037 }
00038 return -1;
00039 }
00040
00041 void writeFileToZipOutputStream( ZipOutputStream &zos, const string &filename ) {
00042 zos.putNextEntry( ZipCDirEntry( filename ) ) ;
00043
00044 ifstream ifs( filename.c_str(), ios::in | ios::binary ) ;
00045
00046 zos << ifs.rdbuf() ;
00047
00048 cerr << "ostream Stream state: " ;
00049 cerr << "good() = " << zos.good() << ",\t" ;
00050 cerr << "fail() = " << zos.fail() << ",\t" ;
00051 cerr << "bad() = " << zos.bad() << ",\t" ;
00052 cerr << "eof() = " << zos.eof() << endl ;
00053
00054 cerr << "istream Stream state: " ;
00055 cerr << "good() = " << ifs.good() << ",\t" ;
00056 cerr << "fail() = " << ifs.fail() << ",\t" ;
00057 cerr << "bad() = " << ifs.bad() << ",\t" ;
00058 cerr << "eof() = " << ifs.eof() << endl ;
00059
00060 }
00061
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083