[plt-scheme] inflate, jar/zip compatibility?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jul 15 17:55:27 EDT 2004

At Thu, 15 Jul 2004 16:38:04 -0400 (EDT), "David A. Herman" wrote:
> The following code causes an "error in compressed data":
>     (with-input-from-file "/usr/local/j2sdk1.4.2_04/jre/lib/rt.jar"
>       (lambda ()
>         (inflate (current-input-port)
>                  (current-output-port))))
> Is this because the rt.jar file doesn't use compression, or maybe that
> it's a newer zip format?

`inflate' will decompress file content from a .jar stream, but first
you must process the header for each file.

More information on the .zip format:


The `inflate' function can be used at the point where you get to "[data
descriptor 1]". I think that `inflate' will stop before reading the
bytes for "[local file header 2]", but I'm not sure about that. If I'm
wrong, use `make-limited-input-port' to limit the number of bytes that
`inflate' can extract from the port.

There's a similar header for `gzip', which is handled by the `gunzip'
(or `gunzip-through-ports') function from "inflate.ss". But `gzip' is
different (and there's only one file).


Posted on the users mailing list.