Class: Zlib::Inflate
Instance Attribute Summary
Attributes inherited from ZStream
#buf, #flags, #func, #input, #stream, #z
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ZStream
#ZSTREAM_IS_CLOSING, #ZSTREAM_IS_FINISHED, #ZSTREAM_IS_READY, #ZSTREAM_READY, #adler, #avail_in, #avail_out, #avail_out=, #close, #closed?, #data_type, #finish, #finished?, #flush_next_in, #flush_next_out, #raise_zlib_error, #reset, #total_in, #total_out, #zstream_append_buffer, #zstream_append_input, #zstream_buffer_ungetc, #zstream_detach_buffer, #zstream_detach_input, #zstream_discard_input, #zstream_end, #zstream_expand_buffer, #zstream_init, #zstream_passthrough_input, #zstream_reset, #zstream_reset_input, #zstream_run, #zstream_shift_buffer, #zstream_sync
Constructor Details
#initialize(wbits = MAX_WBITS) ⇒ Inflate
Returns a new instance of Inflate.
634
635
636
637
638
639
640
641
642
|
# File 'lib/pr/zlib.rb', line 634
def initialize(wbits=MAX_WBITS)
@z = ZStream.new
@z.zstream_init(InflateFuncs)
err = inflateInit2(@z.stream, wbits)
if (err != Z_OK)
raise_zlib_error(err, @z.stream.msg)
end
@z.ZSTREAM_READY()
end
|
Class Method Details
.inflate(src) ⇒ Object
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
|
# File 'lib/pr/zlib.rb', line 607
def self.inflate(src)
@z = ZStream.new
@z.zstream_init(InflateFuncs)
err = inflateInit(@z.stream)
if (err != Z_OK)
raise_zlib_error(err, @z.stream.msg)
end
@z.ZSTREAM_READY()
begin
dst = inflate_run(src)
ensure
@z.zstream_end
end
dst
end
|
.inflate_run(src) ⇒ Object
601
602
603
604
605
|
# File 'lib/pr/zlib.rb', line 601
def self.inflate_run(src)
@z.zstream_run(src,src.length,Z_SYNC_FLUSH)
@z.zstream_run('',0,Z_FINISH)
@z.zstream_detach_buffer()
end
|
Instance Method Details
#<<(src) ⇒ Object
662
663
664
665
666
667
668
669
670
671
672
673
674
|
# File 'lib/pr/zlib.rb', line 662
def <<(src)
if @z.ZSTREAM_IS_FINISHED()
if src
@z.zstream_append_buffer(src,src.length)
end
else
do_inflate(src)
if @z.ZSTREAM_IS_FINISHED()
@z.zstream_passthrough_input()
end
end
self
end
|
#inflate(src) ⇒ Object
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
|
# File 'lib/pr/zlib.rb', line 644
def inflate(src)
if (@z.ZSTREAM_IS_FINISHED())
if src.nil?
dst = @z.zstream_detach_buffer()
else
@z.zstream_append_buffer(src,src.lenth)
dst = ''
end
else
do_inflate(src)
dst = @z.zstream_detach_buffer()
if (@z.ZSTREAM_IS_FINISHED())
@z.zstream_passthrough_input()
end
end
dst
end
|
#set_dictionary(dic) ⇒ Object
692
693
694
695
696
697
698
699
700
701
|
# File 'lib/pr/zlib.rb', line 692
def set_dictionary(dic)
src = dic
err = inflateSetDictionary(@z.stream,src,src.length)
if err != Z_OK
raise_zlib_error(err, @z.stream.msg)
end
dic
end
|
#sync ⇒ Object
676
677
678
679
|
# File 'lib/pr/zlib.rb', line 676
def sync
raise GzipFile::Error,"closed gzip stream" unless @gz.z.ZSTREAM_IS_READY()
return @z.zstream_sync(src,src.length)
end
|
#sync_point? ⇒ Boolean
681
682
683
684
685
686
687
688
689
690
|
# File 'lib/pr/zlib.rb', line 681
def sync_point?()
err = inflateSyncPoint(@z.stream)
return true if err == 1
if err != Z_OK
raise_zlib_error(err, @z.stream.msg)
end
false
end
|