Methods
Classes and Modules
Class Zlib::GzipReader::DataErrorClass Zlib::GzipReader::Error
Class Zlib::GzipReader::NeedDict
Constants
| OSES | = | ['FAT filesystem', 'Amiga', 'VMS (or OpenVMS)', 'Unix', 'VM/CMS', 'Atari TOS', 'HPFS fileystem (OS/2, NT)', 'Macintosh', 'Z-System', 'CP/M', 'TOPS-20', 'NTFS filesystem (NT)', 'QDOS', 'Acorn RISCOS', 'unknown'] |
Public Class methods
[ show source ]
# File lib/zliby.rb, line 458 def initialize io super() @io = io io.read.each_byte {|b| @input_buffer << b} if @input_buffer[@in_pos+=1] != 0x1f || @input_buffer[@in_pos+=1] != 0x8b then raise Zlib::GzipFile::Error.new("not in gzip format") end if @input_buffer[@in_pos+=1] != 0x08 then raise Zlib::GzipFile::Error.new("unknown compression method") end flg = @input_buffer[@in_pos+=1] @ftext = flg.isbitset? 0 @fhcrc = flg.isbitset? 1 @fextra = flg.isbitset? 2 @fname = flg.isbitset? 3 @fcomment = flg.isbitset? 4 @mtime = Time.at(@input_buffer[@in_pos+=1] | (@input_buffer[@in_pos+=1] << 8) | (@input_buffer[@in_pos+=1] << 16) | (@input_buffer[@in_pos+=1] << 24)) @xfl = @input_buffer[@in_pos+=1] @os = OSES[@input_buffer[@in_pos+=1]] if @fextra then @xlen = (@input_buffer[@in_pos+=1] | (@input_buffer[@in_pos+=1] << 8)) @xtra_field = [] @xlen.times {@xtra_field << @input_buffer[@in_pos+=1]} end if @fname then @original_name = "" until @original_name["\0"].nil? == false @original_name.concat(@input_buffer[@in_pos+=1]) end @original_name.chop! end if @fcomment then @comment = "" until @comment["\0"].nil? == false @comment.concat(@input_buffer[@in_pos+=1]) end @comment.chop! end if @fhcrc then @header_crc = @input_buffer[@in_pos+=1] | (@input_buffer[@in_pos+=1] << 8) end @contents = "" until @in_pos == @input_buffer.length-1 @contents.concat(@input_buffer[@in_pos+=1]) end end
[ show source ]
# File lib/zliby.rb, line 513 def open filename io = File.open filename gz = self.new io if block_given? then yield gz else gz end end end
Public Instance methods
[ show source ]
# File lib/zliby.rb, line 508 def close end
[ show source ]
# File lib/zliby.rb, line 502 def read #we do raw deflate, no headers z = Zlib::Inflate.new -MAX_WBITS z.inflate @contents end