class method
FileUtils.compare_stream
(::IO a, ::IO b) -> bool
compare_stream(a, b)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/fileutils.rb, line 1528
def compare_stream(a, b)
bsize = fu_stream_blksize(a, b)
sa = String.new(capacity: bsize)
sb = String.new(capacity: bsize)
begin
a.read(bsize, sa)
b.read(bsize, sb)
return true if sa.empty? && sb.empty?
end while sa == sb
false
end
Returns true if the contents of streams a and b are identical, false otherwise.
Arguments a and b should be interpretable as a path.
Related: FileUtils.compare_file.