From: Thomas Enebo Date: 2008-04-15T00:13:34+09:00 Subject: Re: cross-platform1: st1.dev == st2.dev and st1.ino == st2.ino considered harmful Urabe Shyouhei wrote: > Thomas Enebo wrote: >> Perhaps: >> >> st1.same?(st2) > > We already have File.identical? That method can at least get rid of one use of .ino + .dev. Patch below for file_utils.rb. It does not get rid of the second use in file_utils which is based on an lstat. So it may still be a good idea to perhaps have FileStat.identical? so results of lstat may still be tested. This could get rid of fu_stat_identical_entry?. Ultimately, I am bringing topics up like this because it would be nice to remove special checks from standard libraries (not all systems support .ino and .dev for example). -Tom Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 15992) +++ lib/fileutils.rb (working copy) @@ -1388,7 +1388,7 @@ def fu_each_src_dest(src, dest) #:nodoc: fu_each_src_dest0(src, dest) do |s, d| - raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d) + raise ArgumentError, "same file: #{s} and #{d}" if File.identical?(s, d) yield s, d end end @@ -1411,24 +1411,6 @@ end private_module_function :fu_each_src_dest0 - def fu_same?(a, b) #:nodoc: - if fu_have_st_ino? - st1 = File.stat(a) - st2 = File.stat(b) - st1.dev == st2.dev and st1.ino == st2.ino - else - File.expand_path(a) == File.expand_path(b) - end - rescue Errno::ENOENT - return false - end - private_module_function :fu_same? - - def fu_have_st_ino? #:nodoc: - not fu_windows? - end - private_module_function :fu_have_st_ino? - def fu_check_options(options, optdecl) #:nodoc: h = options.dup optdecl.each do |opt|