AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
ZipEntry typedict
 
A ZipEntry is the Yoix representation of the Java ZipEntry class. This data type is primarily intended to be used when reading or writing ZIPPED streams. Consequently, much of what is described here is in that context.

When written out by one of the Yoix stream types, which rely on Java, the complete set of ZipEntry fields are written to the zip central directory, which is at the end of a zip byte stream, but only the name, extra and timestamp fields are written to the LOC headers within the sequence of the stream. Moreover, if compression is active (i.e., if deflated is non-zero), the crc and size fields are updated when the central directory is written. Furthermore, timestamp field is always reflects the time the entry contents were actually put on the stream when that field written to the central directory, regardless of how it was set. Finally, when the deflated field is zero, then the crc and size fields must be supplied and must be accurate. The comment field, though not written in the LOC header, is written to the central directory with whatever value was assigned to it. When reading a zip byte stream sequentially, the LOC headers are encountered before each corresponding content area and the central directory is never accessed. Fortunately, the entries in the central directory can be retrieved by means of the .BR getZipEntries built-in. The fields in a ZipEntry are:
comment A String for commenting the ZipEntry. When supplied, the value computed for it by the utf8len built-in must be in the range between 0 and 0xFFFF, inclusive. See also the extra field, below, as an alternative to this field.
compressedsize A double field that gives the compressed size, in bytes, of the entry content. It cannot be set by the user. It is set when written to the central directory. When no compression is used, it has the same value as the size field.
crc A double field that indicates the crc encoding value for the content. When no compression is used, an accurate value must be supplied. When compression is used, the value is calculated. When supplied, its value must be in the range between 0 and 0xFFFFFFFF, inclusive.
deflated An int field that indicates, when non-zero, that the entry content is compressed.
extra When supplied, the value computed for it by the utf8len built-in must be in the range between 0 and 0xFFFF, inclusive.
name A String value indicating the name of this ZipEntry instance. The value computed for this field by the utf8len built-in must be in the range between 0 and 0xFFFF, inclusive. A name value ending in a slash (/) is considered to indicate a directory. When assigned, the timestamp field is updated.
size A double field that indicates the uncompressed size, in bytes, of the content. When no compression is used, an accurate value must be supplied. When compression is used, the value is calculated. When supplied, its value must be in the range between 0 and 0xFFFFFFFF, inclusive. The direct implication is that the content should not exceed 0xFFFFFFFF, (i.e., 4,294,967,295) bytes.
timestamp A double used to stamp the time of the entry in seconds since January 1, 1970 00:00:00 GMT. It is initialized with the current time and that value, or whatever value the user supplies, is written in the LOC header. The time that the entry is actually written is put into the central directory. As an extra quirk, whenever the value is set to less than 315,550,800 seconds, it resets to that value. Apparently, since the zip format was developed in the PC environment, the assumption is that time did not exist before January 1, 1980 00:00:00 EST.
Several permanent fields have not been documented and should not be used in Yoix applications.
 
 Example:   The following script opens a jar or zip file and displays its contents. You will note that many of the ZipEntry fields are not filled in since they are from the LOC headers. See the documentation of the getZipEntries built-in for an example that shows how to get the contents of the central directory of entries.
import yoix.*.*;

File f = {
    String name = argc > 1 ? argv[1] : "Tests/test.jar";
    int    mode = READ;
    int    filters = ZIPPED;
    int    open = TRUE;
};

ZipEntry ze;
String data;

while (ze = f.nextentry) {
    fprintf(stdout, "name=%s\n", ze.name);
    fprintf(stdout, "\tcomment=%s\n", ze.comment);
    fprintf(stdout, "\tcompressedsize=%d\n", ze.compressedsize);
    fprintf(stdout, "\tcrc=%d\n", ze.crc);
    fprintf(stdout, "\tdeflated=%d\n", ze.deflated);
    fprintf(stdout, "\textra=%s\n", ze.extra);
    fprintf(stdout, "\tsize=%d\n", ze.size);
    fprintf(stdout, "\ttimestamp=%s\n", date(ze.timestamp));
    stdout.nextline = "==========";
    while (data = f.nextline)
	stdout.nextline = data;
    stdout.nextline = "==========";
}

f.open = FALSE;
 
 See Also:   File, getZipEntries, getZipMember, StringStream, URL, utf8len

 

Yoix is a registered trademark of AT&T Inc.