5bbd7f633d
The old implementation loaded files into memory to provide an IO interface. This has the obvious downside of loading any file included in the import, e.g. a 10GB video file, into memory. ZipKit has no native IO object for reading but it provides all the necessary methods to implement one.
24 lines
368 B
Ruby
24 lines
368 B
Ruby
class ZipFile::Reader::ExtractorIO
|
|
def initialize(extractor)
|
|
@extractor = extractor
|
|
end
|
|
|
|
def read(length = nil, buffer = nil)
|
|
return nil if @extractor.eof?
|
|
|
|
data = @extractor.extract(length)
|
|
return nil if data.nil?
|
|
|
|
if buffer
|
|
buffer.replace(data)
|
|
buffer
|
|
else
|
|
data
|
|
end
|
|
end
|
|
|
|
def eof?
|
|
@extractor.eof?
|
|
end
|
|
end
|