On this page:
gunzip
gunzip-through-ports
inflate

3 gzip Decompression

 (require file/gunzip) package: base
The file/gunzip library provides utilities to decompress archive files in gzip format, or simply to decompress data using the pkzip “inflate” method.

procedure

(gunzip file [output-name-filter])  void?

  file : path-string?
  output-name-filter : (string? boolean? . -> . path-string?)
   = (lambda (file archive-supplied?) file)
Extracts data that was compressed using the gzip utility (or gzip function), writing the uncompressed data directly to a file. The file argument is the name of the file containing compressed data. The default output file name is the original name of the compressed file as stored in file. If a file by this name exists, it will be overwritten. If no original name is stored in the source file, "unzipped" is used as the default output file name.

The output-name-filter procedure is applied to two arguments—the default destination file name and a boolean that is #t if this name was read from filebefore the destination file is created. The return value of the file is used as the actual destination file name (to be opened with the 'truncate flag of open-output-file).

If the compressed data turns out to be corrupted, the exn:fail exception is raised.

procedure

(gunzip-through-ports in out)  void?

  in : input-port?
  out : output-port?
Reads the port in for compressed data that was created using the gzip utility, writing the uncompressed data to the port out.

If the compressed data turns out to be corrupted, the exn:fail exception is raised. The unzipping process may peek further into in than needed to decompress the data, but it will not consume the unneeded bytes.

procedure

(inflate in out)  void?

  in : input-port?
  out : output-port?
Reads pkzip-format “deflated” data from the port in and writes the uncompressed (“inflated”) data to the port out. The data in a file created by gzip uses this format (preceded with some header information).

If the compressed data turns out to be corrupted, the exn:fail exception is raised. The inflate process may peek further into in than needed to decompress the data, but it will not consume the unneeded bytes.