summaryrefslogtreecommitdiffstats
path: root/lib/pathname.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-10 15:17:35 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-10 15:17:35 +0000
commit95dd3615b3c799c1b8a3d300a3ee52b7150f9ffe (patch)
tree3ac2609826c67f740eb692dab18e6a248c436b6c /lib/pathname.rb
parent44355d14f438c072ca5314e434a4b3abe68d1da9 (diff)
downloadruby-95dd3615b3c799c1b8a3d300a3ee52b7150f9ffe.tar.gz
ruby-95dd3615b3c799c1b8a3d300a3ee52b7150f9ffe.tar.xz
ruby-95dd3615b3c799c1b8a3d300a3ee52b7150f9ffe.zip
* lib/pathname.rb (Pathname#unlink): try Dir.unlink first to
avoid unlink a directory by root. cf. [ruby-dev:26237] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@8743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pathname.rb')
-rw-r--r--lib/pathname.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pathname.rb b/lib/pathname.rb
index 9a08fa39c..fd7fa508b 100644
--- a/lib/pathname.rb
+++ b/lib/pathname.rb
@@ -869,9 +869,9 @@ class Pathname # * mixed *
# <tt>Dir.unlink</tt> as necessary.
def unlink()
begin
- File.unlink @path
- rescue SystemCallError
Dir.unlink @path
+ rescue Errno::ENOTDIR
+ File.unlink @path
end
end
alias delete unlink