Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
FileUtils#compare_stream
compare_stream(a, b)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/fileutils.rb, line 1530
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.