1 #ifndef ZIPOUTPUTSTREAMBUF_H
2 #define ZIPOUTPUTSTREAMBUF_H
4 #include "zipios++/zipios-config.h"
10 #include "zipios++/fcoll.h"
11 #include "zipios++/deflateoutputstreambuf.h"
12 #include "zipios++/ziphead.h"
16 /** ZipOutputStreambuf is a zip output streambuf filter. */
17 class ZipOutputStreambuf : public DeflateOutputStreambuf {
20 enum CompressionLevels { NO_COMPRESSION = Z_NO_COMPRESSION,
21 BEST_SPEED = Z_BEST_SPEED,
22 BEST_COMPRESSION = Z_BEST_COMPRESSION,
23 DEFAULT_COMPRESSION = Z_DEFAULT_COMPRESSION } ;
25 /** ZipOutputStreambuf constructor. A newly constructed ZipOutputStreambuf
26 is not ready to accept data, putNextEntry() must be invoked first.
27 @param outbuf the streambuf to use for input.
28 @param del_outbuf if true is specified outbuf will be deleted, when
29 the ZipOutputStreambuf is destructed. */
30 explicit ZipOutputStreambuf( streambuf *outbuf, bool del_outbuf = false ) ;
32 /** Closes the current entry, and positions the stream read pointer at
33 the beginning of the next entry (if there is one). */
39 /** Closes the current entry (if one is open), then writes the Zip
40 Central Directory Structure closing the ZipOutputStream. The
41 output stream that the zip archive is being written to is not
45 /** Begins writing the next entry.
46 Opens the next entry in the zip archive and returns a const pointer to a
47 FileEntry object for the entry.
48 @return a const FileEntry * containing information about the (now) current
50 void putNextEntry( const ZipCDirEntry &entry ) ;
52 /** Sets the global comment for the Zip archive. */
53 void setComment( const string &comment ) ;
55 /** Sets the compression level to be used for subsequent entries. */
56 void setLevel( int level ) ;
58 /** Sets the compression method to be used. only STORED and DEFLATED are
60 void setMethod( StorageMethod method ) ;
63 virtual ~ZipOutputStreambuf() ;
66 virtual int overflow( int c = EOF ) ;
69 void setEntryClosedState() ;
70 void updateEntryHeaderInfo() ;
72 // Should/could be moved to zipheadio.h ?!
73 static void writeCentralDirectory( const vector< ZipCDirEntry > &entries,
74 EndOfCentralDirectory eocd,
81 vector< ZipCDirEntry > _entries ;
84 StorageMethod _method ;
96 Header file that defines ZipOutputStreambuf.
100 Zipios++ - a small C++ library that provides easy access to .zip files.
101 Copyright (C) 2000 Thomas Søndergaard
103 This library is free software; you can redistribute it and/or
104 modify it under the terms of the GNU Lesser General Public
105 License as published by the Free Software Foundation; either
106 version 2 of the License, or (at your option) any later version.
108 This library is distributed in the hope that it will be useful,
109 but WITHOUT ANY WARRANTY; without even the implied warranty of
110 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
111 Lesser General Public License for more details.
113 You should have received a copy of the GNU Lesser General Public
114 License along with this library; if not, write to the Free Software
115 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA