Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
FileUtils.identical?
(::FileUtils::path a, ::FileUtils::path b) -> bool
identical?(a, b)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/fileutils.rb, line 1534
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
Alias of .compare_file
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.