summaryrefslogtreecommitdiff
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
commitb5c68b60bd408a4e14cd58ac0410b0a7444610c2 (patch)
treea4ff843f995e0d52bf763048dc8d5d8c7934246d
parentcaf49155c15fe108142e9665701439477c3686d7 (diff)
* lib/pathname.rb (Pathname#unlink): try Dir.unlink first to
avoid unlink a directory by root. cf. [ruby-dev:26237] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/pathname.rb4
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 52e9bc9..87490a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Jul 10 23:58:04 2005 Tanaka Akira <akr@m17n.org>
+
+ * lib/pathname.rb (Pathname#unlink): try Dir.unlink first to
+ avoid unlink a directory by root.
+ cf. [ruby-dev:26237]
+
Sun Jul 10 12:47:01 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/debug.rb (debug_command): added a deficient format specifier.
diff --git a/lib/pathname.rb b/lib/pathname.rb
index b7cc01e..b21abd7 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