Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby - FileUtils - dereference_root option

Can someone explain me exactly (better if with examples) the meaning of the dereference_root option in FileUtils.cp_r and in other class method of the same class?

Thank you in advance.

like image 452
Astorre Avatar asked Aug 03 '13 21:08

Astorre


People also ask

How to install Ruby library in site_Ruby?

# Installing Ruby library "mylib" under the site_ruby FileUtils. rm_r site_ruby + '/mylib', :force FileUtils. cp_r 'lib/', site_ruby + '/mylib' # Examples of copying several files to target directory.

What does the options parameter mean in Ruby?

This program is free software. You can distribute/modify this program under the same terms of ruby. Namespace for several file utility methods for copying, moving, removing, etc. The options parameter is a hash of options, taken from the list :force, :noop, :preserve, and :verbose. :noop means that no changes are made. The other three are obvious.

Is there a free version of fileutils?

This program is free software. You can distribute/modify this program under the same terms of ruby. Namespace for several file utility methods for copying, moving, removing, etc. require 'fileutils' FileUtils.cd (dir, options) FileUtils.cd (dir, options) {|dir| ....


1 Answers

It applies only if your source file/directory is symbolic link. If it is and you specify this option, then FileUtils.cp_r will follow this link and copy the original files otherwise you will get just a copy of the symlink.

But this doesn't apply recursively. So if you will have other symlinks inside your source folder they will be just copied as is, without 'dereferencing'.

like image 58
Stas S Avatar answered Sep 30 '22 19:09

Stas S