summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/pathname.rb4
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f555b70bc..b85c2508d 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 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