# wxZipOutputStream Class Reference
[Archive support, Streams]

`#include <wx/zipstrm.h>`

Inheritance diagram for wxZipOutputStream:
[legend]

## Detailed Description

Output stream for writing zip files.

wxZipOutputStream::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 wxZipOutputStream::PutNextEntry() closes the current entry and begins the next.

##

Library: wxBase

Category: Archive support, Streams

See also:
  Archive Formats, wxZipEntry, wxZipInputStream

## Public Member Functions
virtual | ~wxZipOutputStream ()
| The destructor calls Close() to finish writing the zip if it has not been called already.
bool | Close ()
| Finishes writing the zip, returning true if successful.
bool | CloseEntry ()
| Close the current entry.
bool | CopyArchiveMetaData (wxZipInputStream &inputStream)
| Transfers the zip comment from the wxZipInputStream to this output stream.
bool | CopyEntry (wxZipEntry *entry, wxZipInputStream &inputStream)
| Takes ownership of entry and uses it to create a new entry in the zip.
bool | PutNextDirEntry (const wxString &name, const wxDateTime &dt=wxDateTime::Now())
| Create a new directory entry (see wxArchiveEntry::IsDir) with the given name and timestamp.
void | SetComment (const wxString &comment)
| Sets a comment for the zip as a whole.
| wxZipOutputStream (wxOutputStream &stream, int level=-1, wxMBConv &conv=wxConvLocal)
| Constructor.
| wxZipOutputStream (wxOutputStream *stream, int level=-1, wxMBConv &conv=wxConvLocal)
| Constructor.
int | GetLevel () const
| Set the compression level that will be used the next time an entry is created.
void | SetLevel (int level)
| Set the compression level that will be used the next time an entry is created.
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(), wxFileOffset size=wxInvalidOffset)
| Create a new entry with the given name, timestamp and size.

List of all members.

## Constructor & Destructor Documentation

wxZipOutputStream::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 | ( | 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.

virtual wxZipOutputStream::~wxZipOutputStream | ( |  | ) | `[virtual]`

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

## Member Function Documentation

bool wxZipOutputStream::Close | ( |  | ) | `[virtual]`

Finishes writing the zip, returning true if successful.

Called by the destructor if not called explicitly.

Reimplemented from wxArchiveOutputStream.

bool wxZipOutputStream::CloseEntry | ( |  | ) | `[virtual]`

Close the current entry.

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

Implements wxArchiveOutputStream.

bool wxZipOutputStream::CopyArchiveMetaData | ( | wxZipInputStream & | inputStream | ) |

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

bool wxZipOutputStream::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 inputStream. For non-seekable streams, entry must also be the last thing read from inputStream.

int wxZipOutputStream::GetLevel | ( |  | ) | const

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.

bool wxZipOutputStream::PutNextDirEntry | ( | const wxString & | name,
|  | const wxDateTime & | dt = `wxDateTime::Now()` |
| ) |  |  | `[virtual]`

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.

Implements wxArchiveOutputStream.

bool wxZipOutputStream::PutNextEntry | ( | const wxString & | name,
|  | const wxDateTime & | dt = `wxDateTime::Now()`,
|  | wxFileOffset | size = `wxInvalidOffset` |
| ) |  |  | `[virtual]`

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

Implements wxArchiveOutputStream.

bool wxZipOutputStream::PutNextEntry | ( | wxZipEntry * | entry | ) |

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

void wxZipOutputStream::SetComment | ( | const wxString & | comment | ) |

Sets a comment for the zip as a whole.

It is written at the end of the zip.

void wxZipOutputStream::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.

|  | [ top ]