1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/fileutils.rb (FileUtils.cp_r): implement :remove_destination

option.

* ext/extmk.rb: use :remove_destination to install extension libraries
  to avoid SEGV.
  [ruby-dev:28417]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2006-03-03 12:24:53 +00:00
parent 469f1f7b49
commit 192fcacebf
3 changed files with 18 additions and 6 deletions

View file

@ -1,3 +1,12 @@
Fri Mar 3 21:22:42 2006 Tanaka Akira <akr@m17n.org>
* lib/fileutils.rb (FileUtils.cp_r): implement :remove_destination
option.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV.
[ruby-dev:28417]
Fri Mar 3 14:41:04 2006 Minero Aoki <aamine@loveruby.net>
* ext/dl/.cvsignore: ignore callback.h.

View file

@ -381,7 +381,7 @@ if $extout
RbConfig.expand(extout = "#$extout", RbConfig::CONFIG.merge("topdir"=>$topdir))
if $install
RbConfig.expand(dest = "#{$destdir}#{$rubylibdir}")
FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun)
FileUtils.cp_r(extout+"/.", dest, :remove_destination => true, :verbose => true, :noop => $dryrun)
exit
end
unless $ignore

View file

@ -392,7 +392,7 @@ module FileUtils
OPT_TABLE['copy'] = %w( noop verbose preserve )
#
# Options: preserve noop verbose dereference_root
# Options: preserve noop verbose dereference_root remove_destination
#
# Copies +src+ to +dest+. If +src+ is a directory, this method copies
# all its contents recursively. If +dest+ is a directory, copies
@ -415,11 +415,11 @@ module FileUtils
# # but this doesn't.
#
def cp_r(src, dest, options = {})
fu_check_options options, :preserve, :noop, :verbose, :dereference_root
fu_output_message "cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
fu_check_options options, :preserve, :noop, :verbose, :dereference_root, :remove_destination
fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
fu_each_src_dest(src, dest) do |s, d|
copy_entry s, d, options[:preserve], options[:dereference_root]
copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]
end
end
module_function :cp_r
@ -440,9 +440,12 @@ module FileUtils
#
# If +dereference_root+ is true, this method dereference tree root.
#
def copy_entry(src, dest, preserve = false, dereference_root = false)
# If +remove_destination+ is true, this method removes each destination file before copy.
#
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
Entry_.new(src, nil, dereference_root).traverse do |ent|
destent = Entry_.new(dest, ent.rel, false)
File.unlink destent.path if remove_destination && File.file?(destent.path)
ent.copy destent.path
ent.copy_metadata destent.path if preserve
end