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