## wxZipOutputStream

Output stream for writing zip files.

PutNextEntry() is used to create a new entry in the output zip, then the entry's data is written to the wxZipOutputStream. Another call to PutNextEntry() closes the current entry and begins the next.

Derived from

wxArchiveOutputStream

Include files

<wx/zipstrm.h>

See also

Archive formats such as zip
wxZipEntry
wxZipInputStream

Members

wxZipOutputStream::wxZipOutputStream
wxZipOutputStream::~wxZipOutputStream
wxZipOutputStream::Close
wxZipOutputStream::CloseEntry
wxZipOutputStream::CopyArchiveMetaData
wxZipOutputStream::CopyEntry
wxZipOutputStream::Get/SetLevel
wxZipOutputStream::PutNextDirEntry
wxZipOutputStream::PutNextEntry
wxZipOutputStream::SetComment

### wxZipOutputStream::wxZipOutputStream

wxZipOutputStream(wxOutputStream& stream, int level = -1, wxMBConv& conv = wxConvLocal)

wxZipOutputStream(wxOutputStream*stream, int level = -1, wxMBConv& conv = wxConvLocal)

Constructor. `level` is the compression level to use. It can be a value between 0 and 9 or -1 to use the default value which currently is equivalent to 6.

If the parent stream is passed as a pointer then the new filter stream takes ownership of it. If it is passed by reference then it does not.

In a Unicode build the third parameter `conv` is used to translate the filename and comment fields to an 8-bit encoding. It has no effect on the stream's data.

### wxZipOutputStream::~wxZipOutputStream

~wxZipOutputStream()

The destructor calls Close() to finish writing the zip if it has not been called already.

### wxZipOutputStream::Close

bool Close()

Finishes writing the zip, returning true if successful. Called by the destructor if not called explicitly.

### wxZipOutputStream::CloseEntry

bool CloseEntry()

Close the current entry. It is called implicitly whenever another new entry is created with CopyEntry() or PutNextEntry(), or when the zip is closed.

### wxZipOutputStream::CopyArchiveMetaData

bool CopyArchiveMetaData(wxZipInputStream& inputStream)

Transfers the zip comment from the wxZipInputStream to this output stream.

### wxZipOutputStream::CopyEntry

bool CopyEntry(wxZipEntry* entry, wxZipInputStream& inputStream)

Takes ownership of `entry` and uses it to create a new entry in the zip. `entry` is then opened in `inputStream` and its contents copied to this stream.

CopyEntry() is much more efficient than transferring the data using Read() and Write() since it will copy them without decompressing and recompressing them.

For zips on seekable streams, `entry` must be from the same zip file as `stream`. For non-seekable streams, `entry` must also be the last thing read from `inputStream`.

### wxZipOutputStream::Get/SetLevel

int GetLevel() const

void SetLevel(int level)

Set the compression level that will be used the next time an entry is created. It can be a value between 0 and 9 or -1 to use the default value which currently is equivalent to 6.

### wxZipOutputStream::PutNextDirEntry

bool PutNextDirEntry(const wxString& name, const wxDateTime& dt = wxDateTime::Now())

Create a new directory entry (see wxArchiveEntry::IsDir()) with the given name and timestamp.

PutNextEntry() can also be used to create directory entries, by supplying a name with a trailing path separator.

### wxZipOutputStream::PutNextEntry

bool PutNextEntry(wxZipEntry* entry)

Takes ownership of `entry` and uses it to create a new entry in the zip.

bool PutNextEntry(const wxString& name, const wxDateTime& dt = wxDateTime::Now(), off_t size = wxInvalidOffset)

Create a new entry with the given name, timestamp and size.

### wxZipOutputStream::SetComment

void SetComment(const wxString& comment)

Sets a comment for the zip as a whole. It is written at the end of the zip.