Method: FileUtils.cmp

Defined in:
lib/fileutils.rb

.cmpObject

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.


1519
1520
1521
1522
1523
1524
1525
1526
# File 'lib/fileutils.rb', line 1519

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