Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
FileUtils#compare_file
compare_file(a, b)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/fileutils.rb, line 1507
def compare_file(a, b)
return false unless File.size(a) == File.size(b)
File.open(a, 'rb') {|fa|
File.open(b, 'rb') {|fb|
return compare_stream(fa, fb)
}
}
end
Returns true if the contents of files a and b are identical, false otherwise.
Arguments a and b should be interpretable as a path.
FileUtils.identical? and FileUtils.cmp are aliases for FileUtils.compare_file.
Related: FileUtils.compare_stream.