Created
March 23, 2009 20:38
-
-
Save jhchabran/83760 to your computer and use it in GitHub Desktop.
This file contains 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
class IO | |
def readbytes(n) | |
str = read(n) | |
if str == nil | |
raise EOFError, "End of file reached" | |
end | |
if str.size < n | |
raise TruncatedDataError.new("data truncated", str) | |
end | |
str | |
end | |
end | |
# little hack to tame Archive/Zip which requires 'readbytes' | |
# :nodoc: | |
module Kernel | |
def require_with_readbytes_hack(something) | |
return true if something == 'readbytes' | |
require_without_readbytes_hack something | |
end | |
alias_method :require_without_readbytes_hack, | |
:require | |
alias_method :require, | |
:require_with_readbytes_hack | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment