[前][次][番号順一覧][スレッド一覧]

ruby-changes:16451

From: knu <ko1@a...>
Date: Sat, 26 Jun 2010 00:05:26 +0900 (JST)
Subject: [ruby-changes:16451] Ruby:r28436 (ruby_1_8): * lib/fileutils.rb (FileUtils#rmdir): Backport -p (parents). This

knu	2010-06-26 00:05:14 +0900 (Sat, 26 Jun 2010)

  New Revision: 28436

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28436

  Log:
    * lib/fileutils.rb (FileUtils#rmdir): Backport -p (parents).  This
      fixes "make clean".

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/lib/fileutils.rb

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 28435)
+++ ruby_1_8/ChangeLog	(revision 28436)
@@ -1,3 +1,8 @@
+Sat Jun 26 00:04:27 2010  Akinori MUSHA  <knu@i...>
+
+	* lib/fileutils.rb (FileUtils#rmdir): Backport -p (parents).  This
+	  fixes "make clean".
+
 Fri Jun 25 23:45:24 2010  Akinori MUSHA  <knu@i...>
 
 	* common.mk (version.$(OBJEXT)): Fix build. (GNU make seems to
Index: ruby_1_8/lib/fileutils.rb
===================================================================
--- ruby_1_8/lib/fileutils.rb	(revision 28435)
+++ ruby_1_8/lib/fileutils.rb	(revision 28436)
@@ -258,15 +258,24 @@
   def rmdir(list, options = {})
     fu_check_options options, OPT_TABLE['rmdir']
     list = fu_list(list)
-    fu_output_message "rmdir #{list.join ' '}" if options[:verbose]
+    parents = options[:parents]
+    fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose]
     return if options[:noop]
     list.each do |dir|
-      Dir.rmdir dir.sub(%r</\z>, '')
+      begin
+        Dir.rmdir(dir = dir.sub(%r</\z>, ''))
+        if parents
+          until (parent = File.dirname(dir)) == '.' or parent == dir
+            Dir.rmdir(dir)
+          end
+        end
+      rescue Errno::ENOTEMPTY, Errno::ENOENT
+      end
     end
   end
   module_function :rmdir
 
-  OPT_TABLE['rmdir'] = [:noop, :verbose]
+  OPT_TABLE['rmdir'] = [:parents, :noop, :verbose]
 
   #
   # Options: force noop verbose

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]