Method: FileUtils.identical?
- Defined in:
- lib/fileutils.rb
permalink .identical? ⇒ Object
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.
1518 1519 1520 1521 1522 1523 1524 1525 |
# File 'lib/fileutils.rb', line 1518 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 |