Method: FileUtils2#compare_file
- Defined in:
- lib/fileutils2.rb
#compare_file(a, b) ⇒ Object Also known as: identical?, cmp
Returns true if the contents of a file A and a file B are identical.
FileUtils.compare_file('somefile', 'somefile') #=> true
FileUtils.compare_file('/bin/cp', '/bin/mv') #=> maybe false
891 892 893 894 895 896 897 898 |
# File 'lib/fileutils2.rb', line 891 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 |