Created
August 4, 2008 18:35
-
-
Save edsono/3947 to your computer and use it in GitHub Desktop.
A little 'patch' to rubzip making possible to unzip files with StringIO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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