method
mv
ruby latest stable - Class:
FileUtils
mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)private
Moves file(s) src to dest. If file and dest exist on the different disk partition, the file is copied then the original file is removed.
FileUtils .mv 'badname.rb', 'goodname.rb' FileUtils .mv 'stuff.rb', '/notexist/lib/ruby', :force => true # no error FileUtils .mv %w(junk.txt dust.txt), '/home/foo/.trash/' FileUtils .mv Dir .glob('test*.rb'), 'test', :noop => true, :verbose => true
# File lib/fileutils.rb, line 457
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
fu_each_src_dest(src, dest) do |s, d|
destent = Entry_.new(d, nil, true)
begin
if destent.exist?
if destent.directory?
raise Errno::EEXIST, d
else
destent.remove_file if rename_cannot_overwrite_file?
end
end
begin
File.rename s, d
rescue Errno::EXDEV
copy_entry s, d, true
if secure
remove_entry_secure s, force
else
remove_entry s, force
end
end
rescue SystemCallError
raise unless force
end
end
end