Project

General

Profile

Feature #4189

FileUtils#ln_r

Added by trans (Thomas Sawyer) almost 8 years ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:33820]

Description

=begin
I wrote a method for FileUtils to do recursive hard linking. It works just like cp_r but links instead of copies.

The code can be found along with the pull request I made to ruby/ruby on Github:

http://github.com/ruby/ruby/pull/4#issuecomment-631067

It's a pretty handy method for "staging" read-only files. For example I've used it to stage test fixture files in a tmp testing location and I've used it collect together a set of files for packaging into a tarball.
=end

fileutils_ln_r.patch (4.72 KB) fileutils_ln_r.patch zzak (Zachary Scott), 11/19/2012 07:09 AM
fileutils_cp_lr.patch (4.72 KB) fileutils_cp_lr.patch mame (Yusuke Endoh), 03/08/2018 08:29 AM

Associated revisions

Revision d583ee26
Added by mame (Yusuke Endoh) 9 months ago

Add FileUtils#cp_lr

  • lib/fileutils.rb: Add FileUtils#cp_lr. This method creates hard links of each file from directory to another directory recursively. This patch is based on Thomas Sawyers and Zachary Scott. [Feature #4189]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62739
Added by mame (Yusuke Endoh) 9 months ago

Add FileUtils#cp_lr

  • lib/fileutils.rb: Add FileUtils#cp_lr. This method creates hard links of each file from directory to another directory recursively. This patch is based on Thomas Sawyers and Zachary Scott. [Feature #4189]

History

#1 [ruby-core:35848] Updated by naruse (Yui NARUSE) over 7 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

#2 [ruby-core:35849] Updated by matz (Yukihiro Matsumoto) over 7 years ago

=begin
Since ln command does not have -r option, I am kind of hesitating to add ln_r. I understand usefulness of the method. But I am not sure yet where to add (is fileutils the best place?), and what to add (is ln_r the best name for the method?).

matz.
=end

#3 [ruby-core:35850] Updated by sakuro (Sakuro OZAWA) over 7 years ago

=begin
FYI
X11 distribution has lndir command, it creates real directories and file symlinks though.
=end

#4 [ruby-core:35870] Updated by johan556 (Johan Holmberg) over 7 years ago

=begin
GNU cp has the -l option, so I think the proposed method is similiar to "cp -lr" on Linux systems.
=end

#5 [ruby-core:45813] Updated by reset (Jamie Winsor) over 6 years ago

This ticket hasn't seen action in a year, but I wanted to chime in and +1 the feature.

Having a convenience function to recursively create hard links based on a source directory is a rare need, but a need, nonetheless. I think FileUtils is a fine place for it when compared to the other choices of where to place it in Ruby core.

#6 [ruby-core:49532] Updated by zzak (Zachary Scott) about 6 years ago

Adding Thomas' patch from github.

#7 [ruby-core:49960] Updated by mame (Yusuke Endoh) about 6 years ago

  • Target version set to 2.6

#8 [ruby-core:83962] Updated by matz (Yukihiro Matsumoto) about 1 year ago

Accepted, but I am against the name ln_r because it behaves differently from ln -r (relative).

Matz.

#9 [ruby-core:83964] Updated by akr (Akira Tanaka) about 1 year ago

After discussion at the developer meeting, cp_lr may be an consensus.

#10 Updated by naruse (Yui NARUSE) 12 months ago

  • Target version deleted (2.6)

#11 [ruby-core:86034] Updated by mame (Yusuke Endoh) 9 months ago

I'll commit this patch that introduces FileUtils.cp_lr in a few days. Let me know if there is a problem.

#12 [ruby-core:86035] Updated by mame (Yusuke Endoh) 9 months ago

  • Assignee changed from matz (Yukihiro Matsumoto) to mame (Yusuke Endoh)

#13 Updated by mame (Yusuke Endoh) 9 months ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r62739.


Add FileUtils#cp_lr

  • lib/fileutils.rb: Add FileUtils#cp_lr. This method creates hard links of each file from directory to another directory recursively. This patch is based on Thomas Sawyers and Zachary Scott. [Feature #4189]

Also available in: Atom PDF