Zlib::GzipFile
is an abstract class for handling a gzip formatted compressed file. The operations are defined in the subclasses, Zlib::GzipReader
for reading, and Zlib::GzipWriter
for writing.
GzipReader
should be used by associating an IO
, or IO-like, object.
Method
Catalogue::open (Zlib::GzipReader::open
and Zlib::GzipWriter::open
)
comment= (Zlib::GzipWriter#comment=
)
eof? (Zlib::GzipReader#eof?
)
lineno (Zlib::GzipReader#lineno
)
lineno= (Zlib::GzipReader#lineno=
)
mtime= (Zlib::GzipWriter#mtime=
)
path (when the underlying IO
supports path)
(due to internal structure, documentation may appear under Zlib::GzipReader
or Zlib::GzipWriter
)
static VALUE rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass) { return gzfile_wrap(argc, argv, klass, 0); }
Creates a GzipReader
or GzipWriter
associated with io
, passing in any necessary extra options, and executes the block with the newly created object just like File.open
.
The GzipFile
object will be closed automatically after executing the block. If you want to keep the associated IO
object open, you may call Zlib::GzipFile#finish
method in the block.
static VALUE rb_gzfile_close(VALUE obj) { struct gzfile *gz; VALUE io; TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); if (!ZSTREAM_IS_READY(&gz->z)) { return Qnil; } io = gz->io; gzfile_close(gz, 1); return io; }
Closes the GzipFile
object. This method calls close method of the associated IO
object. Returns the associated IO
object.
static VALUE rb_gzfile_closed_p(VALUE obj) { struct gzfile *gz; TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); return NIL_P(gz->io) ? Qtrue : Qfalse; }
Same as IO#closed?
static VALUE rb_gzfile_finish(VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE io; io = gz->io; gzfile_close(gz, 0); return io; }
Closes the GzipFile
object. Unlike Zlib::GzipFile#close
, this method never calls the close method of the associated IO
object. Returns the associated IO
object.
static VALUE rb_gzfile_sync(VALUE obj) { return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse; }
Same as IO#sync
static VALUE rb_gzfile_set_sync(VALUE obj, VALUE mode) { struct gzfile *gz = get_gzfile(obj); if (RTEST(mode)) { gz->z.flags |= GZFILE_FLAG_SYNC; } else { gz->z.flags &= ~GZFILE_FLAG_SYNC; } return mode; }
Same as IO
. If flag is true
, the associated IO
object must respond to the flush
method. While sync
mode is true
, the compression ratio decreases sharply.
Same as IO
.
Ruby Core © 1993–2020 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.