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