00001 #ifndef ZIPOUTPUTSTREAMBUF_H 00002 #define ZIPOUTPUTSTREAMBUF_H 00003 00004 #include "zipios-config.h" 00005 00006 #include <vector> 00007 00008 #include <zlib.h> 00009 00010 #include "fcoll.h" 00011 #include "deflateoutputstreambuf.h" 00012 #include "ziphead.h" 00013 00014 namespace zipios { 00015 00017 class ZipOutputStreambuf : public DeflateOutputStreambuf { 00018 public: 00019 00020 enum CompressionLevels { NO_COMPRESSION = Z_NO_COMPRESSION, 00021 BEST_SPEED = Z_BEST_SPEED, 00022 BEST_COMPRESSION = Z_BEST_COMPRESSION, 00023 DEFAULT_COMPRESSION = Z_DEFAULT_COMPRESSION } ; 00024 00030 explicit ZipOutputStreambuf( streambuf *outbuf, bool del_outbuf = false ) ; 00031 00034 void closeEntry() ; 00035 00037 void close() ; 00038 00043 void finish() ; 00044 00050 void putNextEntry( const ZipCDirEntry &entry ) ; 00051 00053 void setComment( const string &comment ) ; 00054 00056 void setLevel( int level ) ; 00057 00060 void setMethod( StorageMethod method ) ; 00061 00063 virtual ~ZipOutputStreambuf() ; 00064 00065 protected: 00066 virtual int overflow( int c = EOF ) ; 00067 virtual int sync() ; 00068 00069 void setEntryClosedState() ; 00070 void updateEntryHeaderInfo() ; 00071 00072 // Should/could be moved to zipheadio.h ?! 00073 static void writeCentralDirectory( const vector< ZipCDirEntry > &entries, 00074 EndOfCentralDirectory eocd, 00075 ostream &os ) ; 00076 00077 00078 00079 private: 00080 string _zip_comment ; 00081 vector< ZipCDirEntry > _entries ; 00082 bool _open_entry ; 00083 bool _open ; 00084 StorageMethod _method ; 00085 int _level ; 00086 }; 00087 00088 00089 } // namespace 00090 00091 00092 00093 #endif 00094 00099 /* 00100 Zipios++ - a small C++ library that provides easy access to .zip files. 00101 Copyright (C) 2000 Thomas Søndergaard 00102 00103 This library is free software; you can redistribute it and/or 00104 modify it under the terms of the GNU Lesser General Public 00105 License as published by the Free Software Foundation; either 00106 version 2 of the License, or (at your option) any later version. 00107 00108 This library is distributed in the hope that it will be useful, 00109 but WITHOUT ANY WARRANTY; without even the implied warranty of 00110 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00111 Lesser General Public License for more details. 00112 00113 You should have received a copy of the GNU Lesser General Public 00114 License along with this library; if not, write to the Free Software 00115 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00116 */