Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: readbytes.rb
# TruncatedDataError is raised when IO#readbytes fails to read enough data.
[0] Fix | Delete
[1] Fix | Delete
class TruncatedDataError<IOError
[2] Fix | Delete
def initialize(mesg, data) # :nodoc:
[3] Fix | Delete
@data = data
[4] Fix | Delete
super(mesg)
[5] Fix | Delete
end
[6] Fix | Delete
[7] Fix | Delete
# The read portion of an IO#readbytes attempt.
[8] Fix | Delete
attr_reader :data
[9] Fix | Delete
end
[10] Fix | Delete
[11] Fix | Delete
class IO
[12] Fix | Delete
# Reads exactly +n+ bytes.
[13] Fix | Delete
#
[14] Fix | Delete
# If the data read is nil an EOFError is raised.
[15] Fix | Delete
#
[16] Fix | Delete
# If the data read is too short a TruncatedDataError is raised and the read
[17] Fix | Delete
# data is obtainable via its #data method.
[18] Fix | Delete
def readbytes(n)
[19] Fix | Delete
str = read(n)
[20] Fix | Delete
if str == nil
[21] Fix | Delete
raise EOFError, "End of file reached"
[22] Fix | Delete
end
[23] Fix | Delete
if str.size < n
[24] Fix | Delete
raise TruncatedDataError.new("data truncated", str)
[25] Fix | Delete
end
[26] Fix | Delete
str
[27] Fix | Delete
end
[28] Fix | Delete
end
[29] Fix | Delete
[30] Fix | Delete
if __FILE__ == $0
[31] Fix | Delete
begin
[32] Fix | Delete
loop do
[33] Fix | Delete
print STDIN.readbytes(6)
[34] Fix | Delete
end
[35] Fix | Delete
rescue TruncatedDataError
[36] Fix | Delete
p $!.data
[37] Fix | Delete
raise
[38] Fix | Delete
end
[39] Fix | Delete
end
[40] Fix | Delete
[41] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function