Class Poco::Zip::Compress
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco::Zip

# class Compress

Library: Zip
Package: Zip
Header: Poco/Zip/Compress.h

## Description

Compresses a directory or files as zip.

## Member Summary

Member Functions: addDirectory, addFile, addRecursive, close, getStoreExtensions, getZipComment, setStoreExtensions, setZipComment

## Constructors

### Compress

Compress(
std::ostream & out,
bool seekableOut,
bool forceZip64 = false
);

seekableOut determines how we write the zip, setting it to true is recommended for local files (smaller zip file), if you are compressing directly to a network, you MUST set it to false If forceZip64 is set true then the file header is allocated with zip64 extension so that it can be updated after the file data is written if seekableOut is true in case the compressed or uncompressed size exceeds 32 bits.

## Destructor

### ~Compress

~Compress();

## Member Functions

### addDirectory

void addDirectory(
const Poco::Path & entryName,
const Poco::DateTime & lastModifiedAt
);

Adds a directory entry excluding all children to the Zip file, entryName must not be empty.

### addFile

void addFile(
std::istream & input,
const Poco::DateTime & lastModifiedAt,
const Poco::Path & fileName,
ZipCommon::CompressionMethod cm = ZipCommon::CM_DEFLATE,
ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM
);

Adds a single file to the Zip File. fileName must not be a directory name.

### addFile

void addFile(
const Poco::Path & file,
const Poco::Path & fileName,
ZipCommon::CompressionMethod cm = ZipCommon::CM_DEFLATE,
ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM
);

Adds a single file to the Zip File. fileName must not be a directory name. The file must exist physically!

### addRecursive

void addRecursive(
const Poco::Path & entry,
ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM,
bool excludeRoot = true,
const Poco::Path & name = Poco::Path ()
);

Adds a directory entry recursively to the zip file, set excludeRoot to false to exclude the parent directory. If excludeRoot is true you can specify an empty name to add the files as relative files

### addRecursive

void addRecursive(
const Poco::Path & entry,
ZipCommon::CompressionMethod cm,
ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM,
bool excludeRoot = true,
const Poco::Path & name = Poco::Path ()
);

Adds a directory entry recursively to the zip file, set excludeRoot to false to exclude the parent directory. If excludeRoot is true you can specify an empty name to add the files as relative files

### close

ZipArchive close();

Finalizes the ZipArchive, closes it.

### getStoreExtensions

const std::set < std::string > & getStoreExtensions() const;

Returns the file extensions for which the CM_STORE compression method is used if CM_AUTO is specified in addFile() or addRecursive().

See setStoreExtensions() for more information.

### getZipComment

const std::string & getZipComment() const;

Returns the Zip file comment.

### setStoreExtensions

void setStoreExtensions(
const std::set < std::string > & extensions
);

Sets the file extensions for which the CM_STORE compression method is used if CM_AUTO is specified in addFile() or addRecursive(). For all other extensions, CM_DEFLATE is used. This is used to avoid double compression of already compressed file formats, which usually leads to worse results. Extensions will be converted to lower case.

The default extensions are:

- gif
- jpg
- jpeg
- png

### setZipComment

void setZipComment(
const std::string & comment
);

Sets the Zip file comment.

## Variables

### EDone

Poco::FIFOEvent < const ZipLocalFileHeader > EDone;