www.digitalmars.com Home | Search | D | Comments
Last update Mon Aug 22 2005
D
Language
Phobos
Comparisons


object

std
 std.base64
 std.boxer
 std.compiler
 std.conv
 std.ctype
 std.date
 std.file
 std.format
 std.gc
 std.intrinsic
 std.math
 std.md5
 std.mmfile
 std.openrj
 std.outbuffer
 std.path
 std.process
 std.random
 std.recls
 std.regexp
 std.socket
 std.socketstream
 std.stdint
 std.stdio
 std.cstream
 std.stream
 std.string
 std.system
 std.thread
 std.uri
 std.utf
 std.zip
 std.zlib

std.windows

std.linux

std.c
 std.c.stdio

std.c.windows

std.c.linux

std.zip

Read/write data in the zip archive format. Makes use of the zlib compression library.
class ZipException
Thrown on error.

class ZipArchive
Object representing the entire archive. ZipArchives are collections of ArchiveMembers.

this()
Constructor used when creating a new archive.

void addMember(ArchiveMember de)
Add de to the archive.

void deleteMember(ArchiveMember de)
Delete de from the archive.

void[] build()
Construct an archive out of the current members of the archive. Fills in the properties data[], diskNumber, diskStartDir, numEntries, totalEntries, and directory[]. For each ArchiveMember, fills in properties crc32, compressedSize, compressedData[]. Return array representing the entire archive.

this(void[] data)
Constructor used when reading an existing archive. data[] is the entire contents of the archive. Fills in the properties data[], diskNumber, diskStartDir, numEntries, totalEntries, comment[], and directory[]. For each ArchiveMember, fills in properties madeVersion, extractVersion, flags, compressionMethod, time, crc32, compressedSize, expandedSize, compressedData[], diskNumber, internalAttributes, externalAttributes, name[], extra[], comment[]. Use expand() to get the expanded data for each ArchiveMember.

ubyte[] expand(ArchiveMember de)
Decompress the contents of archive member de and return the expanded data. Fills in properties extractVersion, flags, compressionMethod, time, crc32, compressedSize, expandedSize, expandedData[], name[], extra[].

ubyte[] data
Read Only: array representing the entire contents of the archive.

uint diskNumber
Read Only: 0 since multi-disk zip archives are not supported.

uint diskStartDir
Read Only: 0 since multi-disk zip archives are not supported.

uint numEntries
Read Only: number of ArchiveMembers in the directory.

uint totalEntries
Read Only: same as totalEntries.

char[] comment
Read/Write: the archive comment. Must be less than 65536 bytes in length.

ArchiveMember[char[]] directory
Read Only: array indexed by the name of each member of the archive. All the members of the archive can be accessed with a foreach loop:

ZipArchive archive = new ZipArchive(data);
foreach (ArchiveMember am; archive)
{
    printf("member name is '%.*s'\n", am.name);
}

class ArchiveMember
A member of the ZipArchive.

ushort madeVersion
Read Only

ushort extractVersion
Read Only

ushort flags
Read/Write: normally set to 0

ushort compressionMethod
Read/Write: the only supported values are 0 (no compression) and 8 (deflate).

date.DosFileTime time
Read/Write: Last modified time of the member. It's in the DOS date/time format.

uint crc32
Read Only: cyclic redundancy check (CRC) value

uint compressedSize
Read Only: size of data of member in compressed form.

uint expandedSize
Read Only: size of data of member in expanded form.

ushort diskNumber
Read Only: should be 0.

ushort internalAttributes
Read/Write

uint externalAttributes
Read/Write

char[] name
Read/Write: Usually the file name of the archive member; it is used to index the archive directory for the member. Each member must have a unique name[]. Do not change without removing member from the directory first.

ubyte[] extra
Read/Write: extra data for this member.

char[] comment
Read/Write: comment associated with this member.

ubyte[] compressedData
Read Only: data of member in compressed form.

ubyte[] expandedData
Read/Write: data of member in uncompressed form.
Bugs:
  • Multi-disk zips not supported.
  • Only Zip version 20 formats are supported.
  • Only supports compression modes 0 (no compression) and 8 (deflate).
  • Does not support encryption.

Feedback and Comments

Add feedback and comments regarding this page.
Copyright © 1999-2005 by Digital Mars, All Rights Reserved