diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-25 02:06:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-25 02:06:29 +0000 |
commit | 97de7d1081e69ad9d63c03b0f6a700954f8e4402 (patch) | |
tree | 7cab17680e1e1f5c6b9340fb0102ef661f4db6c6 /lib/fileutils.rb | |
parent | 0506348ef501d5f2e3dc64666b6bb6785870583c (diff) | |
download | ruby-97de7d1081e69ad9d63c03b0f6a700954f8e4402.tar.gz |
* Makefile.in, win32/Makefile.sub (RMDIRS): remove directory and
parents.
* Makefile.in, win32/Makefile.sub (distclean-rdoc): added to remove
temprary rdoc.
* Makefile.in, win32/Makefile.sub (distclean): removes extout
directory.
* Makefile.in, win32/Makefile.sub (clean-ext): skips non-existent
directories.
* common.mk (clean, distclean): cleans rdoc.
* configure.in (RMDIRS, RMALL): added to clean extout.
* lib/fileutils.rb (FileUtils#rmdir): added :parents option.
* lib/mkmf.rb (create_makefile): cleans installed files at clean
instead of distclean.
* lib/mkmf.rb (create_makefile): added clean-so and clean-rb.
* lib/mkmf.rb (def init_mkmf): added DISTCLEANDIRS.
* lib/un.rb (rmdir): added -p option.
* tool/rmdirs, win32/rmdirs.bat: removes directory and the parents.
* win32/rm.bat: added -r option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r-- | lib/fileutils.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 56fb19beb2..774c0dec8a 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -258,15 +258,24 @@ module FileUtils 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 |