Skip to content

Instantly share code, notes, and snippets.

@edsono
Created August 4, 2008 18:35
Show Gist options
  • Save edsono/3947 to your computer and use it in GitHub Desktop.
Save edsono/3947 to your computer and use it in GitHub Desktop.
A little 'patch' to rubzip making possible to unzip files with StringIO
# To make possible unzip in-memory Zip files with StringIO
module Zip
class ZipInputStream
def initialize(filename, offset = 0)
super()
@archiveIO = filename.class == String ? File.open(filename, "rb") : filename
@archiveIO.seek(offset, IO::SEEK_SET)
@decompressor = NullDecompressor.instance
@currentEntry = nil
end
end
class ::StringIO
alias :old_read :read
def read(length, buffer=nil)
buffer ? old_read(length, buffer) : old_read(length)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment