Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.zip
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.
- Bugzilla 592
- Bugzilla 1832
- Bugzilla 2137
- Bugzilla 2138
License:
Authors:
Source: std/zip.d
- class ZipException: object.Exception;
- Thrown on error.
- enum CompressionMethod: ushort;
- Compression method used by ArchiveMember
- class ArchiveMember;
- A member of the ZipArchive.
- string name;
- ubyte[] extra;
- string comment;
- ushort flags;
- Read/Write: normally set to 0
- ushort internalAttributes;
- Read/Write
- @property ushort extractVersion();
- Read Only
- @property uint crc32();
- Read Only: cyclic redundancy check (CRC) value
- @property uint compressedSize();
- Read Only: size of data of member in compressed form.
- @property uint expandedSize();
- Read Only: size of data of member in expanded form.
- @property ushort diskNumber();
- Read Only: should be 0.
- @property ubyte[] compressedData();
- Read Only: data of member in compressed form.
- @property ubyte[] expandedData();
- Read data of member in uncompressed form.
- @property void expandedData(ubyte[] ed);
- Write data of member in uncompressed form.
- @property void fileAttributes(uint attr);
- Set the OS specific file attributes, as obtained by std.file.getAttributes or std.file.DirEntry.attributes, for this archive member.
- const @property uint fileAttributes();
- Get the OS specific file attributes for the archive member.Returns:The file attributes or 0 if the file attributes were encoded for an incompatible OS (Windows vs. Posix).
- @property void time(SysTime time);
@property void time(DosFileTime time); - const @property DosFileTime time();
- @property CompressionMethod compressionMethod();
- Read compression method used for this memberSee Also:CompressionMethod
- @property void compressionMethod(CompressionMethod cm);
- Write compression method used for this memberSee Also:CompressionMethod
- class ZipArchive;
- Object representing the entire archive. ZipArchives are collections of ArchiveMembers.
- string comment;
- @property ubyte[] data();
- Read Only: array representing the entire contents of the archive.
- @property uint diskNumber();
- Read Only: 0 since multi-disk zip archives are not supported.
- @property uint diskStartDir();
- Read Only: 0 since multi-disk zip archives are not supported
- @property uint numEntries();
@property uint totalEntries(); - Read Only: number of ArchiveMembers in the directory.
- @property ArchiveMember[string] 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:
Example:
ZipArchive archive = new ZipArchive(data); foreach (ArchiveMember am; archive.directory) { writefln("member name is '%s'", am.name); }
- this();
- Constructor to use 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[].Returns:array representing the entire archive.
- this(void[] buffer);
- Constructor to use when reading an existing 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.Parameters:
void[] buffer the entire contents of the archive. - 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[].