new(p1)
public
Creates a GzipReader object associated with io. The GzipReader
object reads gzipped data from io, and parses/decompresses them.
At least, io must have a read method that behaves same as
the read method in IO class.
If the gzip file header is incorrect, raises an Zlib::GzipFile::Error exception.
Show source
/*
* call-seq: Zlib::GzipReader.new(io)
*
* Creates a GzipReader object associated with +io+. The GzipReader object reads
* gzipped data from +io+, and parses/decompresses them. At least, +io+ must have
* a +read+ method that behaves same as the +read+ method in IO class.
*
* If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
* exception.
*/
static VALUE
rb_gzreader_initialize(obj, io)
VALUE obj, io;
{
struct gzfile *gz;
int err;
Data_Get_Struct(obj, struct gzfile, gz);
/* this is undocumented feature of zlib */
err = inflateInit2(&gz->z.stream, -MAX_WBITS);
if (err != Z_OK) {
raise_zlib_error(err, gz->z.stream.msg);
}
gz->io = io;
ZSTREAM_READY(&gz->z);
gzfile_read_header(gz);
return obj;
}