Zipios++
|
00001 #include "zipios++/zipios-config.h" 00002 00003 #include "zipios++/meta-iostreams.h" 00004 #include <string> 00005 #include <exception> 00006 00007 #include "zipios++/gzipoutputstream.h" 00008 00009 using namespace zipios ; 00010 00011 using std::cerr ; 00012 using std::cout ; 00013 using std::endl ; 00014 using std::ifstream ; 00015 using std::ofstream ; 00016 using std::ios ; 00017 using std::string ; 00018 using std::exception ; 00019 00020 void writeFileToGZIPOutputStream( GZIPOutputStream &zos, const string &filename ) ; 00021 00022 int main() { 00023 try { 00024 00025 GZIPOutputStream ozs("zos.gz") ; 00026 00027 writeFileToGZIPOutputStream( ozs, "test.xml" ) ; 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 return -1; 00038 } 00039 00040 void writeFileToGZIPOutputStream( GZIPOutputStream &zos, const string &filename ) { 00041 00042 ifstream ifs( filename.c_str(), ios::in | ios::binary ) ; 00043 00044 zos.setFilename(filename); 00045 zos.setComment("ZIPIOS++ TestFile"); 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 */