Method: LZMA::Decoder#read
- Defined in:
- lib/extlzma.rb
#read(size = nil, buf = "".force_encoding(Encoding::BINARY)) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/extlzma.rb', line 244 def read(size = nil, buf = "".force_encoding(Encoding::BINARY)) buf.clear size = size.to_i if size return buf if size == 0 tmp = "".force_encoding(Encoding::BINARY) while !eof && (size.nil? || size > 0) if workbuf.eof? fetch or break end workbuf.read(size, tmp) or break buf << tmp size -= tmp.bytesize if size end (buf.empty? ? nil : buf) end |