00001 #ifndef ZIPOUTPUTSTREAMBUF_H
00002 #define ZIPOUTPUTSTREAMBUF_H
00003
00004 #include "zipios++/zipios-config.h"
00005
00006 #include <vector>
00007
00008 #include <zlib.h>
00009
00010 #include "zipios++/fcoll.h"
00011 #include "zipios++/deflateoutputstreambuf.h"
00012 #include "zipios++/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
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 }
00090
00091
00092
00093 #endif
00094
00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116