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
commit7312ba0819fa0f0fc4df76a314b5eb42d3789dc0 (patch)
treea4ff843f995e0d52bf763048dc8d5d8c7934246d /lib/pathname.rb
parentbe6a8631d01d7101a32e09a610d4070cfd5f331d (diff)
downloadruby-7312ba0819fa0f0fc4df76a314b5eb42d3789dc0.tar.gz
ruby-7312ba0819fa0f0fc4df76a314b5eb42d3789dc0.tar.xz
ruby-7312ba0819fa0f0fc4df76a314b5eb42d3789dc0.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/branches/ruby_1_8@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 b7cc01edb..b21abd746 100644
--- a/lib/pathname.rb
+++ b/lib/pathname.rb
@@ -861,9 +861,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