Peña, Botp
10/25/2008 6:00:00 AM
From: Nobuyoshi Nakada [mailto:nobu@ruby-lang.org]=20
# At Sat, 25 Oct 2008 03:21:21 +0900,
# Kenneth McDonald wrote in [ruby-talk:318516]:
# > From the documentation, that seems to compare to different=20
# files to =20
# > see if they have the same content. Thanks for the=20
# suggestion, though.
#=20
# It tells whether two files are an identical file, in other
# words, same hardlinks. The doc is too terse?
i think, Nobu, the method naming is misleading/clashing in File and =
FileUtils.
there is File.identical? but there is also Fileutils#identical? wc is =
aliased to compare_file, wc is totally different w File.identical
imho, there are already too many method names in ruby to remember. a lot =
almost having the same fxnality.
it would be nice if file.identical just returns nil, or 1, or 0, where =
nil for different, 1 for same, and 0 for same self.
comparison of File/fileutils identical follows..
~$ qri file#identical?
-------------------------------------------------------=20
File.identical?(file_1, file_2) =3D> true or false
--------------------------------------------------------
Returns true if the named files are identical.
open("a", "w") {}
p File.identical?("a", "a") #=3D> true
p File.identical?("a", "./a") #=3D> true
File.link("a", "b")
p File.identical?("a", "b") #=3D> true
File.symlink("a", "c")
p File.identical?("a", "c") #=3D> true
open("d", "w") {}
p File.identical?("a", "d") #=3D> false
~$ qri fileutils#identical?
--------------------------------------------------- FileUtils#identical?
identical?(a, b)
---------------------------------------------------
Alias for #compare_file
Alias for #compare_file
~$ qri fileutils#compare_file
------------------------------------------------- FileUtils#compare_file
compare_file(a, b)
-------------------------------------------------
Returns true if the contents of a file A and a file B are
identical.
FileUtils.compare_file('somefile', 'somefile') #=3D> true
FileUtils.compare_file('/bin/cp', '/bin/mv') #=3D> maybe false
(also known as identical?, cmp)