Yunqa • The Delphi Inspiration

Delphi Components and Applications

User Tools

Site Tools


products:zipwriter:index

DIZipWriter

YuZip is a Delphi library to create, open, extract from, and modify ZIP archives with multiple algorithms for compression (deflate, bzip2, LZMA, PPMd, XZ, zStandard) and encryption (AES, PKWARE).

DIZipWriter is now YuZip

DIZipWriter has changed its name and is now superseded by the new YuZip. YuZip contains all DIZipWriter units and adds the new YuZip.pas unit: It contains a Delphi port of the popular libzip C library to open, extract from, and modify ZIP archives. Go to the new YuZip home now!.

Overview

DIZipWriter's core functionality is in its main class, TDIZipWriter. It has methods to create new ZIP archives and add ZIP file entries from different data types:

  • Files • Streams • Strings • Memory Buffers

After a ZIP file entry is added, applications can write data to it. Writing can take place in one go or in multiple chunks. There can be any number of chunks of any size, starting from an empty chunk of size zero.

TDIZipWriter writes chunk data directly to the ZIP archive with no need for temporary memory buffers or disk storage. Other than the target ZIP archive, TDIZipWriter does not create any additional files. It can also create ZIP archives enirely in memory, useful for web servers to send ZIP files quickly.

Comments are supported for each ZIP file entry, plus a global comment for the ZIP archive itself. File names of the ZIP entries are automatically encoded to support Unicode. Long file names are supported, too, just as absolute and relative path names.

Compression Algorithms

TDIZipWriter has a pluggable compressor interface. The following compressors are part of DIZipWriter. The are statically linked and require no DLLs:

TYuStoreCompressor This is not a real compressor as it stores data without compression. Fastest, largest files.
TYuDeflateCompressor Deflate dates back to 1993 and forms the basis of ZIP compression up to today. It offers fast, reasonable compression and is supported by all ZIP software.
TYuBZip2Compressor Bzip2 was first published in 1995 and achieves better compression than deflate at the cost of compression time. It is well established and supported by most ZIP software.
TYuLzmaCompressor LZMA was introduced in 1998 and with improves compression over deflate and bzip2 in most cases. Extreme compression levels can be slow, but decompression is always fast, regardless of the compression level. Support by newer ZIP software.
TYuPpmdCompressor PPMd is a highly efficient compression algorithm with exccellent compression ratios, especially for textual data. Supported by 7-zip, amongst others.
TYuXzCompressor The XZ compression format is based on LZMA and adds secure data integrity check.
TYuZstdCompressor Zstandard is a recent compression algorithm from 2016. It combines high compression ratios with short compression times. Decompression is super fast. Supported by selected ZIP software like 7-Zip zstd.

Custom compressors can be implemented by inheriting from the TYuCompressor class.

Zip64 Large File Support

DIZipWriter uses the Zip64 extension for files larger than 4 GB. This applies to the compressed and uncompressed size of a file, and the total size of the archive. Zip64 is applied automatically if needed. To keep the archive file size as low as possible, files smaller than 4 GB are stored without Zip64.

Zip64 support is compatible with all compression algorithms and encryption methods.

Direct Streaming

Direct streaming is a unique feature to DIZipWriter. It allows objects to stream their data directly to a ZIP archive using their own SaveToStream() procedure. This is very efficient because its avoids all temporary storage of, say, image or BLOB data. This is fast to code and efficient to run.

{ Save a TBitMap image to a ZIP archive. }
 
{ Create and initialize an example bitmap image. }
Img := TBitMap.Create;
 
{ Add a new entry to the ZIP archive. }
DIZipWriter.AddEntry('MyImage.bmp');
 
{ Write the bitmap to the archive's entry stream. }
Img.SaveToStream(DIZipWriter.CurrentEntryStream);
 
{ The same works to save a database BLOB. }
MyBlob.SaveToStream(DIZipWriter.CurrentEntryStream);

Encryption: Strong AES, and Standard PKZIP Algorithms

DIZipWriter can encryt data using strong AES encryption up to 256 bits. It follows the AE-1 and AE-2 Encryption Specification first introduced by WinZip 9. Many ZIP software allows to extract AES encrypted ZIP archives, for example the free 7-Zip zstd.

DIZipWriter also supported the standard PKZIP encryption, but this is considered weak and no longer recommended.

products/zipwriter/index.txt · Last modified: 2023/07/20 11:57 by 127.0.0.1