diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-18 10:05:21 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-18 10:05:21 +0000 |
commit | 5d24b03964cc4498db916c63f7d850ebf969a922 (patch) | |
tree | 434d7efa10f17befbb48446cc3d89d4a508a356e /lib/fileutils.rb | |
parent | 674c62c94c1f2a88a9f8017e7367b9dc1810438e (diff) | |
download | ruby-5d24b03964cc4498db916c63f7d850ebf969a922.tar.gz ruby-5d24b03964cc4498db916c63f7d850ebf969a922.tar.xz ruby-5d24b03964cc4498db916c63f7d850ebf969a922.zip |
* lib/fileutils.rb (fu_same?): check by inode instead of path name, to detect two hard links pointing to the same content.
* test/fileutils.rb: did not create correctly looped symlinks.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r-- | lib/fileutils.rb | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 94a8f5e93..9b50aec91 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -739,35 +739,9 @@ module FileUtils end def fu_same?( a, b ) - fu_resolve_symlink(a) == fu_resolve_symlink(b) - end - - def fu_resolve_symlink( path, limit = 128 ) - raise Errno::ELOOP, "too many levels of symlic links: #{path}" if limit < 0 - if File.symlink?(path) - then fu_resolve_symlink(fu_readlink(File.expand_path(path)), limit-1) - else path - end - end - - def fu_readlink( path ) - dest = File.readlink(path) - if absolute_path?(dest) - then dest - else File.dirname(File.expand_path(path)) + '/' + dest - path = File.readlink(path) - end - end - - def absolute_path?( path ) - if have_drive_letter? - then %r<\A([a-z]:)?/> === path - else %r<\A/> === path - end - end - - def have_drive_letter? - File::ALT_SEPARATOR ? true : false + File.stat(a).ino == File.stat(b).ino + rescue Errno::ENOENT + return false end def fu_stream_blksize( *streams ) |