Method: FileUtils.compare_file
- Defined in:
- lib/fileutils.rb
.compare_file(a, b) ⇒ 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.
1508 1509 1510 1511 1512 1513 1514 1515 |
# File 'lib/fileutils.rb', line 1508 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 |