Class: Zstdlib::GzipFile
- Inherits:
-
Object
- Object
- Zstdlib::GzipFile
- Defined in:
- ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c
Overview
Zstdlib::GzipFile is an abstract class for handling a gzip formatted compressed file. The operations are defined in the subclasses, Zstdlib::GzipReader for reading, and Zstdlib::GzipWriter for writing.
GzipReader should be used by associating an IO, or IO-like, object.
== Method Catalogue
- ::wrap
- ::open (Zstdlib::GzipReader::open and Zstdlib::GzipWriter::open)
- #close
- #closed?
- #comment
- comment= (Zstdlib::GzipWriter#comment=)
- #crc
- eof? (Zstdlib::GzipReader#eof?)
- #finish
- #level
- lineno (Zstdlib::GzipReader#lineno)
- lineno= (Zstdlib::GzipReader#lineno=)
- #mtime
- mtime= (Zstdlib::GzipWriter#mtime=)
- #orig_name
- orig_name (Zstdlib::GzipWriter#orig_name=)
- #os_code
- path (when the underlying IO supports #path)
- #sync
- #sync=
- #to_io
(due to internal structure, documentation may appear under Zstdlib::GzipReader or Zstdlib::GzipWriter)
Direct Known Subclasses
Defined Under Namespace
Classes: CRCError, Error, LengthError, NoFooter
Class Method Summary collapse
-
.wrap(*args) ⇒ Object
call-seq: Zstdlib::GzipReader.wrap(io, ...) { |gz| ... } Zstdlib::GzipWriter.wrap(io, ...) { |gz| ... }.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the GzipFile object.
-
#closed? ⇒ Boolean
Same as IO#closed?.
-
#comment ⇒ Object
Returns comments recorded in the gzip file header, or nil if the comments is not present.
-
#crc ⇒ Object
Returns CRC value of the uncompressed data.
-
#finish ⇒ Object
Closes the GzipFile object.
-
#level ⇒ Object
Returns compression level.
-
#mtime ⇒ Object
Returns last modification time recorded in the gzip file header.
-
#orig_name ⇒ Object
Returns original filename recorded in the gzip file header, or +nil+ if original filename is not present.
-
#os_code ⇒ Object
Returns OS code number recorded in the gzip file header.
-
#sync ⇒ Object
Same as IO#sync.
-
#sync=(mode) ⇒ Object
call-seq: sync = flag.
-
#to_io ⇒ Object
Same as IO.
Class Method Details
.wrap(*args) ⇒ Object
call-seq: Zstdlib::GzipReader.wrap(io, ...) { |gz| ... } Zstdlib::GzipWriter.wrap(io, ...) { |gz| ... }
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 Zstdlib::GzipFile#finish method in the block.
3237 3238 3239 3240 3241 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3237
static VALUE
rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
{
return gzfile_wrap(argc, argv, klass, 0);
}
|
Instance Method Details
#close ⇒ Object
Closes the GzipFile object. This method calls close method of the associated IO object. Returns the associated IO object.
3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3461
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;
}
|
#closed? ⇒ Boolean
Same as IO#closed?
3500 3501 3502 3503 3504 3505 3506 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3500
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;
}
|
#comment ⇒ Object
Returns comments recorded in the gzip file header, or nil if the comments is not present.
3337 3338 3339 3340 3341 3342 3343 3344 3345 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3337
static VALUE
rb_gzfile_comment(VALUE obj)
{
VALUE str = get_gzfile(obj)->comment;
if (!NIL_P(str)) {
str = rb_str_dup(str);
}
return str;
}
|
#crc ⇒ Object
Returns CRC value of the uncompressed data.
3276 3277 3278 3279 3280 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3276
static VALUE
rb_gzfile_crc(VALUE obj)
{
return rb_uint2inum(get_gzfile(obj)->crc);
}
|
#finish ⇒ Object
Closes the GzipFile object. Unlike Zstdlib::GzipFile#close, this method never calls the close method of the associated IO object. Returns the associated IO object.
3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3483
static VALUE
rb_gzfile_finish(VALUE obj)
{
struct gzfile *gz = get_gzfile(obj);
VALUE io;
io = gz->io;
gzfile_close(gz, 0);
return io;
}
|
#level ⇒ Object
Returns compression level.
3298 3299 3300 3301 3302 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3298
static VALUE
rb_gzfile_level(VALUE obj)
{
return INT2FIX(get_gzfile(obj)->level);
}
|
#mtime ⇒ Object
Returns last modification time recorded in the gzip file header.
3287 3288 3289 3290 3291 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3287
static VALUE
rb_gzfile_mtime(VALUE obj)
{
return rb_time_new(get_gzfile(obj)->mtime, (time_t)0);
}
|
#orig_name ⇒ Object
Returns original filename recorded in the gzip file header, or +nil+ if original filename is not present.
3321 3322 3323 3324 3325 3326 3327 3328 3329 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3321
static VALUE
rb_gzfile_orig_name(VALUE obj)
{
VALUE str = get_gzfile(obj)->orig_name;
if (!NIL_P(str)) {
str = rb_str_dup(str);
}
return str;
}
|
#os_code ⇒ Object
Returns OS code number recorded in the gzip file header.
3309 3310 3311 3312 3313 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3309
static VALUE
rb_gzfile_os_code(VALUE obj)
{
return INT2FIX(get_gzfile(obj)->os_code);
}
|
#sync ⇒ Object
Same as IO#sync
3526 3527 3528 3529 3530 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3526
static VALUE
rb_gzfile_sync(VALUE obj)
{
return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse;
}
|
#sync=(mode) ⇒ Object
call-seq: sync = flag
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.
3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3541
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;
}
|
#to_io ⇒ Object
Same as IO.
3265 3266 3267 3268 3269 |
# File 'ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c', line 3265
static VALUE
rb_gzfile_to_io(VALUE obj)
{
return get_gzfile(obj)->io;
}
|